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

20 lines
1.3 KiB
Python
Raw Normal View History

2022-12-14 15:31:15 +02:00
from datetime import datetime
2022-12-05 19:49:51 +02:00
from app import app, isAnAdmin
from pyrogram import filters
2022-12-14 15:31:15 +02:00
from modules.utils import configGet, locale
from modules.database import col_warnings
2022-12-05 19:49:51 +02:00
# Warn command =================================================================================================================
@app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"]))
async def cmd_warn(app, msg):
if msg.chat.id == configGet("destination_group"):
if msg.reply_to_message_id != None:
2022-12-15 15:31:42 +02:00
if await isAnAdmin(msg.from_user.id) is True:
2022-12-14 15:38:04 +02:00
message = " ".join(msg.command[1:]) if len(msg.command) > 1 else ""
2022-12-14 15:31:15 +02:00
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))
2022-12-05 19:49:51 +02:00
else:
2022-12-14 15:31:15 +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))
2022-12-05 19:49:51 +02:00
# ==============================================================================================================================