This commit is contained in:
levina 2022-01-19 21:44:22 +07:00 committed by GitHub
parent 22e1c4e6de
commit 9bb1ecac60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,40 @@
""" chat utilities """
from functools import wraps
from driver.veez import bot
from config import SUDO_USERS
from pyrogram.types import Message
from program.admins import member_permissions
from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden
async def authorised(m: Message):
chatID = message.chat.id
return 0
async def unauthorised(m: Message):
chatID = m.chat.id
text = (
"You're missing admin rights to use this command."
+ f"\n\n» ❌ can_manage_voice_chats"
)
try:
await m.reply_text(text)
except ChatWriteForbidden:
await bot.leave_chat(chatID)
return 1
async def adminsOnly(permission, m: Message):
chatID = m.chat.id
if not m.from_user:
if m.sender_chat:
return await authorised(m)
return await unauthorised(m)
userID = m.from_user.id
permissions = await member_permissions(chatID, userID)
if userID not in SUDO_USERS and permission not in permissions:
return await unauthorised(m)
return await authorised(m)