From a653ed679224ef4da9bedd06265767f8f21c971d Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 28 Jul 2025 15:13:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=20=D0=BD=D0=B0=20State.=20?= =?UTF-8?q?=D0=92=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20=3D=3D=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=8C=20in.=20=D0=A0=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=B2=20=D1=85?= =?UTF-8?q?=D0=B5=D0=BD=D0=B4=D0=BB=D0=B5=D1=80=D0=B5=20=D1=83=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D0=B0=D0=BD=D0=BE=20=D0=BD=D0=B5=D1=81=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=BA=D0=BE=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=B0=20State?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maxapi/dispatcher.py | 7 ++++--- maxapi/filters/handler.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/maxapi/dispatcher.py b/maxapi/dispatcher.py index ce5403c..d46d990 100644 --- a/maxapi/dispatcher.py +++ b/maxapi/dispatcher.py @@ -240,9 +240,10 @@ class Dispatcher: if handler.filters: if not filter_attrs(event_object, *handler.filters): continue - - if not handler.state == current_state and handler.state: - continue + + if handler.states: + if current_state not in handler.states: + continue func_args = handler.func_event.__annotations__.keys() diff --git a/maxapi/filters/handler.py b/maxapi/filters/handler.py index 486a07a..f68e057 100644 --- a/maxapi/filters/handler.py +++ b/maxapi/filters/handler.py @@ -44,14 +44,14 @@ class Handler: self.func_event: Callable = func_event self.update_type: UpdateType = update_type self.filters = [] - self.state: Optional[State] = None + self.states: Optional[List[State]] = [] self.middlewares: List[BaseMiddleware] = [] for arg in args: if isinstance(arg, MagicFilter): self.filters.append(arg) elif isinstance(arg, State): - self.state = arg + self.states.append(arg) elif isinstance(arg, (Command, CommandStart)): self.filters.insert(0, F.message.body.text.split()[0] == arg.command) elif isinstance(arg, BaseMiddleware):