mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Accept command strings as parameter
This commit is contained in:
parent
c33c7c76fd
commit
7537a27620
@ -30,7 +30,23 @@ def build(name: str, func: callable, **kwargs) -> type:
|
||||
|
||||
class Filters:
|
||||
text = build("Text", lambda _, m: bool(m.text and not m.text.startswith("/")))
|
||||
command = build("Command", lambda _, m: bool(m.text and m.text.startswith("/")))
|
||||
|
||||
@staticmethod
|
||||
def command(command: str or list = list()):
|
||||
return build(
|
||||
"Command",
|
||||
lambda _, m: bool(
|
||||
m.text
|
||||
and m.text.startswith("/")
|
||||
and (m.text[1:].split()[0] in _.c)
|
||||
),
|
||||
c=(
|
||||
[command]
|
||||
if not isinstance(command, list)
|
||||
else command
|
||||
)
|
||||
)
|
||||
|
||||
reply = build("Reply", lambda _, m: bool(m.reply_to_message))
|
||||
forwarded = build("Forwarded", lambda _, m: bool(m.forward_date))
|
||||
caption = build("Caption", lambda _, m: bool(m.caption))
|
||||
|
Loading…
x
Reference in New Issue
Block a user