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
|
|
|
|
2023-03-09 17:25:06 +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):
|
2023-01-04 20:59:09 +02:00
|
|
|
if msg.chat.id == configGet("users", "groups"):
|
2022-12-05 19:49:51 +02:00
|
|
|
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 ""
|
2023-03-09 17:25:06 +02:00
|
|
|
col_warnings.insert_one(
|
|
|
|
{
|
|
|
|
"user": msg.reply_to_message.from_user.id,
|
|
|
|
"admin": msg.from_user.id,
|
|
|
|
"date": datetime.now(),
|
|
|
|
"reason": message,
|
2023-04-02 17:44:46 +03:00
|
|
|
"active": True,
|
|
|
|
"revoke_date": None,
|
2023-03-09 17:25:06 +02:00
|
|
|
}
|
|
|
|
)
|
2022-12-27 19:46:17 +02:00
|
|
|
if message == "":
|
2023-03-09 17:25:06 +02:00
|
|
|
await msg.reply_text(
|
|
|
|
locale("warned", "message").format(
|
|
|
|
msg.reply_to_message.from_user.first_name,
|
|
|
|
msg.reply_to_message.from_user.id,
|
|
|
|
)
|
|
|
|
)
|
2022-12-27 19:46:17 +02:00
|
|
|
else:
|
2023-03-09 17:25:06 +02:00
|
|
|
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,
|
|
|
|
)
|
|
|
|
)
|