Java Code Examples for org.telegram.telegrambots.meta.api.methods.send.SendMessage#setReplyToMessageId()

The following examples show how to use org.telegram.telegrambots.meta.api.methods.send.SendMessage#setReplyToMessageId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 6 votes vote down vote up
private static SendMessage onCurrentWeatherCityReceived(Long chatId, Integer userId, Integer messageId, String text, String language) {
    Integer cityId = DatabaseManager.getInstance().getRecentWeatherIdByCity(userId, text);
    if (cityId != null) {
        String unitsSystem = DatabaseManager.getInstance().getUserWeatherOptions(userId)[1];
        String weather = WeatherService.getInstance().fetchWeatherCurrent(cityId.toString(), userId, language, unitsSystem);
        SendMessage sendMessageRequest = new SendMessage();
        sendMessageRequest.enableMarkdown(true);
        sendMessageRequest.setReplyMarkup(getMainMenuKeyboard(language));
        sendMessageRequest.setReplyToMessageId(messageId);
        sendMessageRequest.setText(weather);
        sendMessageRequest.setChatId(chatId.toString());
        DatabaseManager.getInstance().insertWeatherState(userId, chatId, MAINMENU);
        return sendMessageRequest;
    } else {
        return sendChooseOptionMessage(chatId, messageId, getRecentsKeyboard(userId, language), language);
    }
}
 
Example 2
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage sendRateMessage(Long chatId, Integer messageId, ReplyKeyboardMarkup replyKeyboardMarkup, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);
    sendMessage.setChatId(chatId);
    sendMessage.setReplyToMessageId(messageId);
    if (replyKeyboardMarkup != null) {
        sendMessage.setReplyMarkup(replyKeyboardMarkup);
    }
    sendMessage.setText(LocalisationService.getString("rateMeMessage", language));

    return sendMessage;
}
 
Example 3
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onForecastWeatherReceived(Long chatId, Integer userId, Integer messageId, String text, String language) {
    String unitsSystem = DatabaseManager.getInstance().getUserWeatherOptions(userId)[1];
    String weather = WeatherService.getInstance().fetchWeatherForecast(text, userId, language, unitsSystem);
    SendMessage sendMessageRequest = new SendMessage();
    sendMessageRequest.enableMarkdown(true);
    sendMessageRequest.setReplyMarkup(getMainMenuKeyboard(language));
    sendMessageRequest.setReplyToMessageId(messageId);
    sendMessageRequest.setText(weather);
    sendMessageRequest.setChatId(chatId.toString());

    DatabaseManager.getInstance().insertWeatherState(userId, chatId, MAINMENU);
    return sendMessageRequest;
}
 
Example 4
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onBackUnitsCommand(Message message, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);

    ReplyKeyboardMarkup replyKeyboardMarkup = getSettingsKeyboard(language);
    sendMessage.setReplyMarkup(replyKeyboardMarkup);
    sendMessage.setReplyToMessageId(message.getMessageId());
    sendMessage.setChatId(message.getChatId());
    sendMessage.setText(getSettingsMessage(language));

    DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), SETTINGS);
    return sendMessage;
}
 
Example 5
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onNewForecastWeatherCommand(Long chatId, Integer userId, Integer messageId, String language) {
    ForceReplyKeyboard forceReplyKeyboard = getForceReply();

    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);
    sendMessage.setChatId(chatId.toString());
    sendMessage.setReplyToMessageId(messageId);
    sendMessage.setReplyMarkup(forceReplyKeyboard);
    sendMessage.setText(LocalisationService.getString("onWeatherNewCommand", language));

    DatabaseManager.getInstance().insertWeatherState(userId, chatId, FORECASTNEWWEATHER);
    return sendMessage;
}
 
Example 6
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onUnitsCommand(Message message, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);

    sendMessage.setReplyToMessageId(message.getMessageId());
    sendMessage.setChatId(message.getChatId());
    sendMessage.setReplyMarkup(getUnitsKeyboard(language));
    sendMessage.setText(getUnitsMessage(message.getFrom().getId(), language));

    DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), UNITS);
    return sendMessage;
}
 
Example 7
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage sendChooseOptionMessage(Long chatId, Integer messageId,
                                            ReplyKeyboard replyKeyboard, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);
    sendMessage.setChatId(chatId.toString());
    sendMessage.setReplyToMessageId(messageId);
    sendMessage.setReplyMarkup(replyKeyboard);
    sendMessage.setText(LocalisationService.getString("chooseOption", language));

    return sendMessage;
}
 
Example 8
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onNewAlertCommand(Message message, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);

    sendMessage.setChatId(message.getChatId());
    sendMessage.setReplyMarkup(getRecentsKeyboard(message.getFrom().getId(), language, false));
    sendMessage.setText(LocalisationService.getString("chooseNewAlertCity", language));
    sendMessage.setReplyToMessageId(message.getMessageId());

    DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), ALERTNEW);
    return sendMessage;
}
 
Example 9
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onListAlertCommand(Message message, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);

    sendMessage.setChatId(message.getChatId());
    sendMessage.setReplyToMessageId(message.getMessageId());
    sendMessage.setReplyMarkup(getAlertsKeyboard(language));
    sendMessage.setText(getAlertListMessage(message.getFrom().getId(), language));
    sendMessage.setReplyToMessageId(message.getMessageId());

    return sendMessage;
}
 
Example 10
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onSettingsChoosen(Message message, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);

    ReplyKeyboardMarkup replyKeyboardMarkup = getSettingsKeyboard(language);
    sendMessage.setReplyMarkup(replyKeyboardMarkup);
    sendMessage.setReplyToMessageId(message.getMessageId());
    sendMessage.setChatId(message.getChatId());
    sendMessage.setText(getSettingsMessage(language));

    DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), SETTINGS);
    return sendMessage;
}
 
Example 11
Source File: ChannelHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private void sendErrorMessage(Message message, String errorText) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);
    sendMessage.setChatId(message.getChatId());
    sendMessage.setReplyToMessageId(message.getMessageId());

    sendMessage.setText(String.format(ERROR_MESSAGE_TEXT, message.getText().trim(), errorText.replace("\"", "\\\"")));
    sendMessage.enableMarkdown(true);

    try {
        execute(sendMessage);
    } catch (TelegramApiException e) {
        BotLogger.error(LOGTAG, e);
    }
}
 
Example 12
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage sendHelpMessage(Long chatId, Integer messageId, ReplyKeyboardMarkup replyKeyboardMarkup, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);
    sendMessage.setChatId(chatId);
    sendMessage.setReplyToMessageId(messageId);
    if (replyKeyboardMarkup != null) {
        sendMessage.setReplyMarkup(replyKeyboardMarkup);
    }
    sendMessage.setText(getHelpMessage(language));
    return sendMessage;
}
 
Example 13
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onLanguageChosen(Integer userId, Long chatId, Integer messageId, String language) {
    String languageCode = LocalisationService.getLanguageCodeByName(language);
    DatabaseManager.getInstance().putUserWeatherLanguageOption(userId, languageCode);

    SendMessage sendMessageRequest = new SendMessage();
    sendMessageRequest.enableMarkdown(true);
    sendMessageRequest.setChatId(chatId.toString());
    sendMessageRequest.setText(LocalisationService.getString("languageUpdated", languageCode));
    sendMessageRequest.setReplyToMessageId(messageId);
    sendMessageRequest.setReplyMarkup(getMainMenuKeyboard(languageCode));

    DatabaseManager.getInstance().insertWeatherState(userId, chatId, MAINMENU);
    return sendMessageRequest;
}
 
Example 14
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onAlertDeleteCityOptionSelected(Message message, String language) {
    DatabaseManager.getInstance().deleteAlertCity(message.getFrom().getId(), message.getText());
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);
    sendMessage.setReplyToMessageId(message.getMessageId());
    sendMessage.setChatId(message.getChatId());
    sendMessage.setReplyMarkup(getAlertsKeyboard(language));
    sendMessage.setText(LocalisationService.getString("alertDeleted", language));

    DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), ALERT);
    return sendMessage;
}
 
Example 15
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private void sendHideKeyboard(Integer userId, Long chatId, Integer messageId) throws TelegramApiException {
    SendMessage sendMessage = new SendMessage();
    sendMessage.setChatId(chatId.toString());
    sendMessage.enableMarkdown(true);
    sendMessage.setReplyToMessageId(messageId);
    sendMessage.setText(Emoji.WAVING_HAND_SIGN.toString());

    ReplyKeyboardRemove replyKeyboardRemove = new ReplyKeyboardRemove();
    replyKeyboardRemove.setSelective(true);
    sendMessage.setReplyMarkup(replyKeyboardRemove);

    execute(sendMessage);
    DatabaseManager.getInstance().insertWeatherState(userId, chatId, STARTSTATE);
}
 
Example 16
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onCancelCommand(Long chatId, Integer userId, Integer messageId, ReplyKeyboard replyKeyboard, String language) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.setChatId(chatId.toString());
    sendMessage.enableMarkdown(true);
    sendMessage.setReplyToMessageId(messageId);
    sendMessage.setReplyMarkup(replyKeyboard);
    sendMessage.setText(LocalisationService.getString("backToMainMenu", language));

    DatabaseManager.getInstance().insertWeatherState(userId, chatId, MAINMENU);
    return sendMessage;
}
 
Example 17
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onCurrentWeatherReceived(Long chatId, Integer userId, Integer messageId, String text, String language) {
    String unitsSystem = DatabaseManager.getInstance().getUserWeatherOptions(userId)[1];
    String weather = WeatherService.getInstance().fetchWeatherCurrent(text, userId, language, unitsSystem);
    SendMessage sendMessageRequest = new SendMessage();
    sendMessageRequest.enableMarkdown(true);
    sendMessageRequest.setReplyMarkup(getMainMenuKeyboard(language));
    sendMessageRequest.setReplyToMessageId(messageId);
    sendMessageRequest.setText(weather);
    sendMessageRequest.setChatId(chatId.toString());

    DatabaseManager.getInstance().insertWeatherState(userId, chatId, MAINMENU);
    return sendMessageRequest;
}
 
Example 18
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onLanguageError(Long chatId, Integer messageId, String language) {
    SendMessage sendMessageRequest = new SendMessage();
    sendMessageRequest.enableMarkdown(true);
    sendMessageRequest.setChatId(chatId.toString());
    sendMessageRequest.setReplyMarkup(getLanguagesKeyboard(language));
    sendMessageRequest.setText(LocalisationService.getString("errorLanguageNotFound", language));
    sendMessageRequest.setReplyToMessageId(messageId);

    return sendMessageRequest;
}
 
Example 19
Source File: ChannelHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage getMessageToChannelSent(Message message) {
    SendMessage sendMessage = new SendMessage();
    sendMessage.enableMarkdown(true);
    sendMessage.setChatId(message.getChatId());
    sendMessage.setReplyToMessageId(message.getMessageId());

    sendMessage.setText(AFTER_CHANNEL_TEXT);
    return sendMessage;
}
 
Example 20
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onCurrentWeatherLocationReceived(Message message, String language) {
    String unitsSystem = DatabaseManager.getInstance().getUserWeatherOptions(message.getFrom().getId())[1];
    String weather = WeatherService.getInstance().fetchWeatherCurrentByLocation(message.getLocation().getLongitude(),
            message.getLocation().getLatitude(), message.getFrom().getId(), language, unitsSystem);
    SendMessage sendMessageRequest = new SendMessage();
    sendMessageRequest.enableMarkdown(true);
    sendMessageRequest.setReplyMarkup(getMainMenuKeyboard(language));
    sendMessageRequest.setReplyToMessageId(message.getMessageId());
    sendMessageRequest.setText(weather);
    sendMessageRequest.setChatId(message.getChatId());

    DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), MAINMENU);
    return sendMessageRequest;
}