Remove legacy globals.conversation_history (defaultdict of deques) and
route all callers through utils.conversation_history.ConversationHistory:
- globals.py: remove conversation_history + unused collections imports
- llm.py: remove backward-compat dual-write to legacy system
- api.py: /conversation/{user_id} now reads from ConversationHistory
- actions.py: reset_conversation uses clear_channel()
- figurine_notifier.py: use add_message() instead of buggy setdefault()
- bipolar_mode.py: fix clear_history -> clear_channel (was AttributeError
silently swallowed by bare except), fix bare except -> except Exception
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
# commands/actions.py
|
|
import os
|
|
import asyncio
|
|
import globals
|
|
from utils.moods import load_mood_description
|
|
from utils.scheduled import send_bedtime_reminder
|
|
from utils.conversation_history import conversation_history
|
|
from utils.logger import get_logger
|
|
|
|
logger = get_logger('commands')
|
|
|
|
|
|
def set_mood(new_mood: str) -> bool:
|
|
"""Set mood (legacy function - now handled per-server or DM)"""
|
|
logger.warning("set_mood called - this function is deprecated. Use server-specific mood endpoints instead.")
|
|
return False
|
|
|
|
|
|
def reset_mood() -> str:
|
|
"""Reset mood to neutral (legacy function - now handled per-server or DM)"""
|
|
logger.warning("reset_mood called - this function is deprecated. Use server-specific mood endpoints instead.")
|
|
return "neutral"
|
|
|
|
|
|
def check_mood():
|
|
return globals.DM_MOOD
|
|
|
|
|
|
def calm_miku() -> str:
|
|
"""Calm Miku down (legacy function - now handled per-server or DM)"""
|
|
logger.warning("calm_miku called - this function is deprecated. Use server-specific mood endpoints instead.")
|
|
return "neutral"
|
|
|
|
|
|
def reset_conversation(user_id):
|
|
conversation_history.clear_channel(str(user_id))
|
|
|
|
|
|
async def force_sleep() -> str:
|
|
"""Force Miku to sleep (legacy function - now handled per-server or DM)"""
|
|
logger.warning("force_sleep called - this function is deprecated. Use server-specific mood endpoints instead.")
|
|
return "asleep"
|
|
|
|
|
|
async def wake_up(set_sleep_state=None):
|
|
reset_mood()
|
|
# Note: DMs don't have sleep states, so this is deprecated
|
|
logger.warning("wake_up called - this function is deprecated. Use server-specific mood endpoints instead.")
|
|
|
|
if set_sleep_state:
|
|
await set_sleep_state(False)
|
|
|
|
|
|
async def send_bedtime_now():
|
|
await send_bedtime_reminder()
|
|
|
|
|
|
async def update_profile_picture(mood: str = "neutral"):
|
|
"""Manually trigger a profile picture update"""
|
|
from utils.profile_picture_manager import update_profile_picture
|
|
|
|
try:
|
|
success = await update_profile_picture(globals.client, mood=mood)
|
|
return success
|
|
except Exception as e:
|
|
logger.error(f"Error updating profile picture: {e}")
|
|
return False
|