/label command improved

This commit is contained in:
Profitroll 2022-12-11 01:31:30 +01:00
parent 9c611b436c
commit 32ebad29ca

View File

@ -1,10 +1,14 @@
from app import app from app import app, isAnAdmin
from pyrogram import filters 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=["/"])) @app.on_message(~ filters.scheduled & filters.private & filters.command(["label"], prefixes=["/"]))
async def cmd_label(app, msg): async def cmd_label(app, msg):
if msg.chat.id == configGet("admin_group") or await isAnAdmin(msg.from_user.id):
if len(msg.command) < 3: if len(msg.command) < 3:
await msg.reply_text("Invalid syntax:\n`/label USER NICKNAME`") await msg.reply_text("Invalid syntax:\n`/label USER NICKNAME`")
return return
@ -13,7 +17,16 @@ async def cmd_label(app, msg):
if target is not None: if target is not None:
target = HoloUser(target)
nickname = " ".join(msg.command[2:]) 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)) await msg.reply_text(f"Setting **{target.id}**'s label to **{nickname}**...", quote=should_quote(msg))
else: else: