From 32ebad29ca2820061959368f56afc61e3fb420ac Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Sun, 11 Dec 2022 01:31:30 +0100 Subject: [PATCH] /label command improved --- modules/commands/label.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/modules/commands/label.py b/modules/commands/label.py index 4ad5093..c9ab761 100644 --- a/modules/commands/label.py +++ b/modules/commands/label.py @@ -1,20 +1,33 @@ -from app import app +from app import app, isAnAdmin from pyrogram import filters -from modules.utils import should_quote, find_user +from pyrogram.types import ChatPrivileges +from modules.utils import should_quote, find_user, configGet +from classes.holo_user import HoloUser @app.on_message(~ filters.scheduled & filters.private & filters.command(["label"], prefixes=["/"])) async def cmd_label(app, msg): - if len(msg.command) < 3: - await msg.reply_text("Invalid syntax:\n`/label USER NICKNAME`") - return + if msg.chat.id == configGet("admin_group") or await isAnAdmin(msg.from_user.id): - target = await find_user(app, msg.command[1]) + if len(msg.command) < 3: + await msg.reply_text("Invalid syntax:\n`/label USER NICKNAME`") + return - if target is not None: + target = await find_user(app, msg.command[1]) - nickname = " ".join(msg.command[2:]) - await msg.reply_text(f"Setting **{target.id}**'s label to **{nickname}**...", quote=should_quote(msg)) + if target is not None: + + target = HoloUser(target) - else: - await msg.reply_text(f"User not found") \ No newline at end of file + nickname = " ".join(msg.command[2:]) + + if nickname.lower() == "reset": + await target.reset_label(app, msg.chat) + await msg.reply_text(f"Resetting **{target.id}**'s label...", quote=should_quote(msg)) + + else: + await target.set_label(app, msg.chat, nickname) + await msg.reply_text(f"Setting **{target.id}**'s label to **{nickname}**...", quote=should_quote(msg)) + + else: + await msg.reply_text(f"User not found") \ No newline at end of file