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

22 lines
1.3 KiB
Python
Raw Normal View History

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 =================================================================================================================
2022-12-27 19:46:17 +02:00
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.command(["warn"], prefixes=["/"]))
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
# ==============================================================================================================================