Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/openclaw_feishu_cron_kit/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 40 additions & 2 deletions src/openclaw_feishu_cron_kit/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,44 @@ 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,
}
}
}


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'<at id="{open_id}"></at>')
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)}