Callback Filters#
- pywa.filters.callback#
alias of
CallbackFilter
- static callback.data_matches(*matches: str, ignore_case: bool = False) CallbackFilterT#
Filter for callbacks their data match exactly the given string/s.
>>> callback.data_matches("menu") >>> callback.data_matches("back","return","exit")
- Parameters:
*matches – The string/s to match.
ignore_case – Whether to ignore case when matching (default: False).
- static callback.data_contains(*matches: str, ignore_case: bool = False) CallbackFilterT#
Filter for callbacks their data contains the given string/s.
>>> callback.data_contains("back")
- Parameters:
*matches – The string/s to match.
ignore_case – Whether to ignore case when matching (default: False).
- static callback.data_startswith(*matches: str, ignore_case: bool = False) CallbackFilterT#
Filter for callbacks their data starts with the given string/s.
>>> callback.data_startswith("id:")
- Parameters:
*matches – The string/s to match.
ignore_case – Whether to ignore case when matching (default: False).
- static callback.data_endswith(*matches: str, ignore_case: bool = False) CallbackFilterT#
Filter for callbacks their data ends with the given string/s.
>>> callback.data_endswith(":true", ":false")
- Parameters:
*matches – The string/s to match.
ignore_case – Whether to ignore case when matching (default: False).
- static callback.data_regex(*patterns: str | re.Pattern, flags: int = 0) CallbackFilterT#
Filter for callbacks their data matches the given regex/regexes.
>>> callback.data_regex(r"^\d+$") # only digits
- Parameters:
*patterns – The regex/regexes to match.
flags – The regex flags to use (default: 0).