fix(config): persist runtime settings across bot restarts

Add restore_runtime_settings() to ConfigManager that reads config_runtime.yaml
on startup and restores persisted values into globals:
- LANGUAGE_MODE, AUTONOMOUS_DEBUG, VOICE_DEBUG_MODE
- USE_CHESHIRE_CAT, PREFER_AMD_GPU, DM_MOOD

Add missing persistence calls to API endpoints:
- POST /language/set now persists to config_runtime.yaml
- POST /voice/debug-mode now persists to config_runtime.yaml
- POST /memory/toggle now persists to config_runtime.yaml

Call restore_runtime_settings() in on_ready() after evil/bipolar restore.

Resolves #22
This commit is contained in:
2026-02-18 12:18:12 +02:00
parent 8d5137046c
commit d44f08af18
3 changed files with 75 additions and 0 deletions

View File

@@ -307,6 +307,13 @@ def set_language_mode(language: str = "english"):
model_used = globals.JAPANESE_TEXT_MODEL if language.lower() == "japanese" else globals.TEXT_MODEL
logger.info(f"Language mode set to {language.lower()} (using {model_used})")
# Persist so it survives restarts
try:
from config_manager import config_manager
config_manager.set("discord.language_mode", language.lower(), persist=True)
except Exception:
pass
return {
"status": "ok",
"language_mode": language.lower(),
@@ -2963,6 +2970,14 @@ def set_voice_debug_mode(enabled: bool = Form(...)):
"""Set voice debug mode (shows transcriptions and responses in text channel)"""
globals.VOICE_DEBUG_MODE = enabled
logger.info(f"Voice debug mode set to: {enabled}")
# Persist so it survives restarts
try:
from config_manager import config_manager
config_manager.set("voice.debug_mode", enabled, persist=True)
except Exception:
pass
return {
"status": "ok",
"debug_mode": enabled,
@@ -3004,6 +3019,14 @@ async def toggle_cat_integration(enabled: bool = Form(...)):
"""Toggle Cheshire Cat integration on/off."""
globals.USE_CHESHIRE_CAT = enabled
logger.info(f"🐱 Cheshire Cat integration {'ENABLED' if enabled else 'DISABLED'}")
# Persist so it survives restarts
try:
from config_manager import config_manager
config_manager.set("memory.use_cheshire_cat", enabled, persist=True)
except Exception:
pass
return {
"success": True,
"enabled": globals.USE_CHESHIRE_CAT,