-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_bot.py
42 lines (39 loc) · 1.35 KB
/
get_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
""" Get the Bots in any chat*
Syntax: .get_bot"""
from telethon import events
from telethon.tl.types import ChannelParticipantAdmin, ChannelParticipantsBots
from ULTRA import CMD_HELP
from ULTRA.utils import admin_cmd
@borg.on(admin_cmd("get_bot ?(.*)"))
async def _(event):
if event.fwd_from:
return
mentions = "**Bots in this Channel**: \n"
input_str = event.pattern_match.group(1)
to_write_chat = await event.get_input_chat()
chat = None
if not input_str:
chat = to_write_chat
else:
mentions = "Bots in {} channel: \n".format(input_str)
try:
chat = await borg.get_entity(input_str)
except Exception as e:
await event.edit(str(e))
return None
try:
async for x in borg.iter_participants(chat, filter=ChannelParticipantsBots):
if isinstance(x.participant, ChannelParticipantAdmin):
mentions += "\n ⚜️ [{}](tg://user?id={}) `{}`".format(x.first_name, x.id, x.id)
else:
mentions += "\n [{}](tg://user?id={}) `{}`".format(x.first_name, x.id, x.id)
except Exception as e:
mentions += " " + str(e) + "\n"
await event.edit(mentions)
CMD_HELP.update(
{
"get_bot": "**Plugin : **`get_bot`\
\n\n**Syntax : **`.get_bot`\
\n**Function : **all bots list use .get_bot"
}
)