Filters¶
moonlygram.ext.filters ¶
Message filters for MessageHandler.
A filter decides whether a handler runs for a given Message. Filters are Filter
instances and combine with & (and), | (or) and ~ (not)::
filters.command("ban") & filters.group
Any callable Message -> bool also works as a predicate, but only Filter instances support the combinator operators.
Filter ¶
A predicate over a Message that supports &, | and ~.
Args: predicate: Callable returning whether the message matches. name: Label used in repr, for debugging.
command ¶
Match /name or /name@botusername at the start of a message.
Pass one or more command names; the filter matches any of them.
regex ¶
Match messages whose text the regular expression finds (re.search).
caption_regex ¶
Match messages whose caption the regular expression finds (re.search).
username ¶
Match messages whose sender has one of the usernames (with or without @).
chat_username ¶
Match messages whose chat has one of the usernames (with or without @).
forwarded_from ¶
Match messages forwarded from any of the given user or chat ids.
Matches the original sender recorded in forward_origin, whether that is a user, a sender chat, or a channel.
entity ¶
Match messages carrying a text entity of any of the given types.
Types are the Bot API entity strings, such as "url", "mention", or "hashtag".
mime_type ¶
Match a document, audio, video, animation, or voice with one of the mime types.