Reputation: 6555
In my python telegram bot, I am able to display the first inlinekeyboard but How can I display the second Inlinekeyboard in the bot after clicking in the first Inlinekeyboard menu.
def start(bot, update):
sub = [
[InlineKeyboardButton("AAA", callback_data='0'),
InlineKeyboardButton("BBB", callback_data='1')]
]
reply_markup = InlineKeyboardMarkup(sub)
update.message.reply_text('Select Branch:', reply_markup=reply_markup)
def button(bot, update):
subK = [
InlineKeyboardButton("JJJ", callback_data='0'),
InlineKeyboardButton("HHH", callback_data='1')
]
reply_markup = InlineKeyboardMarkup(subK)
query = update.callback_query
bot.edit_message_text(chat_id=query.message.chat_id,
message_id=query.message.message_id,
reply_markup=ReplyKeyboardRemove())
bot.edit_message_text(chat_id=query.message.chat_id,
message_id=query.message.message_id,
reply_markup=reply_markup)
Thanks in advance.
Upvotes: 0
Views: 599
Reputation: 794
I assume you have added the button() function to the CallbackHandler()? Than you could use an if statement to check the callback_data (if the new keyboard depends on the button that is pressed)
Maybe it's just the second pair of brackets missing in subK?
def button(bot, update):
subK = [[
InlineKeyboardButton("JJJ", callback_data='0'),
InlineKeyboardButton("HHH", callback_data='1')
]]
The ReplyKeyboardRemove seems not be needed in this snipped, but maybe it's related to ReplyKeyboards created elsewhere? But ReplyKeyboard != InlineKeyboard.
Upvotes: 1