-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Labels
📋 duplicatework status: duplicatework status: duplicate
Description
Hi! I see that dispatcher can take handlers to different groups:
for group in self.groups:
for handler in self.handlers[group]:
try:
if handler.check_update(update):
handler.handle_update(update, self)
break
# Dispatch any errors
except TelegramError as te:Such realization doesn't allow us to cleanly stop handling from a group with a lower number. How do you think about some logic, which will make it? Ex, action handler can raise some exception, like StopPropagationExeption:
def custom_handler(bot: Bot, update: Update):
# handling stuff...
raise StopPropagationException # or maybe wrap it to bot.updater.stop_propagation()
dispatcher.add(custom_handler)for group in self.groups:
for handler in self.handlers[group]:
try:
if handler.check_update(update):
handler.handle_update(update, self)
break
# Dispatch any errors
except TelegramError as te:
except StopPropagationExeption:
passI've just noticed, that group mechanism allows us to create something like middleware, to handle such things as authorization or smth else. I suppose this logic would be useful.
Metadata
Metadata
Assignees
Labels
📋 duplicatework status: duplicatework status: duplicate