|
| 1 | +# Pyrofork - Telegram MTProto API Client Library for Python |
| 2 | +# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan> |
| 3 | +# |
| 4 | +# This file is part of Pyrofork. |
| 5 | +# |
| 6 | +# Pyrofork 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 | +# Pyrofork 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 Pyrofork. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +from typing import List, Union |
| 20 | + |
| 21 | +import pyrogram |
| 22 | +from pyrogram import raw |
| 23 | + |
| 24 | + |
| 25 | +class GetSimilarBots: |
| 26 | + async def get_similar_bots( |
| 27 | + self: "pyrogram.Client", |
| 28 | + bot: Union[int, str] |
| 29 | + ) -> List[pyrogram.types.User]: |
| 30 | + """Get a list of bots similar to the target bot. |
| 31 | +
|
| 32 | + .. include:: /_includes/usable-by/users.rst |
| 33 | +
|
| 34 | + Parameters: |
| 35 | + bot (``int`` | ``str``): |
| 36 | + Unique identifier (int) or username (str) of the target bot. |
| 37 | +
|
| 38 | + Returns: |
| 39 | + List of :obj:`~pyrogram.types.User`: On success. |
| 40 | + """ |
| 41 | + peer = await self.resolve_peer(bot) |
| 42 | + r = await self.invoke(raw.functions.bots.GetBotRecommendations(bot=peer)) |
| 43 | + return [ |
| 44 | + pyrogram.types.User._parse(self, u) |
| 45 | + for u in r.users |
| 46 | + ] |
0 commit comments