from datetime import datetime from app import app 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 from modules import custom_filters # Warn command ================================================================================================================= @app.on_message(custom_filters.enabled_warnings & ~filters.scheduled & filters.command(["warn"], prefixes=["/"]) & custom_filters.admin) async def cmd_warn(app: Client, msg: Message): if msg.chat.id == configGet("users", "groups"): if msg.reply_to_message_id != None: 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)) # ==============================================================================================================================