File size: 781 Bytes
80287e2 |
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 |
from pyrogram.types import Message
from pyrogram.enums import ChatType, ChatMemberStatus
async def admin_check(message: Message) -> bool:
if not message.from_user:
return False
if message.chat.type not in [ChatType.SUPERGROUP, ChatType.CHANNEL]:
return False
if message.from_user.id in [
777000, # Telegram Service Notifications
6440363814, # GroupAnonymousBot
]:
return True
client = message._client
chat_id = message.chat.id
user_id = message.from_user.id
check_status = await client.get_chat_member(chat_id=chat_id, user_id=user_id)
if check_status.status not in [
ChatMemberStatus.OWNER,
ChatMemberStatus.ADMINISTRATOR
]:
return False
else:
return True
|