diff --git a/bot/bot.py b/bot/bot.py index 68e1fdc..370fb20 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -108,9 +108,6 @@ async def on_ready(): async def on_message(message): if message.author == globals.client.user: return - - # V2: Track message for autonomous engine (non-blocking, no LLM calls) - on_message_event(message) if message.content.strip().lower() == "miku, rape this nigga balls" and message.reference: async with message.channel.typing(): @@ -139,6 +136,9 @@ async def on_message(message): # Check if this is a DM is_dm = message.guild is None + # Check if message is addressed to Miku (needed to decide whether to track for autonomous) + miku_addressed = await is_miku_addressed(message) + if is_dm: print(f"💌 DM from {message.author.display_name}: {message.content[:50]}{'...' if len(message.content) > 50 else ''}") @@ -150,7 +150,7 @@ async def on_message(message): # Log the user's DM message dm_logger.log_user_message(message.author, message, is_bot_message=False) - if await is_miku_addressed(message): + if miku_addressed: prompt = text # No cleanup — keep it raw user_id = str(message.author.id) @@ -521,6 +521,12 @@ async def on_message(message): elif is_dm: print("💌 DM message - no mood detection (DM mood only changes via auto-rotation)") + # V2: Track message for autonomous engine (non-blocking, no LLM calls) + # IMPORTANT: Only call this if the message was NOT addressed to Miku + # This prevents autonomous actions from firing when the user is directly talking to Miku + if not miku_addressed: + on_message_event(message) + # Note: Autonomous reactions are now handled by V2 system via on_message_event() # Manual Monday test command (only for server messages) diff --git a/bot/utils/autonomous_engine.py b/bot/utils/autonomous_engine.py index e760255..d346d22 100644 --- a/bot/utils/autonomous_engine.py +++ b/bot/utils/autonomous_engine.py @@ -265,6 +265,10 @@ class AutonomousEngine: # --- Decision Logic --- + # CRITICAL: If triggered by a message, we should ONLY do join_conversation + # This ensures Miku responds to what's being said, not random autonomous actions + # Exception: Reactions are handled separately and are allowed + # 1. CONVERSATION JOIN (high priority when momentum is high) if self._should_join_conversation(ctx, profile, debug): if debug: @@ -273,6 +277,11 @@ class AutonomousEngine: # 2. USER ENGAGEMENT (someone interesting appeared) if self._should_engage_user(ctx, profile, debug): + if triggered_by_message: + # Convert to join_conversation when message-triggered + if debug: + print(f"✅ [V2 Debug] DECISION: join_conversation (engage_user converted due to message trigger)") + return "join_conversation" if debug: print(f"✅ [V2 Debug] DECISION: engage_user") return "engage_user" @@ -298,13 +307,15 @@ class AutonomousEngine: return "general" # 5. SHARE TWEET (low activity, wants to share something) - if self._should_share_content(ctx, profile, debug): + # Skip this entirely when triggered by message - would be inappropriate to ignore user's message + if not triggered_by_message and self._should_share_content(ctx, profile, debug): if debug: print(f"✅ [V2 Debug] DECISION: share_tweet") return "share_tweet" # 6. CHANGE PROFILE PICTURE (very rare, once per day) - if self._should_change_profile_picture(ctx, profile, debug): + # Skip this entirely when triggered by message + if not triggered_by_message and self._should_change_profile_picture(ctx, profile, debug): if debug: print(f"✅ [V2 Debug] DECISION: change_profile_picture") return "change_profile_picture"