Add Button.web_view()

In theory, it should open links inside the telegram app rather than opening another browser.

Please advise if this is not necessary
This commit is contained in:
TrueSaiyan 2024-05-14 09:29:11 +08:00 committed by GitHub
parent 47673680f4
commit 003c6f6626
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -307,3 +307,14 @@ class Button:
documentation for more information on using games. documentation for more information on using games.
""" """
return types.KeyboardButtonGame(text) return types.KeyboardButtonGame(text)
@staticmethod
def web_view(text, url=None):
"""
Creates a new inline button to open the desired URL in a WebView.
If no `url` is given, the `text` will be used as the URL instead.
You cannot detect that the user clicked this button directly.
When the user clicks this button, the URL will open in the Telegram
app's WebView directly.
"""
return types.KeyboardButtonWebView(text, url or text)