diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index a5548590..dc1de959 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -397,6 +397,7 @@ def pyrogram_api(): sell_gift send_gift toggle_gift_is_saved + get_owned_bots """, business=""" Telegram Business diff --git a/pyrogram/methods/bots/__init__.py b/pyrogram/methods/bots/__init__.py index 003bac3e..5d212da1 100644 --- a/pyrogram/methods/bots/__init__.py +++ b/pyrogram/methods/bots/__init__.py @@ -36,6 +36,7 @@ from .set_bot_default_privileges import SetBotDefaultPrivileges from .set_bot_info import SetBotInfo from .set_chat_menu_button import SetChatMenuButton from .set_game_score import SetGameScore +from .get_owned_bots import GetOwnedBots class Bots( @@ -57,6 +58,7 @@ class Bots( SetChatMenuButton, GetChatMenuButton, AnswerWebAppQuery, - GetCollectibleItemInfo + GetCollectibleItemInfo, + GetOwnedBots, ): pass diff --git a/pyrogram/methods/bots/get_owned_bots.py b/pyrogram/methods/bots/get_owned_bots.py new file mode 100644 index 00000000..ca205a09 --- /dev/null +++ b/pyrogram/methods/bots/get_owned_bots.py @@ -0,0 +1,46 @@ +# 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 . + + +from typing import List +import pyrogram +from pyrogram import raw, types + + +class GetOwnedBots: + async def get_owned_bots( + self: "pyrogram.Client", + ) -> List["types.User"]: + """Returns the list of bots owned by the current user. + + .. include:: /_includes/usable-by/users.rst + + Returns: + List of :obj:`~pyrogram.types.User`: On success. + + Example: + .. code-block:: python + + bots = await app.get_owned_bots() + """ + + bots = await self.invoke(raw.functions.bots.GetAdminedBots()) + return types.List([ + types.User._parse(self, b) + for b in bots + ])