From 7537a276201d93841d698bc4b878a74f4bf20973 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 10 Apr 2018 14:54:06 +0200 Subject: [PATCH] Accept command strings as parameter --- pyrogram/client/filters/filters.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index ff043a15..be6a935d 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -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))