Fix autonomous logic: prevent actions when user addresses Miku
- Moved on_message_event() call to END of message processing in bot.py - Only track messages for autonomous when NOT addressed to Miku - Fixed autonomous_engine.py to convert all message-triggered actions to join_conversation - Prevent inappropriate autonomous actions (general, share_tweet, change_profile_picture) when triggered by user messages - Ensures Miku responds to user messages FIRST before any autonomous action fires This fixes the issue where autonomous actions would fire before Miku's response to user messages, and ensures the 'detect and join conversation' safeguard works properly.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user