Compare commits

..

No commits in common. "db36c051d4f75880ad5b8de8ed985e3845008443" and "2b09aaa7b05c434a2cb95c78e486a4b166e62f29" have entirely different histories.

3 changed files with 16 additions and 18 deletions

View File

@ -53,8 +53,7 @@
"reapply_left_chat": "⚠️ **Нагадування**\nЗдається, ти залишив чат у минулому, проте твоя анкета все ще доступна до використання. Подати запит на вступ користуючись старою анкетою?", "reapply_left_chat": "⚠️ **Нагадування**\nЗдається, ти залишив чат у минулому, проте твоя анкета все ще доступна до використання. Подати запит на вступ користуючись старою анкетою?",
"birthday": "У користувача **{0}** (@{1}) сьогодні день народження! Виповнилось {2} років", "birthday": "У користувача **{0}** (@{1}) сьогодні день народження! Виповнилось {2} років",
"application_invalid_syntax": "Неправильний синтаксис!\nТреба: `/application ID/NAME/USERNAME`", "application_invalid_syntax": "Неправильний синтаксис!\nТреба: `/application ID/NAME/USERNAME`",
"warned": "Попереджено **{0}** (`{1}`) про порушення правил", "warned": "Попереджено користувача **{0}** (`{1}`) про порушення правил",
"warned_reason": "Попереджено **{0}** (`{1}`)\n\n**Причина:**\n{2}",
"warnings_1": "Користувач **{0}** (`{1}`) має **{2}** попередження", "warnings_1": "Користувач **{0}** (`{1}`) має **{2}** попередження",
"warnings_2": "Користувач **{0}** (`{1}`) має **{2}** попереджень", "warnings_2": "Користувач **{0}** (`{1}`) має **{2}** попереджень",
"no_warnings": "Користувач **{0}** (`{1}`) не має попереджень", "no_warnings": "Користувач **{0}** (`{1}`) не має попереджень",

View File

@ -1,8 +1,7 @@
from datetime import datetime from os import sep
from app import app, isAnAdmin from app import app, isAnAdmin
from pyrogram import filters from pyrogram import filters
from modules.utils import configGet, locale from modules.utils import jsonLoad, jsonSave, 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=["/"]))
@ -11,10 +10,11 @@ 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):
message = " ".join(msg.command[2:]) if len(msg.command) > 1 else "" warnings = jsonLoad(f"{configGet('data', 'locations')}{sep}warnings.json")
col_warnings.insert_one({"user": msg.reply_to_message.from_user.id, "admin": msg.from_user.id, "date": datetime.now(), "reason": message}) if str(msg.reply_to_message.from_user.id) not in warnings:
if message == "": warnings[str(msg.reply_to_message.from_user.id)] = 1
await msg.reply_text(locale("warned", "message").format(msg.reply_to_message.from_user.first_name, msg.reply_to_message.from_user.id))
else: 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)) 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))
# ============================================================================================================================== # ==============================================================================================================================

View File

@ -2,8 +2,7 @@ from os import path, sep
from app import app, isAnAdmin from app import app, isAnAdmin
from pyrogram import filters from pyrogram import filters
from pyrogram.enums.chat_members_filter import ChatMembersFilter from pyrogram.enums.chat_members_filter import ChatMembersFilter
from modules.utils import configGet, locale, should_quote from modules.utils import configGet, jsonLoad, locale, should_quote
from modules.database import col_warnings
# Warnings command ============================================================================================================= # Warnings command =============================================================================================================
@app.on_message(~ filters.scheduled & filters.command(["warnings"], prefixes=["/"])) @app.on_message(~ filters.scheduled & filters.command(["warnings"], prefixes=["/"]))
@ -11,6 +10,8 @@ async def cmd_warnings(app, msg):
if msg.chat.id == configGet("admin_group") or await isAnAdmin(msg.from_user.id): if msg.chat.id == configGet("admin_group") or await isAnAdmin(msg.from_user.id):
warnings = jsonLoad(f"{configGet('data', 'locations')}{sep}warnings.json")
if len(msg.command) <= 1: if len(msg.command) <= 1:
await msg.reply_text(locale("syntax_warnings", "message"), quote=should_quote(msg)) await msg.reply_text(locale("syntax_warnings", "message"), quote=should_quote(msg))
@ -30,13 +31,11 @@ async def cmd_warnings(app, msg):
await msg.reply_text(locale("no_user_warnings", "message").format(msg.command[1])) await msg.reply_text(locale("no_user_warnings", "message").format(msg.command[1]))
return return
warns = len(list(col_warnings.find({"user": target_id}))) if target_id not in warnings:
if warns == 0:
await msg.reply_text(locale("no_warnings", "message").format(target_name, target_id), quote=should_quote(msg)) await msg.reply_text(locale("no_warnings", "message").format(target_name, target_id), quote=should_quote(msg))
else: else:
if warns <= 5: if warnings[target_id] <= 5:
await msg.reply_text(locale("warnings_1", "message").format(target_name, target_id, warns), quote=should_quote(msg)) await msg.reply_text(locale("warnings_1", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg))
else: else:
await msg.reply_text(locale("warnings_2", "message").format(target_name, target_id, warns), quote=should_quote(msg)) await msg.reply_text(locale("warnings_2", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg))
# ============================================================================================================================== # ==============================================================================================================================