Skip to content

Commit bbd208c

Browse files
committed
Add send_web_app_custom_request
1 parent d465190 commit bbd208c

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def get_title_list(s: str) -> list:
187187
set_chat_menu_button
188188
get_chat_menu_button
189189
answer_web_app_query
190+
send_web_app_custom_request
190191
set_bot_name
191192
get_bot_name
192193
set_bot_info_description

compiler/errors/source/400_BAD_REQUEST.tsv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ STICKER_THUMB_TGS_NOTGS Incorrect stickerset TGS thumb file provided.
417417
STICKER_VIDEO_BIG The specified video sticker is too big.
418418
STICKER_VIDEO_NODOC You must send the video sticker as a document.
419419
STICKER_VIDEO_NOWEBM The specified video sticker is not in webm format.
420+
STORAGE_KEY_REQUIRED A cloud storage key is required.
420421
STORIES_NEVER_CREATED This peer hasn't ever posted any stories.
421422
STORIES_TOO_MUCH You have hit the maximum active stories limit as specified by the [`story_expiring_limit_*` client configuration parameters](https://core.telegram.org/api/config#story-expiring-limit-default): you should buy a [Premium](/api/premium) subscription, delete an active story, or wait for the oldest story to expire.
422423
STORY_ID_EMPTY You specified no story IDs.

docs/source/releases/changes-in-this-fork.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ If you found any issue or have any suggestions, feel free to make `an issue <htt
1414
| Scheme layer used: 181 |
1515
+------------------------+
1616

17+
- Added the :meth:`~pyrogram.Client.send_web_app_custom_request`.
1718
- Added the :meth:`~pyrogram.Client.search_public_hashtag_messages` and :meth:`~pyrogram.Client.search_public_hashtag_messages_count`.
1819
- Added the ``fetch_replies`` parameter to :obj:`~pyrogram.Client`.
1920
- Added the :meth:`~pyrogram.Client.get_message_effects`.

pyrogram/methods/bots/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .request_callback_answer import RequestCallbackAnswer
3232
from .send_game import SendGame
3333
from .send_inline_bot_result import SendInlineBotResult
34+
from .send_web_app_custom_request import SendWebAppCustomRequest
3435
from .set_bot_commands import SetBotCommands
3536
from .set_bot_default_privileges import SetBotDefaultPrivileges
3637
from .set_bot_info_description import SetBotInfoDescription
@@ -44,6 +45,7 @@ class Bots(
4445
AnswerCallbackQuery,
4546
AnswerInlineQuery,
4647
AnswerWebAppQuery,
48+
SendWebAppCustomRequest,
4749
GetInlineBotResults,
4850
RequestCallbackAnswer,
4951
SendInlineBotResult,
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
from typing import Union
20+
21+
import pyrogram
22+
from pyrogram import raw, types
23+
24+
25+
class SendWebAppCustomRequest:
26+
async def send_web_app_custom_request(
27+
self: "pyrogram.Client",
28+
bot_user_id: Union[int, str],
29+
method: str,
30+
parameters: str
31+
) -> str:
32+
"""Sends a custom request from a Web App.
33+
34+
.. include:: /_includes/usable-by/users.rst
35+
36+
Parameters:
37+
bot_user_id (``int`` | ``str``):
38+
Unique identifier of the inline bot you want to get results from. You can specify
39+
a @username (str) or a bot ID (int).
40+
41+
method (``str``):
42+
The method name.
43+
44+
parameters (``str``):
45+
JSON-serialized method parameters.
46+
47+
Returns:
48+
``str``: On success, a JSON-serialized result is returned.
49+
"""
50+
51+
r = await self.invoke(
52+
raw.functions.bots.InvokeWebViewCustomMethod(
53+
bot=await self.resolve_peer(bot_user_id),
54+
custom_method=method,
55+
params=raw.types.DataJSON(
56+
data=parameters
57+
)
58+
)
59+
)
60+
61+
return r.data

0 commit comments

Comments
 (0)