From 3009094caa855fb38ff0452fc33410c0dbd0c99c Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 14 Dec 2022 14:38:04 +0100 Subject: [PATCH] Polisher /warn and /warnings --- modules/commands/warn.py | 4 ++-- modules/commands/warnings.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/commands/warn.py b/modules/commands/warn.py index 6f8d4fe..9d56e63 100644 --- a/modules/commands/warn.py +++ b/modules/commands/warn.py @@ -10,8 +10,8 @@ async def cmd_warn(app, msg): if msg.chat.id == configGet("destination_group"): if msg.reply_to_message_id != None: - if isAnAdmin(msg.from_user.id): - message = " ".join(msg.command[2:]) if len(msg.command) > 1 else "" + if await isAnAdmin(msg.from_user.id): + 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)) diff --git a/modules/commands/warnings.py b/modules/commands/warnings.py index b53e56e..4a6ecda 100644 --- a/modules/commands/warnings.py +++ b/modules/commands/warnings.py @@ -1,23 +1,23 @@ -from os import path, sep from app import app, isAnAdmin from pyrogram import filters from pyrogram.enums.chat_members_filter import ChatMembersFilter from modules.utils import configGet, locale, should_quote -from modules.database import col_warnings +from modules.database import col_users, col_warnings # Warnings command ============================================================================================================= @app.on_message(~ filters.scheduled & filters.command(["warnings"], prefixes=["/"])) async def cmd_warnings(app, msg): - if msg.chat.id == configGet("admin_group") or await isAnAdmin(msg.from_user.id): + if await isAnAdmin(msg.from_user.id): if len(msg.command) <= 1: await msg.reply_text(locale("syntax_warnings", "message"), quote=should_quote(msg)) - if path.exists(f"{configGet('data', 'locations')}{sep}users{sep}{msg.command[1]}.json"): - target_id = str(int(msg.command[1])) - target_name = "N/A" - else: + try: + user_db = col_users.find_one({"user": int(msg.command[1])}) + target_id = user_db["user"] + target_name = user_db["tg_name"] + except: list_of_users = [] async for m in app.get_chat_members(configGet("destination_group"), filter=ChatMembersFilter.SEARCH, query=msg.command[1]): list_of_users.append(m)