Skip to content

Commit

Permalink
Add get_owned_bots
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe authored Dec 5, 2024
1 parent 601da91 commit 3d035e4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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>`__.

+------------------------+
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/bots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -65,5 +66,6 @@ class Bots(
GetBotInfoShortDescription,
SetBotName,
GetBotName,
GetOwnedBots,
):
pass
46 changes: 46 additions & 0 deletions pyrogram/methods/bots/get_owned_bots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# 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 <http://www.gnu.org/licenses/>.


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
])

0 comments on commit 3d035e4

Please sign in to comment.