From 6914552bdf230fde89988f9eb21c03bfda7801b4 Mon Sep 17 00:00:00 2001 From: Joe-rq <1351653049@qq.com> Date: Wed, 11 Mar 2026 08:41:42 +0800 Subject: [PATCH 1/2] fix: build_summary_post returns incorrect format for Feishu reply API The function was returning: {"title": ..., "content": ...} But Feishu reply API requires post type to be wrapped in zh_cn: {"post": {"zh_cn": {"title": ..., "content": ...}}} This fixes the 'content format of the post type is incorrect' error (code 230001) when sending summary replies in thread mode. --- src/openclaw_feishu_cron_kit/renderer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/openclaw_feishu_cron_kit/renderer.py b/src/openclaw_feishu_cron_kit/renderer.py index 1fac2f4..141309f 100644 --- a/src/openclaw_feishu_cron_kit/renderer.py +++ b/src/openclaw_feishu_cron_kit/renderer.py @@ -111,6 +111,10 @@ def build_summary_post(thread_title: str, summary_data: dict[str, Any]) -> dict[ content.append([{"tag": "text", "text": footer}]) return { - "title": f"{thread_title} · 最新摘要", - "content": content, + "post": { + "zh_cn": { + "title": f"{thread_title} · 最新摘要", + "content": content, + } + } } From 4a1a2f56d16ad49d87629bc66032b03b0ce489fb Mon Sep 17 00:00:00 2001 From: Joe-rq <1351653049@qq.com> Date: Wed, 11 Mar 2026 10:24:08 +0800 Subject: [PATCH 2/2] fix: support text channel for summary reply and fix root_message_id extraction --- src/openclaw_feishu_cron_kit/core.py | 16 +++++++++-- src/openclaw_feishu_cron_kit/renderer.py | 34 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/openclaw_feishu_cron_kit/core.py b/src/openclaw_feishu_cron_kit/core.py index 81da22b..f79eb8d 100644 --- a/src/openclaw_feishu_cron_kit/core.py +++ b/src/openclaw_feishu_cron_kit/core.py @@ -464,8 +464,20 @@ def maybe_send_thread_summary_reply(settings: AppSettings, access_token: str, th root_message_id = ((response_meta or {}).get("data") or {}).get("root_id") or ((response_meta or {}).get("data") or {}).get("message_id") if not root_message_id: raise ValueError("未能解析 root_message_id,无法发送摘要 reply") - content = build_summary_post(thread_options["title"], summary_data) - return reply_message_request(access_token, root_message_id, "post", content, "群话题摘要回复") + # 根据模板配置决定使用 post 还是 text + summary_config = (thread_options or {}).get("summary_reply") or {} + channel = summary_config.get("channel", "post") + + if channel == "text": + # 使用 text 类型 + from .renderer import build_summary_text + content = build_summary_text(summary_data) + return reply_message_request(access_token, root_message_id, "text", content, "群话题摘要回复") + else: + # 默认使用 post 类型 + from .renderer import build_summary_post + content = build_summary_post(thread_options["title"], summary_data) + return reply_message_request(access_token, root_message_id, "post", content, "群话题摘要回复") def load_retry_record(settings: AppSettings, record_id: str) -> dict[str, Any] | None: diff --git a/src/openclaw_feishu_cron_kit/renderer.py b/src/openclaw_feishu_cron_kit/renderer.py index 141309f..669906e 100644 --- a/src/openclaw_feishu_cron_kit/renderer.py +++ b/src/openclaw_feishu_cron_kit/renderer.py @@ -118,3 +118,37 @@ def build_summary_post(thread_title: str, summary_data: dict[str, Any]) -> dict[ } } } + + +def build_summary_text(summary_data: dict[str, Any]) -> dict[str, Any]: + """生成纯文本格式的摘要(用于 reply)""" + notice = summary_data.get("notice", "") + bullets = summary_data.get("bullets", []) + footer = summary_data.get("footer", "") + mention_open_ids = summary_data.get("mention_open_ids") or [] + + # 构建文本内容 + lines = [] + + # 添加 @ 人员和通知 + mention_parts = [] + for open_id in mention_open_ids: + mention_parts.append(f'') + if mention_parts: + lines.append("".join(mention_parts) + " " + notice) + else: + lines.append(notice) + + lines.append("") + lines.append("【摘要】") + + # 添加要点 + for bullet in bullets: + lines.append(f"- {bullet}") + + # 添加 footer + if footer: + lines.append("") + lines.append(footer) + + return {"text": "\n".join(lines)}