Reputation: 470
Add a fourth category "About"
Clicking on "About" will send a text message e.g. "Operating since 1999"
Here is the code snippet:
def main_menu_keyboard():
keyboard = [[InlineKeyboardButton('Bubble Tea', callback_data='m1')],
[InlineKeyboardButton('Waffle', callback_data='m2')],
[InlineKeyboardButton('Otah', callback_data='m3')]]
return InlineKeyboardMarkup(keyboard)
# Add command handler to dispatcher
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CallbackQueryHandler(main_menu, pattern='main'))
updater.dispatcher.add_handler(CallbackQueryHandler(first_menu, pattern='m1'))
updater.dispatcher.add_handler(CallbackQueryHandler(second_menu, pattern='m2'))
updater.dispatcher.add_handler(CallbackQueryHandler(third_menu,pattern='m3'))
I have been trying with different ways of displaying text as shown below but not too sure how to piece them together with the dispatcher
bot.send_message(chat_id=chat_id, text="About xxxxx details ")
update.message.reply_text("About xxxx details ")
Upvotes: 0
Views: 2750
Reputation: 4473
Add a fourth category "About"
def main_menu_keyboard():
keyboard = [[InlineKeyboardButton('Bubble Tea', callback_data='m1')],
[InlineKeyboardButton('Waffle', callback_data='m2')],
[InlineKeyboardButton('Otah', callback_data='m3')],
[InlineKeyboardButton('About', callback_data='m4')]] # new button
return InlineKeyboardMarkup(keyboard)
Clicking on "About" will send a text message e.g. "Operating since 1999"
def about_message(bot, update): # handler for "About" button
bot.send_message(chat_id=update.callback_query.from_user.id, text="Operating since 1999")
# ... other existing code
# Add command handler to dispatcher
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CallbackQueryHandler(main_menu, pattern='main'))
updater.dispatcher.add_handler(CallbackQueryHandler(first_menu, pattern='m1'))
updater.dispatcher.add_handler(CallbackQueryHandler(second_menu, pattern='m2'))
updater.dispatcher.add_handler(CallbackQueryHandler(third_menu, pattern='m3'))
updater.dispatcher.add_handler(CallbackQueryHandler(about_message, pattern='m4')) # add handler for "About" button
# ... other existing code
Upvotes: 1