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:
14
bot/bot.py
14
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)
|
||||
|
||||
Reference in New Issue
Block a user