Reputation: 129
I have a menu of buttons, one of them is Research , when you click on it, it's supposed to ask "What do you want to know about?" then receive your answer and give you a summary about that from Wikipedia ...
and I want it to be accessible as a command too like give you a summary when you type /Research ...
now my code works perfect using /Research cause this command is the entry_point of my ConverstationHandler
But now I want it to be accessible by pressing the Research button too :
def Click_Button(update, context):
query = update.callback_query
if query.data == "MeMe":
MeMe(update,context)
if query.data == "Joke":
Joke(update,context)
if query.data == "Research":
#Here I need to call the following ConverstaionHandler somehow .....
query_handler = CallbackQueryHandler(Click_Button)
dispatcher.add_handler(query_handler)
Here is my conversation handler
About = 0
handle_converstation=ConversationHandler(
'''it calls the ask_wikipedia function using command /Research now I want it to
have another entry points too and it's going to be when we press the Research
button or in another word when query.data == "Research" '''
entry_points=[CommandHandler('Research', ask_wikipedia)],
states={
About: [MessageHandler(Filters.text, callback=about)]
},
fallbacks=[CommandHandler('quit', quit)])
dispatcher.add_handler(handle_converstation)
Can anyone tell me How can I start the conversation handler when I press the Research button when query.data == "Research" ....
Upvotes: 0
Views: 86
Reputation: 77
You can do this adding the CallbackQueryHandler
as an entry point with the attribute pattern="Research"
So at the end you should have something like this
entry_points=[CommandHandler('Research', ask_wikipedia),
CallbackQueryHandler(pattern='Research', callback=func_to_call)],
You can see this in the official docs
And also used (not in the entry_points
) on one of their examples
Upvotes: 1