diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index e1667a85..3948df69 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -299,6 +299,7 @@ def pyrogram_api(): get_bot_default_privileges set_chat_menu_button get_chat_menu_button + answer_web_app_query """, authorization=""" Authorization diff --git a/pyrogram/methods/bots/__init__.py b/pyrogram/methods/bots/__init__.py index de1abe1c..da52fcfb 100644 --- a/pyrogram/methods/bots/__init__.py +++ b/pyrogram/methods/bots/__init__.py @@ -18,6 +18,7 @@ from .answer_callback_query import AnswerCallbackQuery from .answer_inline_query import AnswerInlineQuery +from .answer_web_app_query import AnswerWebAppQuery from .delete_bot_commands import DeleteBotCommands from .get_bot_commands import GetBotCommands from .get_bot_default_privileges import GetBotDefaultPrivileges @@ -48,6 +49,7 @@ class Bots( SetBotDefaultPrivileges, GetBotDefaultPrivileges, SetChatMenuButton, - GetChatMenuButton + GetChatMenuButton, + AnswerWebAppQuery ): pass diff --git a/pyrogram/methods/bots/answer_web_app_query.py b/pyrogram/methods/bots/answer_web_app_query.py new file mode 100644 index 00000000..f887e280 --- /dev/null +++ b/pyrogram/methods/bots/answer_web_app_query.py @@ -0,0 +1,51 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-present Dan +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +import pyrogram +from pyrogram import raw +from pyrogram import types + + +class AnswerWebAppQuery: + async def answer_web_app_query( + self: "pyrogram.Client", + web_app_query_id: str, + result: "types.InlineQueryResult" + ) -> "types.SentWebAppMessage": + """Set the result of an interaction with a `Web App `_ and send a + corresponding message on behalf of the user to the chat from which the query originated. + + Parameters: + web_app_query_id (``str``): + Unique identifier for the answered query. + + result (:obj:`~pyrogram.types.InlineQueryResult`): + A list of results for the inline query. + + Returns: + :obj:`~pyrogram.types.SentWebAppMessage`: On success the sent web app message is returned. + """ + + r = await self.invoke( + raw.functions.messages.SendWebViewResultMessage( + bot_query_id=web_app_query_id, + result=await result.write(self) + ) + ) + + return types.SentWebAppMessage._parse(r)