SuperAPI AI 工具集

feishu-lark-agent

办公与效率

查看项目

更新于 10-15 15:39

技能介绍

用途

feishu-lark-agent 是一个面向飞书/Lark 的命令行操作 Agent 技能。它通过运行本地的 Python 脚本 feishu.py,以“分类 + 动作 + 参数”的方式对飞书中的消息、用户、文档、多维表格、日历和任务进行读写操作,适合用命令行或自动化脚本统一处理飞书协作事务。

主要能力

按资料,该技能覆盖以下分类与动作:

  • 消息 msg:发送文本消息、回复消息、查询会话历史、搜索消息、列出所有群聊。
  • 用户 user:按姓名模糊搜索用户、按邮箱或 open_id 精确查询用户。
  • 文档 doc:创建文档(可写入 markdown 内容或从文件读取)、按 document_id 获取文档、列出文档。
  • 多维表格 table:列出所有 table、查询字段、查询记录、新增记录、更新记录、删除记录。
  • 日历 cal:列出可访问日历、查询指定日历在某时间段内的事件、新增日程、删除日程。
  • 任务 task:列出任务、新增任务、完成任务、删除任务。

使用方式

运行方式:先加载环境变量,再执行脚本。

source ~/.zshrc && python3 ~/.claude/skills/feishu-lark-agent/feishu.py <category> <action> [--key value ...]

资料给出的 ID 格式要点:

  • ou_ 前缀为 open_id,用于 --to;
  • oc_ 前缀为 chat_id,用于 --chat;
  • 邮箱用于 --email,会自动解析为 open_id;
  • 文档 URL 中 docx/xxx 的后半段为 document_id;
  • 多维表格 URL 中 base/xxx 的后半段为 app_token。

如果只有姓名,可先执行 user search --name "张三" 获取 open_id,再执行目标操作。

常用命令示例(摘自资料):

  • 消息:
msg send  --to <open_id|chat_id>   --text "..."
msg send  --email <email>          --text "..."
msg send  --chat <chat_id>         --text "..."
msg send  --to <open_id>           --file /path
msg reply --to <message_id>        --text "..."
msg history --chat <chat_id>      [--limit 20]
msg search  --query "关键词"       [--limit 20]
msg chats  [--limit 50]
  • 用户:
user search --name "张三"
user get    --email <email>
user get    --id <open_id>
  • 文档:
doc create  --title "标题"  [--content "markdown内容"]  [--file /path.md]
doc get     --id <document_id>
doc list   [--folder <token>]     [--limit 50]

资料说明创建后会自动授权 FEISHU_OWNER_OPEN_ID 编辑权限。

  • 多维表格:
table tables  --app <token>
table fields  --app <token>  --table <id>
table records --app <token>  --table <id>  [--filter 'AND(CurrentValue.[状态]="进行中")']  [--limit 100]
table add     --app <token>  --table <id>  --data '{"字段名":"值"}'
table update  --app <token>  --table <id>  --record <recXXX>  --data '{"字段名":"新值"}'
table delete  --app <token>  --table <id>  --record <recXXX>
  • 日历:
cal calendars
cal list   --calendar <cal_id>   [--days 7]
cal add    --calendar <cal_id>   --title "..." --start "YYYY-MM-DD HH:MM" --end "YYYY-MM-DD HH:MM"  [--location "..."]  [--attendees "a@x.com,b@x.com"]
cal delete --calendar <cal_id>   --id <event_id>
  • 任务:
task list  [--completed true]  [--limit 50]
task add   --title "..."  [--due "YYYY-MM-DD"]  [--note "..."]
task done  --id <task_guid>
task delete --id <task_guid>

适用场景

资料给出的高频场景包括:按姓名发消息(先 user search 获取 open_id,再 msg send)、给群发消息(先 msg chats 找到 chat_id,再 msg send --chat)、向多维表格添加记录(先 table fields 查字段避免字段名写错,再 table add)、创建文档并写入内容(doc create 配合 --content 或 --file)、查看近期日程(先 cal calendars 获取日历 ID,再 cal list)、创建日程(先 cal calendars 获取 cal_id,再 cal add)。

限制与注意事项

资料明确列出以下限制:

  • 日历方面:Bot 无法访问个人日历(primary 会报错),必须先 cal calendars 获取 Bot 自己的日历 ID,再用该 ID 操作。
  • 添加多维表格记录前建议先查字段,避免字段名写错。
  • 只有姓名时需先搜索获取 open_id。

错误速查(资料提供):

  • 99991671:权限未开通,需在飞书开放平台添加权限。
  • 230006:日历权限缺失,需开通 calendar:calendar。
  • 1254043:Bitable 未找到,检查 URL 中的 app_token。
  • 191001:日历 ID 错误,不能用 primary,需用真实 cal_id。
  • Missing FEISHU_APP_ID:环境变量未加载,需 source ~/.zshrc。

关于收费、价格、平台支持范围以及其他未在资料中出现的信息,暂未提供。