feat: fix evil mode race conditions, expand moods and PFP detection
bipolar_mode.py: - Replace unsafe globals.EVIL_MODE temporary overrides with force_evil_context parameter to fix async race conditions (3 sites) moods.py: - Add 6 new evil mood emojis: bored, manic, jealous, melancholic, playful_cruel, contemptuous - Refactor rotate_dm_mood() to skip when evil mode active (evil mode has its own independent 2-hour rotation timer) persona_dialogue.py: - Same force_evil_context race condition fix (2 sites) - Fix over-aggressive response cleanup that stripped common words (YES/NO/HIGH) — now uses targeted regex for structural markers only - Update evil mood multipliers to match new mood set profile_picture_context: - Expand PFP detection regex for broader coverage (appearance questions, opinion queries, selection/change questions) - Add plugin.json metadata file
This commit is contained in:
@@ -883,23 +883,15 @@ async def run_argument(channel: discord.TextChannel, client, trigger_context: st
|
||||
if last_message is None:
|
||||
init_prompt = get_argument_start_prompt(initiator, trigger_context)
|
||||
|
||||
# Temporarily set evil mode for query_llama if initiator is evil
|
||||
original_evil_mode = globals.EVIL_MODE
|
||||
if initiator == "evil":
|
||||
globals.EVIL_MODE = True
|
||||
else:
|
||||
globals.EVIL_MODE = False
|
||||
|
||||
try:
|
||||
initial_message = await query_llama(
|
||||
user_prompt=init_prompt,
|
||||
user_id=argument_user_id,
|
||||
guild_id=guild_id,
|
||||
response_type="autonomous_general",
|
||||
model=globals.EVIL_TEXT_MODEL if initiator == "evil" else globals.TEXT_MODEL
|
||||
)
|
||||
finally:
|
||||
globals.EVIL_MODE = original_evil_mode
|
||||
# Use force_evil_context to avoid race condition with globals.EVIL_MODE
|
||||
initial_message = await query_llama(
|
||||
user_prompt=init_prompt,
|
||||
user_id=argument_user_id,
|
||||
guild_id=guild_id,
|
||||
response_type="autonomous_general",
|
||||
model=globals.EVIL_TEXT_MODEL if initiator == "evil" else globals.TEXT_MODEL,
|
||||
force_evil_context=(initiator == "evil")
|
||||
)
|
||||
|
||||
if not initial_message or initial_message.startswith("Error") or initial_message.startswith("Sorry"):
|
||||
logger.error("Failed to generate initial argument message")
|
||||
@@ -994,23 +986,15 @@ async def run_argument(channel: discord.TextChannel, client, trigger_context: st
|
||||
# Add last message as context
|
||||
response_prompt = f'The other Miku said: "{last_message}"\n\n{end_prompt}'
|
||||
|
||||
# Temporarily set evil mode for query_llama
|
||||
original_evil_mode = globals.EVIL_MODE
|
||||
if winner == "evil":
|
||||
globals.EVIL_MODE = True
|
||||
else:
|
||||
globals.EVIL_MODE = False
|
||||
|
||||
try:
|
||||
final_message = await query_llama(
|
||||
user_prompt=response_prompt,
|
||||
user_id=argument_user_id,
|
||||
guild_id=guild_id,
|
||||
response_type="autonomous_general",
|
||||
model=globals.EVIL_TEXT_MODEL if winner == "evil" else globals.TEXT_MODEL
|
||||
)
|
||||
finally:
|
||||
globals.EVIL_MODE = original_evil_mode
|
||||
# Use force_evil_context to avoid race condition with globals.EVIL_MODE
|
||||
final_message = await query_llama(
|
||||
user_prompt=response_prompt,
|
||||
user_id=argument_user_id,
|
||||
guild_id=guild_id,
|
||||
response_type="autonomous_general",
|
||||
model=globals.EVIL_TEXT_MODEL if winner == "evil" else globals.TEXT_MODEL,
|
||||
force_evil_context=(winner == "evil")
|
||||
)
|
||||
|
||||
if final_message and not final_message.startswith("Error") and not final_message.startswith("Sorry"):
|
||||
# Send winner's final message via webhook
|
||||
@@ -1059,23 +1043,15 @@ async def run_argument(channel: discord.TextChannel, client, trigger_context: st
|
||||
else:
|
||||
response_prompt = get_miku_argument_prompt(last_message, is_first_response=is_first_response)
|
||||
|
||||
# Temporarily set evil mode for query_llama
|
||||
original_evil_mode = globals.EVIL_MODE
|
||||
if current_speaker == "evil":
|
||||
globals.EVIL_MODE = True
|
||||
else:
|
||||
globals.EVIL_MODE = False
|
||||
|
||||
try:
|
||||
response = await query_llama(
|
||||
user_prompt=response_prompt,
|
||||
user_id=argument_user_id,
|
||||
guild_id=guild_id,
|
||||
response_type="autonomous_general",
|
||||
model=globals.EVIL_TEXT_MODEL if current_speaker == "evil" else globals.TEXT_MODEL
|
||||
)
|
||||
finally:
|
||||
globals.EVIL_MODE = original_evil_mode
|
||||
# Use force_evil_context to avoid race condition with globals.EVIL_MODE
|
||||
response = await query_llama(
|
||||
user_prompt=response_prompt,
|
||||
user_id=argument_user_id,
|
||||
guild_id=guild_id,
|
||||
response_type="autonomous_general",
|
||||
model=globals.EVIL_TEXT_MODEL if current_speaker == "evil" else globals.TEXT_MODEL,
|
||||
force_evil_context=(current_speaker == "evil")
|
||||
)
|
||||
|
||||
if not response or response.startswith("Error") or response.startswith("Sorry"):
|
||||
logger.error(f"Failed to generate argument response")
|
||||
|
||||
Reference in New Issue
Block a user