mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-22 22:09:48 +03:00
open_url argument added to prevent browser from opening
passing open_url=True will open browser and return True on success else it will just return the button's URL to be processed via code.
This commit is contained in:
parent
77b7edcd6e
commit
432b9b71d9
|
@ -65,7 +65,7 @@ class MessageButton:
|
|||
if isinstance(self.button, types.KeyboardButtonUrl):
|
||||
return self.button.url
|
||||
|
||||
async def click(self, share_phone=None, share_geo=None, *, password=None):
|
||||
async def click(self, share_phone=None, share_geo=None, *, password=None, open_url=None):
|
||||
"""
|
||||
Emulates the behaviour of clicking this button.
|
||||
|
||||
|
@ -79,7 +79,8 @@ class MessageButton:
|
|||
:tl:`StartBotRequest` will be invoked and the resulting updates
|
||||
returned.
|
||||
|
||||
If it's a :tl:`KeyboardButtonUrl`, the URL of the button will
|
||||
If it's a :tl:`KeyboardButtonUrl`, the ``URL`` of the button will
|
||||
be returned. If you pass ``open_url=True`` the URL of the button will
|
||||
be passed to ``webbrowser.open`` and return `True` on success.
|
||||
|
||||
If it's a :tl:`KeyboardButtonRequestPhone`, you must indicate that you
|
||||
|
@ -116,8 +117,10 @@ class MessageButton:
|
|||
bot=self._bot, peer=self._chat, start_param=self.button.query
|
||||
))
|
||||
elif isinstance(self.button, types.KeyboardButtonUrl):
|
||||
if "webbrowser" in sys.modules:
|
||||
return webbrowser.open(self.button.url)
|
||||
if open_url:
|
||||
if "webbrowser" in sys.modules:
|
||||
return webbrowser.open(self.button.url)
|
||||
return self.button.url
|
||||
elif isinstance(self.button, types.KeyboardButtonGame):
|
||||
req = functions.messages.GetBotCallbackAnswerRequest(
|
||||
peer=self._chat, msg_id=self._msg_id, game=True
|
||||
|
|
Loading…
Reference in New Issue
Block a user