Better custom.MessageButton.click() docs

This commit is contained in:
Lonami Exo 2018-06-11 10:24:57 +02:00
parent aa6d3430ae
commit f581db294a
2 changed files with 15 additions and 7 deletions

View File

@ -512,10 +512,8 @@ class Message:
async def click(self, i=None, j=None, *, text=None, filter=None):
"""
Clicks the inline keyboard button of the message, if any.
If the message has a non-inline keyboard, clicking it will
send the message, switch to inline, or open its URL.
Calls `telethon.tl.custom.messagebutton.MessageButton.click`
for the specified button.
Does nothing if the message has no buttons.

View File

@ -54,10 +54,20 @@ class MessageButton:
async def click(self):
"""
Clicks the inline keyboard button of the message, if any.
Emulates the behaviour of clicking this button.
If the message has a non-inline keyboard, clicking it will
send the message, switch to inline, or open its URL.
If it's a normal :tl:`KeyboardButton` with text, a message will be
sent, and the sent `telethon.tl.custom.message.Message` returned.
If it's an inline :tl:`KeyboardButtonCallback` with text and data,
it will be "clicked" and the :tl:`BotCallbackAnswer` returned.
If it's an inline :tl:`KeyboardButtonSwitchInline` button, the
:tl:`StartBotRequest` will be invoked and the resulting updates
returned.
If it's a :tl:`KeyboardButtonUrl`, the URL of the button will
be passed to ``webbrowser.open`` and return ``True`` on success.
"""
if isinstance(self.button, types.KeyboardButton):
return await self._client.send_message(