mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-07 15:34:52 +00:00
Compare commits
1 commit
ddb1f2b11c
...
07a96f932b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07a96f932b |
3 changed files with 4 additions and 59 deletions
|
|
@ -484,7 +484,6 @@ def pyrogram_api():
|
||||||
BusinessWeeklyOpen
|
BusinessWeeklyOpen
|
||||||
BusinessWorkingHours
|
BusinessWorkingHours
|
||||||
User
|
User
|
||||||
Username
|
|
||||||
Chat
|
Chat
|
||||||
ChatPreview
|
ChatPreview
|
||||||
ChatPhoto
|
ChatPhoto
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__fork_name__ = "PyroFork"
|
__fork_name__ = "PyroFork"
|
||||||
__version__ = "2.3.64"
|
__version__ = "2.3.63"
|
||||||
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
|
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
|
||||||
__copyright__ = "Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>"
|
__copyright__ = "Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -890,12 +890,7 @@ def command(commands: Union[str, List[str]], prefixes: Union[str, List[str]] = "
|
||||||
command_re = re.compile(r"([\"'])(.*?)(?<!\\)\1|(\S+)")
|
command_re = re.compile(r"([\"'])(.*?)(?<!\\)\1|(\S+)")
|
||||||
|
|
||||||
async def func(flt, client: pyrogram.Client, message: Message):
|
async def func(flt, client: pyrogram.Client, message: Message):
|
||||||
usernames = []
|
|
||||||
username = client.me.username or ""
|
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
|
text = message.text or message.caption
|
||||||
message.command = None
|
message.command = None
|
||||||
|
|
||||||
|
|
@ -909,24 +904,6 @@ def command(commands: Union[str, List[str]], prefixes: Union[str, List[str]] = "
|
||||||
without_prefix = text[len(prefix):]
|
without_prefix = text[len(prefix):]
|
||||||
|
|
||||||
for cmd in flt.commands:
|
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,
|
if not re.match(rf"^(?:{cmd}(?:@?{username})?)(?:\s|$)", without_prefix,
|
||||||
flags=re.IGNORECASE if not flt.case_sensitive else 0):
|
flags=re.IGNORECASE if not flt.case_sensitive else 0):
|
||||||
continue
|
continue
|
||||||
|
|
@ -1034,22 +1011,12 @@ class user(Filter, set):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def __call__(self, _, message: Message):
|
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
|
return (message.from_user
|
||||||
and (message.from_user.id in self
|
and (message.from_user.id in self
|
||||||
or (message.from_user.username
|
or (message.from_user.username
|
||||||
and message.from_user.username.lower() in self)
|
and message.from_user.username.lower() in self)
|
||||||
or ("me" in self
|
or ("me" in self
|
||||||
and message.from_user.is_self))
|
and message.from_user.is_self)))
|
||||||
or is_usernames_in_filters)
|
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
|
|
@ -1077,15 +1044,6 @@ class chat(Filter, set):
|
||||||
|
|
||||||
async def __call__(self, _, message: Union[Message, Story]):
|
async def __call__(self, _, message: Union[Message, Story]):
|
||||||
if isinstance(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 (
|
return (
|
||||||
message.sender_chat
|
message.sender_chat
|
||||||
and (
|
and (
|
||||||
|
|
@ -1104,17 +1062,8 @@ class chat(Filter, set):
|
||||||
and message.from_user.username.lower() in self
|
and message.from_user.username.lower() in self
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
) or is_usernames_in_filters
|
)
|
||||||
else:
|
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
|
return (message.chat
|
||||||
and (message.chat.id in self
|
and (message.chat.id in self
|
||||||
or (message.chat.username
|
or (message.chat.username
|
||||||
|
|
@ -1122,10 +1071,7 @@ class chat(Filter, set):
|
||||||
or ("me" in self
|
or ("me" in self
|
||||||
and message.from_user
|
and message.from_user
|
||||||
and message.from_user.is_self
|
and message.from_user.is_self
|
||||||
and not message.outgoing))
|
and not message.outgoing)))
|
||||||
or (is_usernames_in_filters
|
|
||||||
and not message.outgoing)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue