N
N
Nodir Malikov2021-03-08 17:50:13
Java
Nodir Malikov, 2021-03-08 17:50:13

Telegram Bot in Java. Why doesn't a message come up when I click on the Inline button?

Addiction


org.telegram
telegrambots
4.9.1



The code

public void onUpdateReceived(Update update) {
        SendMessage sendMessage = new SendMessage();

        if (update.hasCallbackQuery()) {
            sendMessage.setChatId(update.getCallbackQuery().getMessage().getChatId());
            String callbackText = update.getCallbackQuery().getData();
            if (callbackText.equals("toUSD")) {
                sendMessage.setText("Напишите сумму:");
                System.out.println(sendMessage.getChatId());  //Проверка Chat ID
            } else if (callbackText.equals("toEUR")) {
                sendMessage.setText("Напишите сумму:");
            }
        }
}



Checked with debug, but everything is fine. Chat ID is correct. But the message is not coming to the chat.

Why is this happening?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2021-03-08
@Fayo

Because you create an object sendMessage, put text into it sendMessage.setText("Напишите сумму:");, and then nothing happens.
You need a method .execute(sendMessage)fromDefaultAbsSender

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question