Add open_url param to control browser opening on click (#4607)

This commit is contained in:
AEIMS
2025-05-04 23:31:55 +03:30
committed by GitHub
parent 77b7edcd6e
commit 6a7331b7dc
2 changed files with 17 additions and 8 deletions

View File

@@ -871,7 +871,7 @@ class Message(ChatGetter, SenderGetter, TLObject):
async def click(self, i=None, j=None,
*, text=None, filter=None, data=None, share_phone=None,
share_geo=None, password=None):
share_geo=None, password=None, open_url=None):
"""
Calls :tl:`SendVote` with the specified poll option
or `button.click <telethon.tl.custom.messagebutton.MessageButton.click>`
@@ -955,7 +955,13 @@ class Message(ChatGetter, SenderGetter, TLObject):
button to transfer ownership), if your account has 2FA enabled,
you need to provide your account's password. Otherwise,
`teltehon.errors.PasswordHashInvalidError` is raised.
open_url (`bool`):
When clicking on an inline keyboard URL button :tl:`KeyboardButtonUrl`
By default it will return URL of the button, passing ``click(open_url=True)``
will lunch the default browser with given URL of the button and
return `True` on success.
Example:
.. code-block:: python
@@ -985,7 +991,7 @@ class Message(ChatGetter, SenderGetter, TLObject):
but = types.KeyboardButtonCallback('', data)
return await MessageButton(self._client, but, chat, None, self.id).click(
share_phone=share_phone, share_geo=share_geo, password=password)
share_phone=share_phone, share_geo=share_geo, password=password, open_url=open_url)
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')
@@ -1058,7 +1064,7 @@ class Message(ChatGetter, SenderGetter, TLObject):
button = find_button()
if button:
return await button.click(
share_phone=share_phone, share_geo=share_geo, password=password)
share_phone=share_phone, share_geo=share_geo, password=password, open_url=open_url)
async def mark_read(self):
"""