sender.sendDocument(new SendDocument() .setDocument(backup) .setChatId(ctx.chatId()) ); } catch (FileNotFoundException e) {
sendDocument.validate(); try { String url = getBaseUrl() + SendDocument.PATH; builder.setLaxMode(); builder.setCharset(StandardCharsets.UTF_8); builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId(), TEXT_PLAIN_CONTENT_TYPE); addInputFile(builder, sendDocument.getDocument(), SendDocument.DOCUMENT_FIELD, true); if (sendDocument.getReplyMarkup() != null) { builder.addTextBody(SendDocument.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendDocument.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getReplyToMessageId() != null) { builder.addTextBody(SendDocument.REPLYTOMESSAGEID_FIELD, sendDocument.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getCaption() != null) { builder.addTextBody(SendDocument.CAPTION_FIELD, sendDocument.getCaption(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getParseMode() != null) { builder.addTextBody(SendDocument.PARSEMODE_FIELD, sendDocument.getParseMode(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getDisableNotification() != null) { builder.addTextBody(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getThumb() != null) { addInputFile(builder, sendDocument.getThumb(), SendDocument.THUMB_FIELD, false); builder.addTextBody(SendDocument.THUMB_FIELD, sendDocument.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE); return sendDocument.deserializeResponse(sendHttpPostRequest(httppost));
/** * Fetch the language file for WP * @param language Language requested */ public SendDocument getWPLanguageFile(String language) { SendDocument sendDocument = null; try { byte[] file = getFileWP(language); if (file != null && file.length / BYTES1024 >= 10) { try { String fileName = "languages_wp_" + language + ".xml"; File fileToUpload = new File(fileName); FileOutputStream output = new FileOutputStream(fileToUpload); IOUtils.write(file, output); output.close(); if (fileToUpload.exists()) { sendDocument = new SendDocument(); sendDocument.setDocument(fileToUpload); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } return sendDocument; } }
sendDocument.setChatId(message.getChatId()); try { execute(sendDocument);
/** * Fetch the language file for Tdesktop * @param language Language requested */ public SendDocument getTdesktopLanguageFile(String language) { SendDocument sendDocument = null; try { byte[] file = getFileTDesktop(language); if (file != null && file.length / BYTES1024 >= 10) { try { String fileName = "languages_tdesktop_" + language + ".strings"; File fileToUpload = new File(fileName); FileOutputStream output = new FileOutputStream(fileToUpload); IOUtils.write(file, output); output.close(); if (fileToUpload.exists()) { sendDocument = new SendDocument(); sendDocument.setDocument(fileToUpload); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } return sendDocument; }
sendDocument.validate(); try { String url = getBaseUrl() + SendDocument.PATH; builder.setLaxMode(); builder.setCharset(StandardCharsets.UTF_8); builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId(), TEXT_PLAIN_CONTENT_TYPE); addInputFile(builder, sendDocument.getDocument(), SendDocument.DOCUMENT_FIELD, true); if (sendDocument.getReplyMarkup() != null) { builder.addTextBody(SendDocument.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendDocument.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getReplyToMessageId() != null) { builder.addTextBody(SendDocument.REPLYTOMESSAGEID_FIELD, sendDocument.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getCaption() != null) { builder.addTextBody(SendDocument.CAPTION_FIELD, sendDocument.getCaption(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getParseMode() != null) { builder.addTextBody(SendDocument.PARSEMODE_FIELD, sendDocument.getParseMode(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getDisableNotification() != null) { builder.addTextBody(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getThumb() != null) { addInputFile(builder, sendDocument.getThumb(), SendDocument.THUMB_FIELD, false); builder.addTextBody(SendDocument.THUMB_FIELD, sendDocument.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE); return sendDocument.deserializeResponse(sendHttpPostRequest(httppost));
/** * Fetch the language file for Webogram * @param language Language requested */ public SendDocument getWebogramLanguageFile(String language) { SendDocument sendDocument = null; try { byte[] file = getFileWebogram(language); if (file != null && file.length / BYTES1024 >= 10) { try { String fileName = "languages_webogram_" + language + ".json"; File fileToUpload = new File(fileName); FileOutputStream output = new FileOutputStream(fileToUpload); IOUtils.write(file, output); output.close(); if (fileToUpload.exists()) { sendDocument = new SendDocument(); sendDocument.setDocument(fileToUpload); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } return sendDocument; }
private void onStartWithParameters(Message message, String language, String part) throws InvalidObjectException, TelegramApiException { if (DatabaseManager.getInstance().doesFileExists(part.trim())) { SendDocument sendDocumentRequest = new SendDocument(); sendDocumentRequest.setDocument(part.trim()); sendDocumentRequest.setChatId(message.getChatId()); execute(sendDocumentRequest); } else { SendMessage sendMessageRequest = new SendMessage(); sendMessageRequest.setText(LocalisationService.getString("wrongFileId", language)); sendMessageRequest.setChatId(message.getChatId()); execute(sendMessageRequest); } }
/** * Fetch the language file for OSX * @param language Language requested */ public SendDocument getOSXLanguageFile(String language) { SendDocument sendDocument = null; try { byte[] file = getFileOSX(language); if (file != null && file.length / BYTES1024 >= 10) { try { String fileName = "languages_osx_" + language + ".strings"; File fileToUpload = new File(fileName); FileOutputStream output = new FileOutputStream(fileToUpload); IOUtils.write(file, output); output.close(); sendDocument = new SendDocument(); sendDocument.setDocument(fileToUpload); } catch (IOException e) { BotLogger.error(LOGTAG, e); } } } catch (Exception e) { BotLogger.error(LOGTAG, e); } return sendDocument; }
/** * Fetch the language file for support members of android * @param language Language requested */ public SendDocument getAndroidSupportLanguageFile(String language) { SendDocument sendDocument = null; try { String file = getFileAndroid(language); if (file != null && file.getBytes().length / BYTES1024 >= 10) { file = file.replaceAll("\"LanguageName\"\\>(\\w*)\\<\\/string\\>", "\"LanguageName\"\\>$1_1\\<\\/string\\>").replaceAll("\"LanguageCode\"\\>(\\w*)\\<\\/string\\>", "\"LanguageCode\"\\>$1_1\\<\\/string\\>"); try { String fileName = "languages_Android_" + language + ".xml"; PrintWriter localFile = new PrintWriter(fileName); localFile.print(file); localFile.close(); File fileToUpload = new File(fileName); sendDocument = new SendDocument(); sendDocument.setDocument(fileToUpload); } catch (FileNotFoundException e) { BotLogger.error(LOGTAG, e); } } } catch (Exception e) { BotLogger.error(LOGTAG, e); } return sendDocument; }
/** * Fetch the language file for Android * @param language Language requested */ public SendDocument getAndroidLanguageFile(String language) { SendDocument sendDocument = null; try { String file = getFileAndroid(language); if (file != null && file.getBytes().length / BYTES1024 >= 10) { try { String fileName = "languages_Android_" + language + ".xml"; PrintWriter localFile = new PrintWriter(fileName); localFile.print(file); localFile.close(); File fileToUpload = new File(fileName); sendDocument = new SendDocument(); sendDocument.setDocument(fileToUpload); } catch (FileNotFoundException e) { BotLogger.error(LOGTAG, e); } } } catch (Exception e) { BotLogger.error(LOGTAG, e); } return sendDocument; }
/** * Fetch the language file for iOS * * @param language Language requested */ public SendDocument getiOSLanguageFile(String language) { SendDocument sendDocument = null; try { byte[] file = getFileiOS(language); if (file != null && file.length / BYTES1024 >= 10) { try { String fileName = "languages_ios_" + language + ".strings"; File fileToUpload = new File(fileName); FileOutputStream output = new FileOutputStream(fileToUpload); IOUtils.write(file, output); output.close(); sendDocument = new SendDocument(); sendDocument.setDocument(fileToUpload); } catch (IOException e) { BotLogger.error(LOGTAG, e); } } } catch (Exception e) { BotLogger.error(LOGTAG, e); } return sendDocument; }