|
| 1 | +# Pyrogram - Telegram MTProto API Client Library for Python |
| 2 | +# Copyright (C) 2017-present Dan <https://github.com/delivrance> |
| 3 | +# |
| 4 | +# This file is part of Pyrogram. |
| 5 | +# |
| 6 | +# Pyrogram is free software: you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU Lesser General Public License as published |
| 8 | +# by the Free Software Foundation, either version 3 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# Pyrogram is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU Lesser General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU Lesser General Public License |
| 17 | +# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +import pyrogram |
| 20 | +from pyrogram import raw |
| 21 | +from pyrogram import types |
| 22 | + |
| 23 | + |
| 24 | +class AnswerWebAppQuery: |
| 25 | + async def answer_web_app_query( |
| 26 | + self: "pyrogram.Client", |
| 27 | + web_app_query_id: str, |
| 28 | + result: "types.InlineQueryResult" |
| 29 | + ) -> "types.SentWebAppMessage": |
| 30 | + """Set the result of an interaction with a `Web App <https://core.telegram.org/bots/webapps>`_ and send a |
| 31 | + corresponding message on behalf of the user to the chat from which the query originated. |
| 32 | +
|
| 33 | + Parameters: |
| 34 | + web_app_query_id (``str``): |
| 35 | + Unique identifier for the answered query. |
| 36 | +
|
| 37 | + result (:obj:`~pyrogram.types.InlineQueryResult`): |
| 38 | + A list of results for the inline query. |
| 39 | +
|
| 40 | + Returns: |
| 41 | + :obj:`~pyrogram.types.SentWebAppMessage`: On success the sent web app message is returned. |
| 42 | + """ |
| 43 | + |
| 44 | + r = await self.invoke( |
| 45 | + raw.functions.messages.SendWebViewResultMessage( |
| 46 | + bot_query_id=web_app_query_id, |
| 47 | + result=await result.write(self) |
| 48 | + ) |
| 49 | + ) |
| 50 | + |
| 51 | + return types.SentWebAppMessage._parse(r) |
0 commit comments