G
G
Gleb Kalinin2017-02-26 14:01:09
ruby
Gleb Kalinin, 2017-02-26 14:01:09

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

As a result, the bot sends a new one, and I need it to replace the old one. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nllm, 2017-02-26
@nllm

Do not send_message, but edit_message

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question