-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1486e5e
commit c3e106f
Showing
2 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import logging | ||
import functools | ||
from pyrogram import Client | ||
from pyrogram.types import Message | ||
from pyrogram.types import CallbackQuery | ||
from pyrogram.enums.chat_type import ChatType | ||
|
||
|
||
def only_managers(func): | ||
@functools.wraps(func) | ||
async def _(client: Client, any): | ||
try: | ||
if isinstance(any, Message): | ||
if not any.chat.type == ChatType.PRIVATE: | ||
user = await client.get_chat_member(any.chat.id, any.from_user.id) | ||
if not user.privileges: | ||
return await any.reply( | ||
"**__You are not my master, you do not order me what to do, bye__** \U0001f621" | ||
) | ||
|
||
elif isinstance(any, CallbackQuery): | ||
if not any.message.chat.type == ChatType.PRIVATE: | ||
user = await client.get_chat_member( | ||
any.message.chat.id, any.message.from_user.id | ||
) | ||
if not user.privileges: | ||
return await client.answer_callback_query( | ||
any.id, | ||
text="**__You are not my master or played user, you cannot execute this action.__** \U0001f621", | ||
show_alert=True, | ||
) | ||
except Exception as e: | ||
logging.error(e) | ||
await func(client, any) | ||
|
||
return _ |