from datetime import datetime from app import app, isAnAdmin from pyrogram import filters from pyrogram.types import Message from pyrogram.client import Client from modules.utils import configGet, locale from modules.database import col_warnings # Warn command ================================================================================================================= @app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"])) async def cmd_warn(app: Client, msg: Message): if msg.chat.id == configGet("destination_group"): if msg.reply_to_message_id != None: if await isAnAdmin(msg.from_user.id) is True: message = " ".join(msg.command[1:]) if len(msg.command) > 1 else "" col_warnings.insert_one({"user": msg.reply_to_message.from_user.id, "admin": msg.from_user.id, "date": datetime.now(), "reason": message}) if message == "": await msg.reply_text(locale("warned", "message").format(msg.reply_to_message.from_user.first_name, msg.reply_to_message.from_user.id)) else: await msg.reply_text(locale("warned_reason", "message").format(msg.reply_to_message.from_user.first_name, msg.reply_to_message.from_user.id, message)) # ==============================================================================================================================