Merge Beta with Stable releases #1
@ -1,7 +1,8 @@
|
|||||||
from os import sep
|
from datetime import datetime
|
||||||
from app import app, isAnAdmin
|
from app import app, isAnAdmin
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from modules.utils import jsonLoad, jsonSave, configGet, locale
|
from modules.utils import configGet, locale
|
||||||
|
from modules.database import col_warnings
|
||||||
|
|
||||||
# Warn command =================================================================================================================
|
# Warn command =================================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"]))
|
||||||
@ -10,11 +11,10 @@ async def cmd_warn(app, msg):
|
|||||||
if msg.chat.id == configGet("destination_group"):
|
if msg.chat.id == configGet("destination_group"):
|
||||||
if msg.reply_to_message_id != None:
|
if msg.reply_to_message_id != None:
|
||||||
if isAnAdmin(msg.from_user.id):
|
if isAnAdmin(msg.from_user.id):
|
||||||
warnings = jsonLoad(f"{configGet('data', 'locations')}{sep}warnings.json")
|
message = " ".join(msg.command[2:]) if len(msg.command) > 1 else ""
|
||||||
if str(msg.reply_to_message.from_user.id) not in warnings:
|
col_warnings.insert_one({"user": msg.reply_to_message.from_user.id, "admin": msg.from_user.id, "date": datetime.now(), "reason": message})
|
||||||
warnings[str(msg.reply_to_message.from_user.id)] = 1
|
if message == "":
|
||||||
else:
|
|
||||||
warnings[str(msg.reply_to_message.from_user.id)] += 1
|
|
||||||
jsonSave(warnings, f"{configGet('data', 'locations')}{sep}warnings.json")
|
|
||||||
await msg.reply_text(locale("warned", "message").format(msg.reply_to_message.from_user.first_name, msg.reply_to_message.from_user.id))
|
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))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
Reference in New Issue
Block a user