From 49f7ea683505d7d42c25223ff02057f103c385ab Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Mon, 23 Oct 2023 23:21:46 +0700 Subject: [PATCH] Tes fix perm for channel Signed-off-by: Yasir Aris M --- misskaty/core/misskaty_patch/decorators/adminsOnly.py | 3 ++- misskaty/plugins/inkick_user.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/misskaty/core/misskaty_patch/decorators/adminsOnly.py b/misskaty/core/misskaty_patch/decorators/adminsOnly.py index 2a6e6542be..442cb6e5e6 100644 --- a/misskaty/core/misskaty_patch/decorators/adminsOnly.py +++ b/misskaty/core/misskaty_patch/decorators/adminsOnly.py @@ -116,6 +116,7 @@ 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` @@ -148,7 +149,7 @@ async def decorator(client, message): return await message.reply_text( "This command can be used in supergroups only.", ) - if message.sender_chat and not TRUST_ANON_ADMINS: + if message.sender_chat and (not TRUST_ANON_ADMINS or ALLOW_CHANNEL): ANON[int(f"{message.chat.id}{message.id}")] = ( message, func, diff --git a/misskaty/plugins/inkick_user.py b/misskaty/plugins/inkick_user.py index f7f6e852f2..695226ed77 100644 --- a/misskaty/plugins/inkick_user.py +++ b/misskaty/plugins/inkick_user.py @@ -22,7 +22,7 @@ @app.on_message( filters.incoming & ~filters.private & filters.command(["inkick"], COMMAND_HANDLER) ) -@app.adminsOnly("can_restrict_members") +@app.adminsOnly("can_restrict_members", ALLOW_CHANNEL=True) 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") +@app.adminsOnly("can_restrict_members", ALLOW_CHANNEL=True) 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") +@app.adminsOnly("can_restrict_members", ALLOW_CHANNEL=True) 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") +@app.adminsOnly("can_restrict_members", ALLOW_CHANNEL=True) async def instatus(client, message): bstat = await app.get_chat_member(message.chat.id, client.me.id) if bstat.status.value != "administrator":