From 41f16a17c9e59d159985bfad0e14c0fc3999be17 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:56:07 +0200 Subject: [PATCH] Fix filters.command not working with multiple running bots Closes #864 --- pyrogram/client.py | 3 +++ pyrogram/filters.py | 12 +----------- pyrogram/methods/auth/initialize.py | 1 + 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pyrogram/client.py b/pyrogram/client.py index 920b7233..ac753f88 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -286,6 +286,9 @@ class Client(Methods): self.disconnect_handler = None + # Username used for mentioned bot commands, e.g.: /start@usernamebot + self.username = None + self.loop = asyncio.get_event_loop() def __enter__(self): diff --git a/pyrogram/filters.py b/pyrogram/filters.py index 2eeef95c..348e6e7a 100644 --- a/pyrogram/filters.py +++ b/pyrogram/filters.py @@ -745,11 +745,6 @@ linked_channel = create(linked_channel_filter) # region command_filter - -# Used by the command filter below -username = None - - def command(commands: Union[str, List[str]], prefixes: Union[str, List[str]] = "/", case_sensitive: bool = False): """Filter commands, i.e.: text messages starting with "/" or any other custom prefix. @@ -772,12 +767,7 @@ def command(commands: Union[str, List[str]], prefixes: Union[str, List[str]] = " command_re = re.compile(r"([\"'])(.*?)(?