Skip to content

Commit bd340cd

Browse files
committed
pyrofork: Add get_similar_bot method
Signed-off-by: wulan17 <wulan17@nusantararom.org>
1 parent e8d73fb commit bd340cd

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ def get_title_list(s: str) -> list:
398398
set_bot_info
399399
get_collectible_item_info
400400
get_owned_bots
401+
get_similar_bots
401402
""",
402403
business="""
403404
Telegram Business

pyrogram/methods/bots/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from .set_chat_menu_button import SetChatMenuButton
3838
from .set_game_score import SetGameScore
3939
from .get_owned_bots import GetOwnedBots
40+
from .get_similar_bots import GetSimilarBots
4041

4142

4243
class Bots(
@@ -60,5 +61,6 @@ class Bots(
6061
AnswerWebAppQuery,
6162
GetCollectibleItemInfo,
6263
GetOwnedBots,
64+
GetSimilarBots,
6365
):
6466
pass
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 pyrogram.types.List([
44+
pyrogram.types.User._parse(self, u)
45+
for u in r.users
46+
])

0 commit comments

Comments
 (0)