From 0a96355c5dcda94a7ce982421ca0eeba66adf80d Mon Sep 17 00:00:00 2001 From: ColinShark Date: Sat, 1 Jun 2019 23:31:17 +0200 Subject: [PATCH] Add Filter for Callback_Query.data --- pyrogram/client/filters/filters.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 9c80d870..a3e39117 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -339,4 +339,19 @@ class Filters: and message.from_user.is_self and not message.outgoing))) + @staticmethod + def data(data: str or bytes = None): + """Filter callback queries for their data. + + Parameters: + data (``str`` | ``bytes``): + Pass the data you want to filter for. + Defaults to None (no data). + """ + + def f(_, cb): + return bool(cb.data and cb.data == _.d) + + return create("Data", f, d=data) + dan = create("Dan", lambda _, m: bool(m.from_user and m.from_user.id == 23122162))