Skip to content

Commit b6a9607

Browse files
committed
Add get_similar_bots to return a list of bots similar to the given bot.
1 parent 05badbf commit b6a9607

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ def get_title_list(s: str) -> list:
366366
answer_web_app_query
367367
send_web_app_custom_request
368368
get_owned_bots
369+
get_similar_bots
369370
""",
370371
phone="""
371372
Phone

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

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

29+
- Added the :meth:`~pyrogram.Client.get_similar_bots`.
2930
- Changed types in :obj:`~pyrogram.types.UpgradedGift`, :obj:`~pyrogram.types.UserGift`.
3031
- PR from upstream: `701 <https://github.com/pyrogram/pyrogram/pull/701>`_
3132
- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=196&to=198>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=196&to=198>`__.

pyrogram/methods/bots/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from .set_chat_menu_button import SetChatMenuButton
4141
from .set_game_score import SetGameScore
4242
from .get_owned_bots import GetOwnedBots
43+
from .get_similar_bots import GetSimilarBots
4344

4445

4546
class Bots(
@@ -67,5 +68,6 @@ class Bots(
6768
SetBotName,
6869
GetBotName,
6970
GetOwnedBots,
71+
GetSimilarBots,
7072
):
7173
pass
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present <https://github.com/TelegramPlayGround>
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+
from typing import Union
20+
21+
import pyrogram
22+
from pyrogram import raw, types
23+
24+
25+
class GetSimilarBots:
26+
async def get_similar_bots(
27+
self: "pyrogram.Client",
28+
user_id: Union[int, str]
29+
) -> list["types.User"]:
30+
"""Returns a list of bots similar to the given bot.
31+
32+
.. include:: /_includes/usable-by/users.rst
33+
34+
Parameters:
35+
user_id (``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+
Example:
42+
.. code-block:: python
43+
44+
bots = await app.get_similar_bots()
45+
"""
46+
47+
botss = await self.invoke(raw.functions.bots.GetBotRecommendations(
48+
bot=await self.resolve_peer(user_id)
49+
))
50+
return types.List([
51+
types.User._parse(self, b)
52+
for b in botss.users
53+
])

0 commit comments

Comments
 (0)