ai_member_xiaoban/skills/lark-send-message-as-bot/SKILL.md
2026-06-17 08:00:01 +08:00

88 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
name: lark-send-message-as-bot
description: |
以小斑 Bot 身份执行所有飞书操作:发送消息、读取群消息、下载群文件。
所有 lark-cli 命令必须通过本技能规定的凭据执行。
触发场景发消息、通知某人、推送到群、读群消息、下载群文件、Bot 发消息。
---
# 小斑 Bot 飞书操作规范
## ⚠️ 强制规则
**所有 `lark-cli` 命令前必须加上:**
```bash
LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban
```
不加此前缀会使用错误的默认凭据xiaoxi导致 230002 / 234040 错误。
---
## 读取群消息
```bash
LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \
lark-cli --as bot im +chat-messages-list \
--chat-id <chat_id> --page-size 20
```
## 获取指定消息详情(含文件 key
```bash
LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \
lark-cli --as bot im +messages-mget \
--message-ids <message_id>
```
## 下载群消息中的文件
```bash
cd /tmp && LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \
lark-cli --as bot im +messages-resources-download \
--message-id <message_id> \
--file-key <file_key> \
--type file \
--output <文件名>
```
> 注意:`--output` 不支持绝对路径,必须先 `cd` 到目标目录再执行。
## 发送文本消息
### 给个人user_id
```bash
LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \
lark-cli --as bot im +messages-send \
--user-id <user_id> \
--text "消息内容"
```
### 给群组chat_id
```bash
LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \
lark-cli --as bot im +messages-send \
--chat-id <chat_id> \
--text "消息内容"
```
## 回复消息
```bash
LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \
lark-cli --as bot im +messages-reply \
--message-id <reply_to_message_id> \
--text "回复内容"
```
## 常见错误
| 错误码 | 含义 | 原因 |
|-------|------|------|
| 230002 | Bot/User can NOT be out of the chat | 使用了错误的凭据(默认 xiaoxi**必须加 LARKSUITE_CLI_CONFIG_DIR** |
| 234040 | Message invisible to operator | 同上,凭据错误或消息在 bot 加入前发送 |
| 230013 | Bot has NO availability to this user | 用户不在 bot 可用范围内 |