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

33 lines
1.2 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-11 02:31:30 +02:00
from pyrogram.types import ChatPrivileges
from modules.utils import should_quote, find_user, configGet
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-11 02:31:30 +02:00
if msg.chat.id == configGet("admin_group") or await isAnAdmin(msg.from_user.id):
2022-12-10 18:29:06 +02:00
2022-12-11 02:31:30 +02:00
if len(msg.command) < 3:
await msg.reply_text("Invalid syntax:\n`/label USER NICKNAME`")
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-11 02:31:30 +02:00
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")