Actually add callbacks registered through Button

This commit is contained in:
Lonami Exo 2018-07-10 19:50:18 +02:00
parent f6c45dcc63
commit a3d6baf408
2 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,6 @@
from .updates import UpdateMethods from .updates import UpdateMethods
from ..tl import types, custom from ..tl import types, custom
from .. import utils from .. import utils, events
class ButtonMethods(UpdateMethods): class ButtonMethods(UpdateMethods):
@ -30,7 +30,12 @@ class ButtonMethods(UpdateMethods):
is_inline |= inline is_inline |= inline
is_normal |= not inline is_normal |= not inline
if isinstance(button, custom.Button): 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 button = button.button
if button.SUBCLASS_OF_ID == 0xbad74a3: if button.SUBCLASS_OF_ID == 0xbad74a3:

View File

@ -29,6 +29,11 @@ class Button:
self.callback = callback self.callback = callback
self.is_inline = self._is_inline(button) self.is_inline = self._is_inline(button)
@property
def data(self):
if isinstance(self.button, types.KeyboardButtonCallback):
return self.button.data
@classmethod @classmethod
def _is_inline(cls, button): def _is_inline(cls, button):
""" """