Fix custom.Message.buttons being None in channels (#870)

The implications behind this were bigger than expected. The sender
of the message is not actually needed for anything in the bot. The
bot itself may be needed, but only for KeyboardButtonSwitchInline.
This commit is contained in:
Lonami Exo
2018-06-27 19:25:14 +02:00
parent 18f06f1a25
commit ad01bda503
2 changed files with 47 additions and 11 deletions

View File

@@ -14,9 +14,9 @@ class MessageButton:
button (:tl:`KeyboardButton`):
The original :tl:`KeyboardButton` object.
"""
def __init__(self, client, original, from_user, chat, msg_id):
def __init__(self, client, original, chat, bot, msg_id):
self.button = original
self._from = from_user
self._bot = bot
self._chat = chat
self._msg_id = msg_id
self._client = client
@@ -82,7 +82,7 @@ class MessageButton:
return None
elif isinstance(self.button, types.KeyboardButtonSwitchInline):
return await self._client(functions.messages.StartBotRequest(
bot=self._from, peer=self._chat, start_param=self.button.query
bot=self._bot, peer=self._chat, start_param=self.button.query
))
elif isinstance(self.button, types.KeyboardButtonUrl):
return webbrowser.open(self.button.url)