- Created new logging infrastructure with per-component filtering - Added 6 log levels: DEBUG, INFO, API, WARNING, ERROR, CRITICAL - Implemented non-hierarchical level control (any combination can be enabled) - Migrated 917 print() statements across 31 files to structured logging - Created web UI (system.html) for runtime configuration with dark theme - Added global level controls to enable/disable levels across all components - Added timestamp format control (off/time/date/datetime options) - Implemented log rotation (10MB per file, 5 backups) - Added API endpoints for dynamic log configuration - Configured HTTP request logging with filtering via api.requests component - Intercepted APScheduler logs with proper formatting - Fixed persistence paths to use /app/memory for Docker volume compatibility - Fixed checkbox display bug in web UI (enabled_levels now properly shown) - Changed System Settings button to open in same tab instead of new window Components: bot, api, api.requests, autonomous, persona, vision, llm, conversation, mood, dm, scheduled, gpu, media, server, commands, sentiment, core, apscheduler All settings persist across container restarts via JSON config.
67 lines
2.0 KiB
Python
67 lines
2.0 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.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):
|
|
globals.conversation_history[str(user_id)].clear()
|
|
|
|
|
|
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
|