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/warn.py
2022-12-27 18:46:17 +01:00

22 lines
1.3 KiB
Python

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(~ filters.scheduled & custom_filters.admin & 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:
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))
# ==============================================================================================================================