-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
client/src/telethon/_impl/client/events/filters/callback.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
from .combinators import Combinable | ||
from ..event import Event | ||
|
||
|
||
class Data(Combinable): | ||
""" | ||
Filter by ``event.data`` using a full bytes match, used for events such as :class:`telethon.events.ButtonCallback`. | ||
It checks if ``event.data`` is equal to the data passed to the filter. | ||
:param data: Bytes to match data with. | ||
""" | ||
|
||
__slots__ = ("_data",) | ||
|
||
def __init__(self, data: bytes) -> None: | ||
self._data = data | ||
|
||
def __call__(self, event: Event) -> bool: | ||
data = getattr(event, "data", None) | ||
return self._data == data if data is not None else False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
Reply, | ||
Senders, | ||
Text, | ||
Data, | ||
) | ||
|
||
__all__ = [ | ||
|
@@ -39,4 +40,5 @@ | |
"Reply", | ||
"Senders", | ||
"Text", | ||
"Data" | ||
] |