From e8f57b976ab6d13c447589c8a6f66c44b543e5bf Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Tue, 25 Feb 2025 20:17:40 -0500 Subject: [PATCH] Update .gitignore to exclude .DS_Store; refactor logging for unauthorized reset attempts and message formatting --- .gitignore | 1 + discord_glhf/handlers/event_handler.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 1979375..43fd364 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ discord_glhf/handlers/event_handler.py discord_glhf/handlers/__pycache__/__init__.cpython-313.pyc discord_glhf/handlers/__pycache__/image_handler.cpython-313.pyc discord_glhf/web/__pycache__/__init__.cpython-313.pyc +.DS_Store diff --git a/discord_glhf/handlers/event_handler.py b/discord_glhf/handlers/event_handler.py index 317d63e..2cb9f88 100644 --- a/discord_glhf/handlers/event_handler.py +++ b/discord_glhf/handlers/event_handler.py @@ -230,11 +230,13 @@ class EventHandler: is_allowed = ( message.author.id in RESET_ALLOWED_USERS or message.author.id == BOT_OWNER_ID or - (hasattr(message.author, 'guild_permissions') and message.author.guild_permissions.administrator) + (hasattr(message.author, 'guild_permissions') + and message.author.guild_permissions.administrator) ) - + if not is_allowed: - logger.warning(f"Unauthorized reset attempt by {message.author.name} ({message.author.id})") + logger.warning( + f"Unauthorized reset attempt by {message.author.name} ({message.author.id})") return try: @@ -242,7 +244,8 @@ class EventHandler: await message.add_reaction("✅") # Clear all messages await self.db_manager.clear_all_messages() - logger.info(f"Personality reset by {message.author.name} ({message.author.id})") + logger.info( + f"Personality reset by {message.author.name} ({message.author.id})") return except Exception as e: logger.error(f"Failed to reset personality: {e}") @@ -280,7 +283,7 @@ class EventHandler: user_id=0, channel_id=message.channel.id ) - current_content = f"{message.author.display_name} ({message.author.name}) (<@{message.author.id}>): {message.content}" + current_content = f"({message.author.name}): {message.content}" for hist_msg in recent_history: hist_content = hist_msg.get("content", {}).get("content", "") if isinstance( hist_msg.get("content"), dict) else hist_msg.get("content", "") @@ -368,7 +371,7 @@ class EventHandler: message_uuid = str(uuid.uuid4()) # Format the message with user info - formatted_content = f"{item.message.author.display_name} ({item.message.author.name}) (<@{item.message.author.id}>): {item.prompt}" + formatted_content = f"({item.message.author.name}): {item.prompt}" # Check if this message is already in history message_in_history = False