Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions pyrogram/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,33 @@ async def func(flt, client: pyrogram.Client, message: Message):
)


# endregion


# region cq_data_filter
def cq_data(data: Union[str, List[str]]):
"""Filter callback query updates that match a given string or list of strings.

Can be applied to handlers that receive :obj:`~pyrogram.types.CallbackQuery` updates.

Parameters:
data (``str`` | ``List[str]``):
The data or list of data strings to match against the callback query.

Returns:
:obj:`callable`: A filter function that matches callback query updates based on the provided data.
"""

async def func(_, __, callback_query: CallbackQuery):
if isinstance(data, str):
return callback_query.data == data
elif isinstance(data, list):
return callback_query.data in data
else:
return False
return filters.create(func)


# endregion

def regex(pattern: Union[str, Pattern], flags: int = 0):
Expand Down