mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-27 16:45:19 +00:00
Add quote filter
This commit is contained in:
parent
353a00deda
commit
eb601d5743
@ -129,10 +129,10 @@ def create(func: Callable, name: str = None, **kwargs) -> Filter:
|
|||||||
Parameters:
|
Parameters:
|
||||||
func (``Callable``):
|
func (``Callable``):
|
||||||
A function that accepts three positional arguments *(filter, client, update)* and returns a boolean: True if the
|
A function that accepts three positional arguments *(filter, client, update)* and returns a boolean: True if the
|
||||||
update should be handled, False otherwise.
|
update should be handled, False otherwise.
|
||||||
The *filter* argument refers to the filter itself and can be used to access keyword arguments (read below).
|
The *filter* argument refers to the filter itself and can be used to access keyword arguments (read below).
|
||||||
The *client* argument refers to the :obj:`~pyrogram.Client` that received the update.
|
The *client* argument refers to the :obj:`~pyrogram.Client` that received the update.
|
||||||
The *update* argument type will vary depending on which `Handler <handlers>`_ is coming from.
|
The *update* argument type will vary depending on which `Handler <handlers>`_ is coming from.
|
||||||
For example, in a :obj:`~pyrogram.handlers.MessageHandler` the *update* argument will be a :obj:`~pyrogram.types.Message`; in a :obj:`~pyrogram.handlers.CallbackQueryHandler` the *update* will be a :obj:`~pyrogram.types.CallbackQuery`.
|
For example, in a :obj:`~pyrogram.handlers.MessageHandler` the *update* argument will be a :obj:`~pyrogram.types.Message`; in a :obj:`~pyrogram.handlers.CallbackQueryHandler` the *update* will be a :obj:`~pyrogram.types.CallbackQuery`.
|
||||||
Your function body can then access the incoming update attributes and decide whether to allow it or not.
|
Your function body can then access the incoming update attributes and decide whether to allow it or not.
|
||||||
|
|
||||||
@ -425,6 +425,17 @@ dice = create(dice_filter)
|
|||||||
"""Filter messages that contain :obj:`~pyrogram.types.Dice` objects."""
|
"""Filter messages that contain :obj:`~pyrogram.types.Dice` objects."""
|
||||||
|
|
||||||
|
|
||||||
|
# endregion
|
||||||
|
|
||||||
|
# region quote_filter
|
||||||
|
async def quote_filter(_, __, m: Message):
|
||||||
|
return bool(m.quote)
|
||||||
|
|
||||||
|
|
||||||
|
text = create(quote_filter)
|
||||||
|
"""Filter quote messages."""
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# region media_spoiler
|
# region media_spoiler
|
||||||
|
Loading…
Reference in New Issue
Block a user