fix: /config/set now syncs all runtime-relevant globals
Previously only 4 of 5+ settings were synced to globals when set via the generic /config/set endpoint. Added: - memory.use_cheshire_cat -> globals.USE_CHESHIRE_CAT - runtime.mood.dm_mood -> globals.DM_MOOD + DM_MOOD_DESCRIPTION - Uses same _GLOBALS_SYNC mapping pattern as restore_runtime_settings
This commit is contained in:
30
bot/api.py
30
bot/api.py
@@ -2978,15 +2978,27 @@ async def set_config_value(request: Request):
|
|||||||
from config_manager import config_manager
|
from config_manager import config_manager
|
||||||
config_manager.set(key_path, value, persist=persist)
|
config_manager.set(key_path, value, persist=persist)
|
||||||
|
|
||||||
# Update globals if needed
|
# ── Sync globals for every runtime-relevant key path ──
|
||||||
if key_path == "discord.language_mode":
|
_GLOBALS_SYNC = {
|
||||||
globals.LANGUAGE_MODE = value
|
"discord.language_mode": ("LANGUAGE_MODE", str),
|
||||||
elif key_path == "autonomous.debug_mode":
|
"autonomous.debug_mode": ("AUTONOMOUS_DEBUG", bool),
|
||||||
globals.AUTONOMOUS_DEBUG = value
|
"voice.debug_mode": ("VOICE_DEBUG_MODE", bool),
|
||||||
elif key_path == "voice.debug_mode":
|
"memory.use_cheshire_cat": ("USE_CHESHIRE_CAT", bool),
|
||||||
globals.VOICE_DEBUG_MODE = value
|
"gpu.prefer_amd": ("PREFER_AMD_GPU", bool),
|
||||||
elif key_path == "gpu.prefer_amd":
|
}
|
||||||
globals.PREFER_AMD_GPU = value
|
|
||||||
|
if key_path in _GLOBALS_SYNC:
|
||||||
|
attr, converter = _GLOBALS_SYNC[key_path]
|
||||||
|
setattr(globals, attr, converter(value))
|
||||||
|
elif key_path == "runtime.mood.dm_mood":
|
||||||
|
# DM mood needs description loaded alongside
|
||||||
|
if isinstance(value, str) and value in getattr(globals, "AVAILABLE_MOODS", []):
|
||||||
|
globals.DM_MOOD = value
|
||||||
|
try:
|
||||||
|
from utils.moods import load_mood_description
|
||||||
|
globals.DM_MOOD_DESCRIPTION = load_mood_description(value)
|
||||||
|
except Exception:
|
||||||
|
globals.DM_MOOD_DESCRIPTION = f"I'm feeling {value} today."
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
|
|||||||
Reference in New Issue
Block a user