Answer the question
In order to leave comments, you need to log in
How to change the inline keyboard and not send a new one?
There is a code:
bot.listen do |message|
case message
when Telegram::Bot::Types::CallbackQuery
one = [
Telegram::Bot::Types::InlineKeyboardButton.new(text: '2', callback_data: 'two'),
Telegram::Bot::Types: :InlineKeyboardButton.new(text: '3', callback_data: 'three')
]
onem = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: one)
# Here you can handle your callbacks from inline buttons
if message. data == 'one'
bot.api.editMessageText(chat_id: message.from.id, text: 'one', reply_markup: onem)
end
when Telegram::Bot::Types::Message
kb = [
Telegram::Bot::Types::InlineKeyboardButton.new(text: '1', callback_data: 'one'),
Telegram::Bot::Types::InlineKeyboardButton.new(text: '2', callback_data: 'two' ),
Telegram::Bot::Types::InlineKeyboardButton.new(text: '3', callback_data: 'three')
]
startm = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: kb)
if message. text == "/start"
bot.api.send_message(chat_id: message.chat.id, text: 'Select a number', reply_markup: startm)
end
end
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question