-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Added impementation of "prefallbacks" list. #2764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Imagine you have such CH: ``` ch = tg_ext.ConversationHandler( entry_points=[ tg_ext.CommandHandler("start", callback=lambda *args, **kwargs: 0)], states={ 0: [ tg_ext.MessageHandler(filters=tg_ext.Filters.text & ~Filters.regex("cancel"), callback=lambda *args, **kwargs: 1)], 1: [ tg_ext.MessageHandler(filters=tg_ext.Filters.text & ~Filters.regex("cancel"), callback=lambda *args, **kwargs: 2)], 2: [ tg_ext.MessageHandler(filters=tg_ext.Filters.text & ~Filters.regex("cancel"), callback=lambda *args, **kwargs: -1)], }, fallbacks=[ tg_ext.CommandHandler("cancel", callback=lambda *args, **kwargs: -1), ]) ``` Here you should apply `& ~Filter` for every handler in `states` to prevent catching a `cancel` command. But it can be easily avoided by adding list of handlers that should to trigger before any another update.
Forget default value (`[]`) for `prefallbacks`
Hi. Thanks for this interesting proposal! We'll definitely have a closer look at it - however, that might take a while (The recent API update has priority and we're slowly working on the large v14 project). In the meantime, you can make your life a bit easier by defining a filter shortcut e.g. as |
Yeah, I thought about |
yes, I've noticed ;) The crucial part would be to integrate them into |
5c26c91
to
74c4270
Compare
Imagine you have such CH:
Here you should apply
& ~Filter
for every handler instates
to prevent catching acancel
command.But it can be easily avoided by adding list of handlers that should to trigger before any another update.
Please look at this implementation of "prefallbacks". This is directly from my personal code, I have used it for a while and no encountered with errors.