You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! Is there an elegant way of ensuring only one conversation is active at a time without having to put them into separate groups?
Specifically, if two ConversationHandlers conv1 and conv2 are attached to the dispatcher,
Calling conv2 when conv1 is active will end conv1 and then start conv2.
Calling conv1 when conv2 is active will end conv2 and then start conv1.
Note the order, the active conversation should be ended before the next conversation starts.
A minimal working code of two conversations (but does not meet the requirement yet) can be found here. I have searched for potential solutions and have found the following:
I am unsure whether the hacky method of context.update_queue.append is still recommended for PTB v13. As for putting the command handlers in different groups, the reason why I would like to avoid is because of the two limitations:
1. Group priorities are blanket-applied for all handlers within each ConversationHandler
This means the ordering I want would not be possible.
2. Global fallbacks become complicated to implement
Placing conversations in different groups means that there can no longer be a global fallback that can catch any update that is not handled by any handler, from any groups. (In my example. this can happen when all the conversations are inactive.) Instead, we need to attach a separate handler for each group used.
Is there other ways to achieve this? I was also wondering if a custom handler created by inheriting Handler could be a way. Do let me know if I overlooked something.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello! Is there an elegant way of ensuring only one conversation is active at a time without having to put them into separate groups?
Specifically, if two ConversationHandlers
conv1
andconv2
are attached to the dispatcher,conv2
whenconv1
is active will endconv1
and then startconv2
.conv1
whenconv2
is active will endconv2
and then startconv1
.Note the order, the active conversation should be ended before the next conversation starts.
A minimal working code of two conversations (but does not meet the requirement yet) can be found here. I have searched for potential solutions and have found the following:
context.update_queue.append
I am unsure whether the hacky method of
context.update_queue.append
is still recommended for PTB v13. As for putting the command handlers in different groups, the reason why I would like to avoid is because of the two limitations:1. Group priorities are blanket-applied for all handlers within each ConversationHandler
This means the ordering I want would not be possible.
2. Global fallbacks become complicated to implement
Placing conversations in different groups means that there can no longer be a global fallback that can catch any update that is not handled by any handler, from any groups. (In my example. this can happen when all the conversations are inactive.) Instead, we need to attach a separate handler for each group used.
Is there other ways to achieve this? I was also wondering if a custom handler created by inheriting Handler could be a way. Do let me know if I overlooked something.
Beta Was this translation helpful? Give feedback.
All reactions