This repository was archived by the owner on Nov 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbots.py
More file actions
76 lines (60 loc) · 2.51 KB
/
bots.py
File metadata and controls
76 lines (60 loc) · 2.51 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from pyrogram import enums, filters
@app.on_message(filters.command("bots") & filters.group)
async def bots(client, message):
bot_list = []
async for bot in app.get_chat_members(
message.chat.id, filter=enums.ChatMembersFilter.BOTS
):
bot_list.append(bot.user)
total_bots = len(bot_list)
if total_bots == 0:
await message.reply_text("There are no bots in this group.")
return
header = f"**🤖 Bot List in {message.chat.title}**\n\n"
bot_lines = "\n".join(
[f"{i + 1}. @{bot.username}" for i, bot in enumerate(bot_list)]
)
footer = f"\n\n**Total Number of Bots:** {total_bots}"
result_text = header + bot_lines + footer
await app.send_message(message.chat.id, result_text)
@app.on_message(filters.command(["staff", "staffs"]) & filters.group)
async def staffs(client, message):
owner_list = []
admin_list = []
async for member in app.get_chat_members(
message.chat.id, filter=enums.ChatMembersFilter.ADMINISTRATORS
):
staff = member.user
staff_name = f"{staff.first_name} {staff.last_name or ''}".strip()
staff_username = f"@{staff.username}" if staff.username else "No Username"
if member.status == enums.ChatMemberStatus.OWNER:
custom_title = member.custom_title if member.custom_title else "Owner"
owner_list.append(f"{staff_name} ({staff_username}) - {custom_title}")
elif member.status == enums.ChatMemberStatus.ADMINISTRATOR:
custom_title = member.custom_title if member.custom_title else "Admin"
admin_list.append(f"{staff_name} ({staff_username}) - {custom_title}")
total_owners = len(owner_list)
total_admins = len(admin_list)
result_text = ""
if total_owners > 0:
result_text += "**👑 Owner(s)**\n"
result_text += (
"\n".join([f"{i + 1}: {owner}" for i, owner in enumerate(owner_list)])
+ "\n\n"
)
else:
result_text += "**👑 Owner(s)**\nNo owner found.\n\n"
if total_admins > 0:
result_text += "**👮♂️ Admin(s)**\n"
result_text += (
"\n".join([f"{i + 1}: {admin}" for i, admin in enumerate(admin_list)])
+ "\n"
)
else:
result_text += "**👮♂️ Admin(s)**\nNo admins found.\n"
await app.send_message(message.chat.id, result_text)
__MODULE__ = "Bots"
__HELP__ = """
• /bots - Get a list of bots in the group.
• /staffs - Get a list of staff members (owners & admins) in the group.
"""