From f2460fa6ba6bb9576df0ed8f7f39060debc6fc1f Mon Sep 17 00:00:00 2001 From: apepenkov Date: Thu, 9 Nov 2023 21:43:26 +0300 Subject: [PATCH] implement alert, url, cache_time parameters in ButtonCallback.answer --- .../telethon/_impl/client/events/queries.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/client/src/telethon/_impl/client/events/queries.py b/client/src/telethon/_impl/client/events/queries.py index 08b5ef7f..73c13845 100644 --- a/client/src/telethon/_impl/client/events/queries.py +++ b/client/src/telethon/_impl/client/events/queries.py @@ -44,6 +44,9 @@ class ButtonCallback(Event): async def answer( self, text: Optional[str] = None, + alert: bool = False, + url: Optional[str] = None, + cache_time: int = 0, ) -> None: """ Answer the callback query. @@ -54,14 +57,23 @@ class ButtonCallback(Event): :param text: The text of the message to display to the user, usually as a toast. + :param alert: + If True, the answer will be shown as a pop-up alert that must be dismissed by the user. + :param url: + Url, to which user will be redirected upon pressing the button. + It should be a link to the same bot with ?start=... parameter, or a link to the game. + :param cache_time: + Time in seconds to cache the answer on the client side, + preventing repeated callback queries from being sent to the bot on subsequent button presses. + A cache_time of 0 means each button press will send a callback query to the bot. """ await self._client( functions.messages.set_bot_callback_answer( - alert=False, + alert=alert, query_id=self._raw.query_id, message=text, - url=None, - cache_time=0, + url=url, + cache_time=cache_time, ) )