I have this menu here:
keyboard = [
[InlineKeyboardButton("Modifica Materie", callback_data='edit_subjects'),
InlineKeyboardButton("Modifica Voti", callback_data='edit_grades'),
InlineKeyboardButton("Resoconto", callback_data='resume')],
[InlineKeyboardButton("Suggerisci Modifiche!", callback_data='suggest')],
[InlineKeyboardButton("Supporta il progetto!", callback_data='donate')],
]
menu_query_keyboard = InlineKeyboardMarkup(keyboard)
And the first two buttons are linked to MENU_QUERY_HANDLER:
EDIT_SUBJECTS_HANDLER = ConversationHandler(
entry_points=[CallbackQueryHandler(edit_subjects.display_subjects, "edit_subjects")],
states={
"select_subjects": [CallbackQueryHandler(edit_subjects.select_subjects)],
"add_subjects": [MessageHandler(filters.TEXT, edit_user_subjects)],
"back_to_menu": [CallbackQueryHandler(back_to_menu, "menu")]
},
fallbacks=[],
map_to_parent={
END: "selector",
}
)
EDIT_GRADES_HANDLER = ConversationHandler(
entry_points=[CallbackQueryHandler(not_avaliable.not_avaliable, "edit_grades")],
states={
"back_to_menu": [CallbackQueryHandler(back_to_menu, "menu")]
},
fallbacks=[],
map_to_parent={
END: "selector",
}
)
MENU_QUERY_HANDLER = ConversationHandler(
entry_points=[CommandHandler("menu", menu)],
states={
"selector": [CallbackQueryHandler(selector)],
"edit_subjects": [EDIT_SUBJECTS_HANDLER],
"edit_grades": [EDIT_GRADES_HANDLER],
},
fallbacks=[
],
)
The thing is, when I try to select any of the options, I have to click it twice to have a response.
To manage the various selections I use the selector function, which is this:
async def selector(update: Update, context: ContextTypes) -> str:
query = update.callback_query
await query.answer()
return query.data
Could it maybe be caused by this? Is there a better way to make a menu with InlineQueryKeyboard?