This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/modules/commands/label.py

32 lines
1.1 KiB
Python
Raw Normal View History

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