From 60711d0a28f3fdd8243300f83bdbe0e957d2f651 Mon Sep 17 00:00:00 2001 From: yehuda-lev <94082865+yehuda-lev@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:54:00 +0200 Subject: [PATCH] [filters] prioritize `/` over `!` because the official commands --- pywa/filters.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pywa/filters.py b/pywa/filters.py index 4cf3dc00..4ca82c8a 100644 --- a/pywa/filters.py +++ b/pywa/filters.py @@ -264,11 +264,11 @@ class _TextFilters(_BaseUpdateFilters): """ is_command: _MessageFilterT = lambda _, m: m.type == _Mt.TEXT and m.text.startswith( - ("!", "/", "#") + ("/", "!", "#") ) """ - Filter for text messages that are commands (start with ``!``, ``/``, or ``#``). - - Use _TextFilter.command if you want to filter for specific commands or prefixes. + Filter for text messages that are commands (start with ``/``, ``!``, or ``#``). + - Use text.command(...) if you want to filter for specific commands or prefixes. >>> filters.text.is_command """ @@ -373,17 +373,17 @@ def length(*lengths: tuple[int, int]) -> _MessageFilterT: @staticmethod def command( *cmds: str, - prefixes: str | Iterable[str] = "!", + prefixes: str | Iterable[str] = "/!", ignore_case: bool = False, ) -> _MessageFilterT: """ Filter for text messages that are commands. - >>> text.command("start", "hello", prefixes=("!", "/"), ignore_case=True) + >>> text.command("start", "hello", prefixes="/", ignore_case=True) Args: *cmds: The command/s to filter for (e.g. "start", "hello"). - prefixes: The prefix/s to filter for (default: "!", i.e. "!start"). + prefixes: The prefix/s to filter for (default: "/!", i.e. "/start"). ignore_case: Whether to ignore case when matching (default: ``False``). """ cmds = tuple(c.lower() for c in cmds) if ignore_case else cmds