Fix custom.Message.click not having buttons

This commit is contained in:
Lonami Exo 2018-05-31 14:09:43 +02:00
parent a1c511429e
commit 2191fbf30b

View File

@ -27,7 +27,7 @@ class Message:
self._text = None self._text = None
self._reply_to = None self._reply_to = None
self._buttons = None self._buttons = None
self._buttons_flat = [] self._buttons_flat = None
self._sender = entities.get(self.original_message.from_id) self._sender = entities.get(self.original_message.from_id)
self._chat = entities.get(get_peer_id(self.original_message.to_id)) self._chat = entities.get(get_peer_id(self.original_message.to_id))
self._input_sender = None self._input_sender = None
@ -260,6 +260,8 @@ class Message:
If the message has a non-inline keyboard, clicking it will If the message has a non-inline keyboard, clicking it will
send the message, switch to inline, or open its URL. send the message, switch to inline, or open its URL.
Does nothing if the message has no buttons.
Args: Args:
i (`int`): i (`int`):
Clicks the i'th button (starting from the index 0). Clicks the i'th button (starting from the index 0).
@ -297,6 +299,9 @@ class Message:
if sum(int(x is not None) for x in (i, text, filter)) >= 2: if sum(int(x is not None) for x in (i, text, filter)) >= 2:
raise ValueError('You can only set either of i, text or filter') raise ValueError('You can only set either of i, text or filter')
if not self.buttons:
return # Accessing the property sets self._buttons[_flat]
if text is not None: if text is not None:
if callable(text): if callable(text):
for button in self._buttons_flat: for button in self._buttons_flat: