Skip to content

Commit 43f9b57

Browse files
committed
Add the method answer_web_app_query
1 parent 747b25b commit 43f9b57

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ def get_title_list(s: str) -> list:
299299
get_bot_default_privileges
300300
set_chat_menu_button
301301
get_chat_menu_button
302+
answer_web_app_query
302303
""",
303304
authorization="""
304305
Authorization

pyrogram/methods/bots/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from .answer_callback_query import AnswerCallbackQuery
2020
from .answer_inline_query import AnswerInlineQuery
21+
from .answer_web_app_query import AnswerWebAppQuery
2122
from .delete_bot_commands import DeleteBotCommands
2223
from .get_bot_commands import GetBotCommands
2324
from .get_bot_default_privileges import GetBotDefaultPrivileges
@@ -48,6 +49,7 @@ class Bots(
4849
SetBotDefaultPrivileges,
4950
GetBotDefaultPrivileges,
5051
SetChatMenuButton,
51-
GetChatMenuButton
52+
GetChatMenuButton,
53+
AnswerWebAppQuery
5254
):
5355
pass
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)