- Notifications
You must be signed in to change notification settings - Fork5.7k
Description
Is your feature request related to a problem? Please describe.
While usingConversationHandler
there is no possibility to check which state a callback was triggered from.
In my case I have a bot for a group game and I have commands like/add_me
,/remove_me
which every user may trigger at any time during the game. I would like to update my internal state differently depending on which state the conversation is currently in.
Describe the solution you'd like
As a solution I'd like to see an additional field inCallbackContext
, e.g.{"conversation_data": {"current_state": <MY_STATE>}}
. This can be easily done by implementingcollect_additional_context
method inConversationHandler
class.
Describe alternatives you've considered
There are two ways to achieve what I need using current code:
assuming I only has one
ConversationHandler
and it was added to dispatcher first, I can runcontext.dispatcher.handlers[0][0].conversations[(update.effective_chat.id,)]
however this method is error-prone if i have many conversation handlers or I have nested ones.
I can manually update context with
conversation_data
field, however this would require editing all of my callbacks and therefore also error-prone.
Additional context
N/A
I will be happy to make a PR if you find this useful.