From e0ed44388f161d7d661a4be7a5cf6779e49193f7 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Sun, 22 Feb 2026 17:28:52 -0800 Subject: [PATCH] fix: improve error messaging for chat ID and home channel configuration - Enhanced warning in `_deliver_result` to provide clearer instructions for setting the home channel. - Updated error message in `send_message_tool` to specify how to set a home channel when no chat ID is provided, improving user guidance. --- cron/scheduler.py | 2 +- tools/send_message_tool.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cron/scheduler.py b/cron/scheduler.py index 2a6effa23e..4545288ce5 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -73,7 +73,7 @@ def _deliver_result(job: dict, content: str) -> None: # Fall back to home channel chat_id = os.getenv(f"{platform_name.upper()}_HOME_CHANNEL", "") if not chat_id: - logger.warning("Job '%s' deliver=%s but no chat_id or home channel", job["id"], deliver) + logger.warning("Job '%s' deliver=%s but no chat_id or home channel. Set via: hermes config set %s_HOME_CHANNEL ", job["id"], deliver, platform_name.upper()) return from tools.send_message_tool import _send_to_platform diff --git a/tools/send_message_tool.py b/tools/send_message_tool.py index 795b3b97d6..efe9880ccd 100644 --- a/tools/send_message_tool.py +++ b/tools/send_message_tool.py @@ -68,16 +68,20 @@ def send_message_tool(args, **kw): if not pconfig or not pconfig.enabled: return json.dumps({"error": f"Platform '{platform_name}' is not configured. Set up credentials in ~/.hermes/gateway.json or environment variables."}) + used_home_channel = False if not chat_id: home = config.get_home_channel(platform) if home: chat_id = home.chat_id + used_home_channel = True else: - return json.dumps({"error": f"No chat_id specified and no home channel configured for {platform_name}. Use format 'platform:chat_id'."}) + return json.dumps({"error": f"No home channel set for {platform_name} to determine where to send the message. Either specify a channel directly with '{platform_name}:CHANNEL_ID', or set a home channel via: hermes config set {platform_name.upper()}_HOME_CHANNEL "}) try: from model_tools import _run_async result = _run_async(_send_to_platform(platform, pconfig, chat_id, message)) + if used_home_channel and isinstance(result, dict) and result.get("success"): + result["note"] = f"Sent to {platform_name} home channel (chat_id: {chat_id})" return json.dumps(result) except Exception as e: return json.dumps({"error": f"Send failed: {e}"})