--- 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 --page-size 20 ``` ## 获取指定消息详情(含文件 key) ```bash LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \ lark-cli --as bot im +messages-mget \ --message-ids ``` ## 下载群消息中的文件 ```bash cd /tmp && LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \ lark-cli --as bot im +messages-resources-download \ --message-id \ --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 \ --text "消息内容" ``` ### 给群组(chat_id) ```bash LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \ lark-cli --as bot im +messages-send \ --chat-id \ --text "消息内容" ``` ## 回复消息 ```bash LARKSUITE_CLI_CONFIG_DIR=/root/.openclaw/credentials/xiaoban \ lark-cli --as bot im +messages-reply \ --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 可用范围内 |