From 003c6f662604a70c3ed6336632e6772552f15525 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 14 May 2024 09:29:11 +0800 Subject: [PATCH] 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 --- telethon/tl/custom/button.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/telethon/tl/custom/button.py b/telethon/tl/custom/button.py index 1b7d71e4..f1aa0dac 100644 --- a/telethon/tl/custom/button.py +++ b/telethon/tl/custom/button.py @@ -307,3 +307,14 @@ class Button: documentation for more information on using games. """ 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)