mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 12:57:52 +00:00
parent
78efb04b40
commit
41f16a17c9
@ -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):
|
||||
|
@ -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"([\"'])(.*?)(?<!\\)\1|(\S+)")
|
||||
|
||||
async def func(flt, client: pyrogram.Client, message: Message):
|
||||
# Username shared among all commands; used for mention commands, e.g.: /start@username
|
||||
global username
|
||||
|
||||
if username is None:
|
||||
username = (await client.get_me()).username or ""
|
||||
|
||||
username = client.username or ""
|
||||
text = message.text or message.caption
|
||||
message.command = None
|
||||
|
||||
|
@ -48,4 +48,5 @@ class Initialize:
|
||||
await self.dispatcher.start()
|
||||
await Syncer.add(self)
|
||||
|
||||
self.username = (await self.get_me()).username
|
||||
self.is_initialized = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user