Telegram/modules/commands/label.py

32 lines
1.1 KiB
Python

from app import app, isAnAdmin
from pyrogram import filters
from modules.utils import should_quote, find_user
from classes.holo_user import HoloUser
@app.on_message(~ filters.scheduled & filters.private & filters.command(["label"], prefixes=["/"]))
async def cmd_label(app, msg):
if await isAnAdmin(msg.from_user.id) is True:
if len(msg.command) < 3:
await msg.reply_text("Invalid syntax:\n`/label USER LABEL`")
return
target = await find_user(app, msg.command[1])
if target is not None:
target = HoloUser(target)
label = " ".join(msg.command[2:])
if label.lower() == "reset":
await target.reset_label(msg.chat)
await msg.reply_text(f"Resetting **{target.id}**'s label...", quote=should_quote(msg))
else:
await target.set_label(msg.chat, label)
await msg.reply_text(f"Setting **{target.id}**'s label to **{label}**...", quote=should_quote(msg))
else:
await msg.reply_text(f"User not found")