From 2721f5c7015b47ffa4f28a7d036be565c29d9b68 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 1 Feb 2022 04:01:57 +0700 Subject: [PATCH] add handler must unban the user from the chat after un-gbanned --- program/punishment.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/program/punishment.py b/program/punishment.py index ae3129f..85fe946 100644 --- a/program/punishment.py +++ b/program/punishment.py @@ -126,6 +126,7 @@ async def global_banned(c: Client, message: Message): @Client.on_message(command(["ungban", f"ungban@{bn}"]) & ~filters.edited) @sudo_users_only async def ungban_global(c: Client, message: Message): + chat_id = message.chat.id if not message.reply_to_message: if len(message.command) != 2: await message.reply_text( @@ -147,10 +148,11 @@ async def ungban_global(c: Client, message: Message): else: is_gbanned = await is_gbanned_user(user.id) if not is_gbanned: - await message.reply_text("This user already ungbanned.") + await message.reply_text("This user not ungbanned !") else: + await c.unban_chat_member(chat_id, user.id) await remove_gban_user(user.id) - await message.reply_text("✅ This user has ungbanned.") + await message.reply_text("✅ This user has ungbanned") return from_user_id = message.from_user.id user_id = message.reply_to_message.from_user.id @@ -167,7 +169,8 @@ async def ungban_global(c: Client, message: Message): else: is_gbanned = await is_gbanned_user(user_id) if not is_gbanned: - await message.reply_text("This user already un-gbanned") + await message.reply_text("This user not gbanned !") else: + await c.unban_chat_member(chat_id, user_id) await remove_gban_user(user_id) - await message.reply_text("✅ This user has ungbanned.") + await message.reply_text("✅ This user has ungbanned")