diff --git a/telethon/client/buttons.py b/telethon/client/buttons.py index 536c6e6f..4741cbda 100644 --- a/telethon/client/buttons.py +++ b/telethon/client/buttons.py @@ -1,6 +1,6 @@ from .updates import UpdateMethods from ..tl import types, custom -from .. import utils +from .. import utils, events class ButtonMethods(UpdateMethods): @@ -30,7 +30,12 @@ class ButtonMethods(UpdateMethods): is_inline |= inline is_normal |= not inline if isinstance(button, custom.Button): - # TODO actually register callbacks + if button.callback: + self.add_event_handler( + button.callback, + events.CallbackQuery(data=button.data) + ) + button = button.button if button.SUBCLASS_OF_ID == 0xbad74a3: diff --git a/telethon/tl/custom/button.py b/telethon/tl/custom/button.py index b0094dfd..689d7b51 100644 --- a/telethon/tl/custom/button.py +++ b/telethon/tl/custom/button.py @@ -29,6 +29,11 @@ class Button: self.callback = callback self.is_inline = self._is_inline(button) + @property + def data(self): + if isinstance(self.button, types.KeyboardButtonCallback): + return self.button.data + @classmethod def _is_inline(cls, button): """