fix(gateway): persist /sethome home channel to .env across all platforms
_handle_set_home_command wrote FEISHU_HOME_CHANNEL / DISCORD_HOME_CHANNEL / etc. as top-level keys into config.yaml, but load_gateway_config() only reads home channels from env vars. After every gateway restart the home channel was lost — on every platform, not just Feishu. Fix: switch /sethome to save_env_value(), which atomically writes to ~/.hermes/.env and updates the current process env in one shot. The handler builds the env key from platform_name.upper(), so one line change repairs /sethome for every platform that has a HOME_CHANNEL env var. Also widen _EXTRA_ENV_KEYS in hermes_cli/config.py so HOME_CHANNEL and HOME_CHANNEL_NAME for every platform are treated as managed env vars: SIGNAL, SLACK, SMS, DINGTALK, BLUEBUBBLES, FEISHU, WECOM, YUANBAO, plus the missing *_NAME variants for DISCORD/TELEGRAM/MATTERMOST. Closes #16806 Co-authored-by: teknium1 <screenmachine@gmail.com>
This commit is contained in:
@@ -6384,18 +6384,10 @@ class GatewayRunner:
|
||||
|
||||
env_key = f"{platform_name.upper()}_HOME_CHANNEL"
|
||||
|
||||
# Save to config.yaml
|
||||
# Save to .env so it persists across restarts
|
||||
try:
|
||||
import yaml
|
||||
config_path = _hermes_home / 'config.yaml'
|
||||
user_config = {}
|
||||
if config_path.exists():
|
||||
with open(config_path, encoding="utf-8") as f:
|
||||
user_config = yaml.safe_load(f) or {}
|
||||
user_config[env_key] = chat_id
|
||||
atomic_yaml_write(config_path, user_config)
|
||||
# Also set in the current environment so it takes effect immediately
|
||||
os.environ[env_key] = str(chat_id)
|
||||
from hermes_cli.config import save_env_value
|
||||
save_env_value(env_key, str(chat_id))
|
||||
except Exception as e:
|
||||
return f"Failed to save home channel: {e}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user