From 9503b0124fd600f3422856e4ea119b6f71ab3f91 Mon Sep 17 00:00:00 2001 From: Okk Hex <78189163+okkhex@users.noreply.github.com> Date: Tue, 29 Jul 2025 12:50:22 +0530 Subject: [PATCH 1/2] Add command logging --- pyUltroid/_misc/_decorators.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pyUltroid/_misc/_decorators.py b/pyUltroid/_misc/_decorators.py index 94cea8297..672b07281 100644 --- a/pyUltroid/_misc/_decorators.py +++ b/pyUltroid/_misc/_decorators.py @@ -78,6 +78,21 @@ def ultroid_cmd( def decor(dec): async def wrapp(ult): + command_name = pattern if pattern else ult.text.split()[0].lstrip(HNDLR) + user_id = ult.sender_id + chat_id = ult.chat_id + chat_name = get_display_name(ult.chat) + + LOGS.info(f"Command '{command_name}' executed by user ID {user_id} in chat {chat_id} ({chat_name})") + log_channel = udB.get_key("LOG_CHANNEL") + if log_channel: + try: + await asst.send_message( + log_channel, + f"Command '{command_name}' executed by user ID {user_id} in chat {chat_id} ({chat_name})" + ) + except Exception as e: + LOGS.warning(f"Failed to send command log to log channel {log_channel}: {e}") if not ult.out: if owner_only: return From aacdfbfa310f55900c1e7ad5596433bf61c6b794 Mon Sep 17 00:00:00 2001 From: Devesh Pal Date: Tue, 29 Jul 2025 13:57:02 +0530 Subject: [PATCH 2/2] Update _decorators.py --- pyUltroid/_misc/_decorators.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pyUltroid/_misc/_decorators.py b/pyUltroid/_misc/_decorators.py index 672b07281..af3f8b020 100644 --- a/pyUltroid/_misc/_decorators.py +++ b/pyUltroid/_misc/_decorators.py @@ -78,21 +78,21 @@ def ultroid_cmd( def decor(dec): async def wrapp(ult): - command_name = pattern if pattern else ult.text.split()[0].lstrip(HNDLR) - user_id = ult.sender_id - chat_id = ult.chat_id - chat_name = get_display_name(ult.chat) - - LOGS.info(f"Command '{command_name}' executed by user ID {user_id} in chat {chat_id} ({chat_name})") - log_channel = udB.get_key("LOG_CHANNEL") - if log_channel: - try: - await asst.send_message( - log_channel, - f"Command '{command_name}' executed by user ID {user_id} in chat {chat_id} ({chat_name})" - ) - except Exception as e: - LOGS.warning(f"Failed to send command log to log channel {log_channel}: {e}") + if udB.get_key("COMMAND_LOGGER"): + user_id = ult.sender_id + chat_id = ult.chat_id + command_name = pattern if pattern else ult.text.split()[0].lstrip(HNDLR) + chat_name = get_display_name(ult.chat) + LOGS.info(f"Command '{command_name}' executed by user ID {user_id} in chat {chat_id} ({chat_name})") + log_channel = udB.get_key("LOG_CHANNEL") + if log_channel: + try: + await asst.send_message( + log_channel, + f"Command '{command_name}' executed by user ID {user_id} in chat {chat_id} ({chat_name})" + ) + except Exception as e: + LOGS.warning(f"Failed to send command log to log channel {log_channel}: {e}") if not ult.out: if owner_only: return