2022-12-14 15:31:15 +02:00
|
|
|
from datetime import datetime
|
2022-12-27 19:46:17 +02:00
|
|
|
from app import app
|
2022-12-05 19:49:51 +02:00
|
|
|
from pyrogram import filters
|
2022-12-27 14:36:54 +02:00
|
|
|
from pyrogram.types import Message
|
|
|
|
from pyrogram.client import Client
|
2022-12-14 15:31:15 +02:00
|
|
|
from modules.utils import configGet, locale
|
|
|
|
from modules.database import col_warnings
|
2022-12-27 19:46:17 +02:00
|
|
|
from modules import custom_filters
|
2022-12-05 19:49:51 +02:00
|
|
|
|
|
|
|
# Warn command =================================================================================================================
|
2023-01-03 21:34:13 +02:00
|
|
|
@app.on_message(custom_filters.enabled_warnings & ~filters.scheduled & filters.command(["warn"], prefixes=["/"]) & custom_filters.admin)
|
2022-12-27 14:36:54 +02:00
|
|
|
async def cmd_warn(app: Client, msg: Message):
|
2022-12-05 19:49:51 +02:00
|
|
|
|
|
|
|
if msg.chat.id == configGet("destination_group"):
|
|
|
|
if msg.reply_to_message_id != None:
|
2022-12-27 19:46:17 +02:00
|
|
|
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))
|
2022-12-05 19:49:51 +02:00
|
|
|
# ==============================================================================================================================
|