diff --git a/aiogram/dispatcher/dispatcher.py b/aiogram/dispatcher/dispatcher.py index 813a9dee..22f6700c 100644 --- a/aiogram/dispatcher/dispatcher.py +++ b/aiogram/dispatcher/dispatcher.py @@ -1200,45 +1200,32 @@ class Dispatcher(DataMixin, ContextInstanceMixin): return decorator - def register_errors_handler(self, - callback, - *custom_filters, - exception=None, - run_task=None, - once: typing.Optional[bool] = None, - **kwargs): + def register_errors_handler(self, callback, *custom_filters, exception=None, run_task=None, **kwargs): """ Register handler for errors :param callback: :param exception: you can make handler for specific errors type :param run_task: run callback in task (no wait results) - :param once: run handler only once """ filters_set = self.filters_factory.resolve(self.errors_handlers, *custom_filters, exception=exception, **kwargs) - self.errors_handlers.register(self._wrap_async_task(callback, run_task), filters_set, once) + self.errors_handlers.register(self._wrap_async_task(callback, run_task), filters_set) - def errors_handler(self, - *custom_filters, - exception=None, - run_task=None, - once: typing.Optional[bool] = None, - **kwargs): + def errors_handler(self, *custom_filters, exception=None, run_task=None, **kwargs): """ Decorator for errors handler :param exception: you can make handler for specific errors type :param run_task: run callback in task (no wait results) - :param once: run handler only once :return: """ def decorator(callback): self.register_errors_handler(self._wrap_async_task(callback, run_task), - *custom_filters, exception=exception, once=once, **kwargs) + *custom_filters, exception=exception, **kwargs) return callback return decorator diff --git a/aiogram/dispatcher/handler.py b/aiogram/dispatcher/handler.py index 3034d927..e6b89380 100644 --- a/aiogram/dispatcher/handler.py +++ b/aiogram/dispatcher/handler.py @@ -43,7 +43,7 @@ class Handler: self.handlers: typing.List[Handler.HandlerObj] = [] self.middleware_key = middleware_key - def register(self, handler, filters=None, index=None, once: typing.Optional[bool] = None): + def register(self, handler, filters=None, index=None): """ Register callback @@ -52,7 +52,6 @@ class Handler: :param handler: coroutine :param filters: list of filters :param index: you can reorder handlers - :param once: if True, handler will be called only once """ from .filters import get_filters_spec @@ -68,9 +67,6 @@ class Handler: else: self.handlers.insert(index, record) - if once is not None: - self.once = once - def unregister(self, handler): """ Remove handler @@ -120,7 +116,7 @@ class Handler: response = await handler_obj.handler(*args, **partial_data) if response is not None: results.append(response) - if self.once is True: + if self.once: break except SkipHandler: continue