iluozhiqiang/hermes-aimaxia/feishu-card-fix

Claude Code and agent skill by iluozhiqiang/hermes-aimaxia

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

飞书 interactive card 点击后更新状态、隐藏按钮、保留原始内容 — 包含 SDK bug 绕过方案和 patch 持久化

Install

npx vskill@latest install iluozhiqiang/hermes-aimaxia/feishu-card-fix

SKILL.md

The same SKILL.md was published earlier as iluozhiqiang/hermes-aimaxia/feishu-card-fix.

Feishu Card Fix - 飞书审批卡片点击更新

背景

飞书 interactive card 点击按钮后,需要:

  1. 自动更新卡片状态(标题变 ✅/❌)
  2. 隐藏按钮
  3. 保留原始内容(命令预览 + 原因)

遇到的两个 SDK Bug

Bug 1: WS Client 丢弃 CARD 消息

文件: lark-oapi/ws/client.py 问题: MessageType.CARD 分支直接 return,不执行回调 状态: ⚠️ 官方未修复,SDK 版本 1.5.3 仍有此问题

Bug 2: PATCH API 多传 msg_type

问题: SDK 更新卡片时带 msg_type="interactive",飞书 PATCH API 拒绝 状态: ⚠️ 官方未修复

解决方案

在 feishu.py 的 _on_card_action_trigger 里用 直接 HTTP 请求 绕过 SDK:

python
import requests as _requests
import asyncio, json
# 1. 获取 tenant_access_token
_token_resp = await asyncio.to_thread(
_requests.post,
"https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal",
json={"app_id": self._app_id, "app_secret": self._app_secret},
)
_token = _token_resp.json().get("tenant_access_token", "")
# 2. 直接 PATCH 卡片(不带 msg_type)
payload_str = json.dumps(card, ensure_ascii=False)
_resp = await asyncio.to_thread(
_requests.patch,
f"https://open.feishu.cn/open-apis/im/v1/messages/{message_id}",
headers={
"Authorization": f"Bearer {_token}",
"Content-Type": "application/json",
},
json={"content": payload_str},
)

保留原始内容的改动点

1. _approval_state 多存两个字段
python
self._approval_state[approval_id] = {
"session_key": session_key,
"message_id": result.message_id or "",
"chat_id": chat_id,
"command": command,
"description": description,
}
2. 更新卡片的 elements
python
orig_cmd = (state or {}).get("command", "")
orig_desc = (state or {}).get("description", "")
cmd_preview = orig_cmd[:3000] + "..." if len(orig_cmd) > 3000 else orig_cmd
elements = [
{"tag": "markdown", "content": f"```\n{cmd_preview}\n```\n**Reason:** {orig_desc}"},
{"tag": "markdown", "content": f"{icon} **{label}**"},
]
card = {
"config": {"wide_screen_mode": True},
"header": {"title": {"content": f"{icon} {label}", "tag": "plain_text"}, "template": template},
"elements": elements,
}

Patch 持久化

容器更新后 patch 会丢失,存到持久化目录:

bash
# 生成 patch
cd /opt/hermes && git diff gateway/platforms/feishu.py > /opt/data/patches/feishu_card_fix.patch
# 还原
cd /opt/hermes && patch -p1 < /opt/data/patches/feishu_card_fix.patch

关键文件位置

文件作用
/opt/hermes/gateway/platforms/feishu.py飞书集成主文件
/opt/data/patches/feishu_card_fix.patch改动存档
/opt/data/patches/README.mdpatch 索引

验证方法

bash
grep -n "orig_cmd\|orig_desc" /opt/hermes/gateway/platforms/feishu.py
# 应该看到第 1925-1930 行有这两个变量

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/iluozhiqiang/hermes-aimaxia/feishu-card-fix/badge)](https://verified-skill.com/skills/iluozhiqiang/hermes-aimaxia/feishu-card-fix)

Something wrong with this skill or its page? Tell us.