A
A
AmirDigiev2019-05-01 19:46:21
Java
AmirDigiev, 2019-05-01 19:46:21

How can a telegram bot (Java TelegramBots) accept a response to its message?

When you enter the /start command, the bot sends a message and waits until I send him another one.

public class Bot extends TelegramLongPollingBot {
    private long chatId;
    Parser parser = new Parser();

    public void onUpdateReceived(Update update) {
        update.getUpdateId();

        chatId = update.getMessage().getChatId();
        String text = update.getMessage().getText();

        if(text.equals("/start") || text.equals("/Start")) {
            SendMessage sendMessage = new SendMessage().setChatId(chatId);

            try {
                sendMessage.setText("Введите URL");
                execute(sendMessage);
            }
            catch(TelegramApiException e){
                e.printStackTrace();
            }
        }
    }



    public String getBotUsername(){
        return "@ParseSteamBot";
    }

    @Override
    public String getBotToken() {
        return "872707712:AAG1DC5si0qXLVBDyrD49HRGn-Co6bZ4xa0";
    }
}

I don't understand how to process the second message sent by the user. If you turn to String text = update.getMessage().getText, then the bot perceives this as a start command, which causes errors...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question