pengrad/java-telegram-bot-api

callbackQuery's message() is deprecated

Donaboyev opened this issue · 1 comments

I want to get Update -> callbackQuery -> message -> replyMarkup
But message() function is deprecated that says use maybeInaccessibleMessage instead.
Unfortunately, maybeInaccessibleMessage has not replyMarkup.

The goal is updating message's InlineKeyboardButtons. Or how can I achieve this in another way?

MaybeInaccessibleMessage is a new class added by telegram because sometimes BOTs may receive callbacks from messages that they can't read.

You can check if the maybeInaccessibleMessage is of type Message, and then cast it. Something like this:

if (update.callbackQuery().maybeInaccessibleMessage() instanceof Message) {
   Message message = (Message)update.callbackQuery().maybeInaccessibleMessage();
}