Skip to content

Commit 58c2f09

Browse files
committed
Add get_owned_bots
1 parent 601da91 commit 58c2f09

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ def get_title_list(s: str) -> list:
365365
send_inline_bot_result
366366
answer_web_app_query
367367
send_web_app_custom_request
368+
get_owned_bots
368369
""",
369370
phone="""
370371
Phone

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Changes in this Fork
2525
| Scheme layer used: 195 |
2626
+------------------------+
2727

28+
- Added the :meth:`~pyrogram.Client.get_owned_bots` to return the list of owned by the current user bots.
2829
- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=194&to=195>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=194&to=195>`__.
2930

3031
+------------------------+

pyrogram/methods/bots/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from .set_bot_name import SetBotName
4040
from .set_chat_menu_button import SetChatMenuButton
4141
from .set_game_score import SetGameScore
42+
from .get_owned_bots import GetOwnedBots
4243

4344

4445
class Bots(
@@ -65,5 +66,6 @@ class Bots(
6566
GetBotInfoShortDescription,
6667
SetBotName,
6768
GetBotName,
69+
GetOwnedBots,
6870
):
6971
pass
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
20+
from typing import List
21+
import pyrogram
22+
from pyrogram import raw, types
23+
24+
25+
class GetOwnedBots:
26+
async def get_owned_bots(
27+
self: "pyrogram.Client",
28+
) -> List["types.User"]:
29+
"""Returns the list of bots owned by the current user.
30+
31+
.. include:: /_includes/usable-by/users.rst
32+
33+
Returns:
34+
List of :obj:`~pyrogram.types.User`: On success.
35+
36+
Example:
37+
.. code-block:: python
38+
39+
bots = await app.get_owned_bots()
40+
"""
41+
42+
bots = await self.invoke(raw.functions.bots.GetAdminedBots())
43+
return types.List([
44+
types.User._parse(self, b)
45+
for b in bots
46+
])

0 commit comments

Comments
 (0)