diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 2a3e696fc..5e5eb9091 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -365,6 +365,7 @@ def get_title_list(s: str) -> list: send_inline_bot_result answer_web_app_query send_web_app_custom_request + get_owned_bots """, phone=""" Phone diff --git a/docs/source/releases/changes-in-this-fork.rst b/docs/source/releases/changes-in-this-fork.rst index a6fff3e54..59aac1c70 100644 --- a/docs/source/releases/changes-in-this-fork.rst +++ b/docs/source/releases/changes-in-this-fork.rst @@ -25,6 +25,7 @@ Changes in this Fork | Scheme layer used: 195 | +------------------------+ +- Added the :meth:`~pyrogram.Client.get_owned_bots` to return the list of owned by the current user bots. - View `new and changed `__ `raw API methods `__. +------------------------+ diff --git a/pyrogram/methods/bots/__init__.py b/pyrogram/methods/bots/__init__.py index 33a602914..8945ed5f3 100644 --- a/pyrogram/methods/bots/__init__.py +++ b/pyrogram/methods/bots/__init__.py @@ -39,6 +39,7 @@ from .set_bot_name import SetBotName from .set_chat_menu_button import SetChatMenuButton from .set_game_score import SetGameScore +from .get_owned_bots import GetOwnedBots class Bots( @@ -65,5 +66,6 @@ class Bots( GetBotInfoShortDescription, SetBotName, GetBotName, + 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 000000000..9956fa1a3 --- /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 owned by the current user bots. + + .. 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 + ])