printStream.print(db.backup()); sender.sendDocument(new SendDocument() .setDocument(backup) .setChatId(ctx.chatId()) );
/** * 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; } }
/** * 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; }
/** * 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; }
/** * 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 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 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; }
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); } }