-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatinfo.py
35 lines (28 loc) · 1.52 KB
/
chatinfo.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
from .. import loader, utils
from pyrogram import Client, types, enums
@loader.module('ChatInfo', author='Layz')
class ChatInfoMod(loader.Module):
"""ChatInfo предоставит информацию о чате или группе"""
async def chat_cmd(self, app: Client, message: types.Message):
"""Дает список администраторов и участников группы"""
chatId = message.chat.id
bots = [bot.user.username async for bot in app.get_chat_members(
chatId,
filter=enums.ChatMembersFilter.BOTS # type: ignore
)]
owners = [owner.user.username async for owner in app.get_chat_members(
chatId,
filter=enums.ChatMembersFilter.ADMINISTRATORS # type: ignore
) if owner.user.username not in bots]
members = [member.user.username async for member in app.get_chat_members(
chatId # type: ignore
) if member.user.username not in bots]
total = members + owners
# это так для pylance, а то бесит ^^^
await utils.answer(
message,
f'📝 Информация о чате "{message.chat.title}"\n\n'
f'Всего **{len(total)}** участников\n\n'
'👨✈️ Администраторы: ' + ', '.join(owner for owner in owners) + '\n\n'
'🧍♂️ Участники: ' + ', '.join(member for member in members)
)