Java Code Examples for org.telegram.telegrambots.meta.api.objects.Message#isReply()

The following examples show how to use org.telegram.telegrambots.meta.api.objects.Message#isReply() . 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 5 votes vote down vote up
private static SendMessage onForecastNewWeather(Message message, String language) {
    if (message.isReply()) {
        return onForecastWeatherReceived(message.getChatId(), message.getFrom().getId(), message.getMessageId(), message.getText(), language);
    } else {
        return sendMessageDefault(message, 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 onForecastWeatherLocation(Message message, String language) {
    if (message.isReply() && message.hasLocation()) {
        return onForecastWeatherLocationReceived(message, language);
    } else {
        return sendMessageDefault(message, language);
    }
}
 
Example 3
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onCurrentNewWeather(Message message, String language) {
    if (message.isReply()) {
        return onCurrentWeatherReceived(message.getChatId(), message.getFrom().getId(), message.getMessageId(), message.getText(), language);
    } else {
        return sendMessageDefault(message, language);
    }
}
 
Example 4
Source File: WeatherHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 5 votes vote down vote up
private static SendMessage onCurrentWeatherLocation(Message message, String language) {
    if (message.isReply() && message.hasLocation()) {
        return onCurrentWeatherLocationReceived(message, language);
    } else {
        return sendMessageDefault(message, language);
    }
}
 
Example 5
Source File: DirectionsHandlers.java    From TelegramBotsExample with GNU General Public License v3.0 4 votes vote down vote up
private void handleDirections(Update update) throws InvalidObjectException {
    Message message = update.getMessage();
    if (message != null && message.hasText()) {
        if (languageMessages.contains(message.getFrom().getId())) {
            onLanguageSelected(message);
        } else {
            String language = DatabaseManager.getInstance().getUserLanguage(update.getMessage().getFrom().getId());
            if (message.getText().startsWith(Commands.setLanguageCommand)) {
                onSetLanguageCommand(message, language);
            } else if (message.getText().startsWith(Commands.startDirectionCommand)) {
                onStartdirectionsCommand(message, language);
            } else if ((message.getText().startsWith(Commands.help) ||
                    (message.getText().startsWith(Commands.startCommand) || !message.isGroupMessage())) &&
                    DatabaseManager.getInstance().getUserDestinationStatus(message.getFrom().getId()) == -1) {
                sendHelpMessage(message, language);
            } else if (!message.getText().startsWith("/")) {
                if (DatabaseManager.getInstance().getUserDestinationStatus(message.getFrom().getId()) == WATING_ORIGIN_STATUS &&
                        message.isReply() &&
                        DatabaseManager.getInstance().getUserDestinationMessageId(message.getFrom().getId()) == message.getReplyToMessage().getMessageId()) {
                    onOriginReceived(message, language);

                } else if (DatabaseManager.getInstance().getUserDestinationStatus(message.getFrom().getId()) == WATING_DESTINY_STATUS &&
                        message.isReply() &&
                        DatabaseManager.getInstance().getUserDestinationMessageId(message.getFrom().getId()) == message.getReplyToMessage().getMessageId()) {
                    onDestinationReceived(message, language);
                } else if (!message.isReply()) {
                    if (DatabaseManager.getInstance().getUserDestinationStatus(message.getFrom().getId()) == -1) {
                        sendHelpMessage(message, language);
                    } else {
                        SendMessage sendMessageRequest = new SendMessage();
                        sendMessageRequest.setText(LocalisationService.getString("youNeedReplyDirections", language));
                        sendMessageRequest.setChatId(message.getChatId());
                        try {
                            execute(sendMessageRequest);
                        } catch (TelegramApiException e) {
                            BotLogger.error(LOGTAG, e);
                        }
                    }
                }
            }
        }
    }
}