Signed-off-by: Yasir Aris M <git@yasirdev.my.id>
This commit is contained in:
Yasir Aris M 2023-10-23 23:28:14 +07:00
parent e73a0d2e2b
commit 0cdcef3ebd
2 changed files with 6 additions and 7 deletions

View file

@ -116,7 +116,6 @@ def adminsOnly(
self,
permission: typing.Union[str, list],
TRUST_ANON_ADMINS: typing.Union[bool, bool] = False,
ALLOW_CHANNEL: typing.Union[bool, bool] = False,
):
"""
# `tgEasy.tgClient.adminsOnly`
@ -145,11 +144,11 @@ def adminsOnly(
def wrapper(func):
async def decorator(client, message):
permissions = ""
if message.chat.type != pyrogram.enums.ChatType.SUPERGROUP and not ALLOW_CHANNEL:
if message.chat.type != pyrogram.enums.ChatType.SUPERGROUP:
return await message.reply_text(
"This command can be used in supergroups only.",
)
if message.sender_chat and (not TRUST_ANON_ADMINS or ALLOW_CHANNEL):
if message.sender_chat and not TRUST_ANON_ADMINS:
ANON[int(f"{message.chat.id}{message.id}")] = (
message,
func,

View file

@ -22,7 +22,7 @@ __HELP__ = """"
@app.on_message(
filters.incoming & ~filters.private & filters.command(["inkick"], COMMAND_HANDLER)
)
@app.adminsOnly("can_restrict_members", ALLOW_CHANNEL=True)
@app.adminsOnly("can_restrict_members")
async def inkick(_, message):
user = await app.get_chat_member(message.chat.id, message.from_user.id)
if user.status.value in ("administrator", "owner"):
@ -77,7 +77,7 @@ async def inkick(_, message):
@app.on_message(
filters.incoming & ~filters.private & filters.command(["uname"], COMMAND_HANDLER)
)
@app.adminsOnly("can_restrict_members", ALLOW_CHANNEL=True)
@app.adminsOnly("can_restrict_members")
async def uname(_, message):
user = await app.get_chat_member(message.chat.id, message.from_user.id)
if user.status.value in ("administrator", "owner"):
@ -125,7 +125,7 @@ async def uname(_, message):
& ~filters.private
& filters.command(["ban_ghosts"], COMMAND_HANDLER)
)
@app.adminsOnly("can_restrict_members", ALLOW_CHANNEL=True)
@app.adminsOnly("can_restrict_members")
async def rm_delacc(_, message):
user = await app.get_chat_member(message.chat.id, message.from_user.id)
if user.status.value in ("administrator", "owner"):
@ -168,7 +168,7 @@ async def rm_delacc(_, message):
@app.on_message(
filters.incoming & ~filters.private & filters.command(["instatus"], COMMAND_HANDLER)
)
@app.adminsOnly("can_restrict_members", ALLOW_CHANNEL=True)
@app.adminsOnly("can_restrict_members")
async def instatus(client, message):
bstat = await app.get_chat_member(message.chat.id, client.me.id)
if bstat.status.value != "administrator":