I have a dilemma with my telegram bot. I was trying to prompt a response from my nested menu selection upon clicking it. However, it prompts an error saying: "Message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message"
Is there something I missed out when triggering the respond? Still new to this, so pardon the novice question
def start(update, context):
update.message.reply_text(main_menu_message(),
reply_markup=main_menu_keyboard())
def main_menu(update,context):
query = update.callback_query
context.bot.edit_message_text(chat_id=query.message.chat_id,
message_id=query.message.message_id,
text=main_menu_message(),
reply_markup=main_menu_keyboard())
def first_menu(update, context):
query = update.callback_query
# print(context.match)
context.bot.edit_message_text(chat_id=query.message.chat_id,
message_id=query.message.message_id,
text=first_menu_message(),
reply_markup=first_menu_keyboard())
# and so on for every callback_data option
def first_submenu(update):
update.message.reply_text("Use /start to test this bot.")
################ Keyboard #######################
def main_menu_keyboard():
keyboard = [[InlineKeyboardButton("Exercise", callback_data='m1'),
InlineKeyboardButton("Option 2", callback_data='m2')],
[InlineKeyboardButton("Option 3", callback_data='m3')]]
return InlineKeyboardMarkup(keyboard)
def first_menu_keyboard():
keyboard = [[InlineKeyboardButton('Running', callback_data='m1_1')],
[InlineKeyboardButton('Push Ups', callback_data='m1_2')],
[InlineKeyboardButton('Back', callback_data='main')]]
return InlineKeyboardMarkup(keyboard)
####### Messages ############
def main_menu_message():
return 'Choose the option:'
def first_menu_message():
return 'Select exercise:'
def main():
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(first_submenu, pattern='m1_1'))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
updater = Updater(TOKEN, use_context=True)
main()
My current stacktrace states:
Traceback (most recent call last):
File "Python\Python37-32\lib\site-packages\telegram\ext\dispatcher.py", line 390, in process_update
handler.handle_update(update, self, check, context)
File "Python\Python37-32\lib\site-packages\telegram\ext\handler.py", line 117, in handle_update
return self.callback(update, context)
File "PycharmProjects/project/app.py", line 32, in first_menu
reply_markup=first_menu_keyboard())
File "<decorator-gen-27>", line 2, in edit_message_text
File "Python\Python37-32\lib\site-packages\telegram\bot.py", line 67, in decorator
result = func(*args, **kwargs)
File "Python\Python37-32\lib\site-packages\telegram\bot.py", line 1834, in edit_message_text
return self._message(url, data, timeout=timeout, reply_markup=reply_markup, **kwargs)
File "Python\Python37-32\lib\site-packages\telegram\bot.py", line 172, in _message
result = self._request.post(url, data, timeout=timeout)
File "Python\Python37-32\lib\site-packages\telegram\utils\request.py", line 334, in post
**urlopen_kwargs)
File "Python\Python37-32\lib\site-packages\telegram\utils\request.py", line 245, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message'