Compare commits

..

1 commit

Author SHA1 Message Date
NekoChan
07a96f932b
Merge 38cde8d556 into 2a84c33607 2025-05-24 18:02:16 +00:00
3 changed files with 4 additions and 59 deletions

View file

@ -484,7 +484,6 @@ def pyrogram_api():
BusinessWeeklyOpen
BusinessWorkingHours
User
Username
Chat
ChatPreview
ChatPhoto

View file

@ -18,7 +18,7 @@
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
__fork_name__ = "PyroFork"
__version__ = "2.3.64"
__version__ = "2.3.63"
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
__copyright__ = "Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>"

View file

@ -890,12 +890,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):
usernames = []
username = client.me.username or ""
if client.me.usernames:
usernames.append(username)
for user in client.me.usernames:
usernames.append(user.username)
text = message.text or message.caption
message.command = None
@ -909,24 +904,6 @@ def command(commands: Union[str, List[str]], prefixes: Union[str, List[str]] = "
without_prefix = text[len(prefix):]
for cmd in flt.commands:
if usernames:
for username in usernames:
if not re.match(rf"^(?:{cmd}(?:@?{username})?)(?:\s|$)", without_prefix,
flags=re.IGNORECASE if not flt.case_sensitive else 0):
continue
without_command = re.sub(rf"{cmd}(?:@?{username})?\s?", "", without_prefix, count=1,
flags=re.IGNORECASE if not flt.case_sensitive else 0)
# match.groups are 1-indexed, group(1) is the quote, group(2) is the text
# between the quotes, group(3) is unquoted, whitespace-split text
# Remove the escape character from the arguments
message.command = [cmd] + [
re.sub(r"\\([\"'])", r"\1", m.group(2) or m.group(3) or "")
for m in command_re.finditer(without_command)
]
return True
if not re.match(rf"^(?:{cmd}(?:@?{username})?)(?:\s|$)", without_prefix,
flags=re.IGNORECASE if not flt.case_sensitive else 0):
continue
@ -1034,22 +1011,12 @@ class user(Filter, set):
)
async def __call__(self, _, message: Message):
is_usernames_in_filters = False
if message.from_user.usernames:
for username in message.from_user.usernames:
if (
username.username in self
or username.username.lower() in self
):
is_usernames_in_filters = True
break
return (message.from_user
and (message.from_user.id in self
or (message.from_user.username
and message.from_user.username.lower() in self)
or ("me" in self
and message.from_user.is_self))
or is_usernames_in_filters)
and message.from_user.is_self)))
# noinspection PyPep8Naming
@ -1077,15 +1044,6 @@ class chat(Filter, set):
async def __call__(self, _, message: Union[Message, Story]):
if isinstance(message, Story):
is_usernames_in_filters = False
if message.sender_chat.usernames:
for username in message.sender_chat.usernames:
if (
username.username in self
or username.username.lower() in self
):
is_usernames_in_filters = True
break
return (
message.sender_chat
and (
@ -1104,17 +1062,8 @@ class chat(Filter, set):
and message.from_user.username.lower() in self
)
)
) or is_usernames_in_filters
)
else:
is_usernames_in_filters = False
if message.chat.usernames:
for username in message._chat.usernames:
if (
username.username in self
or username.username.lower() in self
):
is_usernames_in_filters = True
break
return (message.chat
and (message.chat.id in self
or (message.chat.username
@ -1122,10 +1071,7 @@ class chat(Filter, set):
or ("me" in self
and message.from_user
and message.from_user.is_self
and not message.outgoing))
or (is_usernames_in_filters
and not message.outgoing)
)
and not message.outgoing)))
# noinspection PyPep8Naming