add handler

must unban the user from the chat after un-gbanned
This commit is contained in:
levina 2022-02-01 04:01:57 +07:00 committed by GitHub
parent a48cf6dacc
commit 2721f5c701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,6 +126,7 @@ async def global_banned(c: Client, message: Message):
@Client.on_message(command(["ungban", f"ungban@{bn}"]) & ~filters.edited) @Client.on_message(command(["ungban", f"ungban@{bn}"]) & ~filters.edited)
@sudo_users_only @sudo_users_only
async def ungban_global(c: Client, message: Message): async def ungban_global(c: Client, message: Message):
chat_id = message.chat.id
if not message.reply_to_message: if not message.reply_to_message:
if len(message.command) != 2: if len(message.command) != 2:
await message.reply_text( await message.reply_text(
@ -147,10 +148,11 @@ async def ungban_global(c: Client, message: Message):
else: else:
is_gbanned = await is_gbanned_user(user.id) is_gbanned = await is_gbanned_user(user.id)
if not is_gbanned: if not is_gbanned:
await message.reply_text("This user already ungbanned.") await message.reply_text("This user not ungbanned !")
else: else:
await c.unban_chat_member(chat_id, user.id)
await remove_gban_user(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 return
from_user_id = message.from_user.id from_user_id = message.from_user.id
user_id = message.reply_to_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: else:
is_gbanned = await is_gbanned_user(user_id) is_gbanned = await is_gbanned_user(user_id)
if not is_gbanned: if not is_gbanned:
await message.reply_text("This user already un-gbanned") await message.reply_text("This user not gbanned !")
else: else:
await c.unban_chat_member(chat_id, user_id)
await remove_gban_user(user_id) await remove_gban_user(user_id)
await message.reply_text("✅ This user has ungbanned.") await message.reply_text("✅ This user has ungbanned")