I
I
IBNSINA2020-06-07 10:10:59
Java
IBNSINA, 2020-06-07 10:10:59

How can I receive a message from a user Telegram bot java?

For example, the bot sent "enter your address", the user replied with his address, I have to accept it in a string format. Also, the bot said "enter your name", I entered it and so that the bot would also accept it and fill it in a string format.

Code where Onupdate:

else if (update.getCallbackQuery().getData().equals("dostavka")){
sendDostavka(update.getCallbackQuery());
}

It sends to the SendDostavka function:
public void sendDostavka(CallbackQuery callbackQuery) {
Update update = new Update();

String getType = "Доставка";
try {
execute(new SendMessage().setText(
"Теперь введите куда вести заказ")
.setChatId(callbackQuery.getMessage().getChatId()));

This is where he should take his address
Message message = update.getMessage();
message.getMessageId();
SendMsg(message,"6667");
if (message != null && message.hasText()) {

It must equate the address to this string address, but it does not even accept anything in the message
String adress = update.getMessage().getText();

}
}
} catch(TelegramApiException e){
e.printStackTrace();
}

}

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