返回 VideoClaw
feishu.md
1 # 飞书消息发送
2
3 向用户发送图片、视频等媒体文件。
4
5 ## 发送消息
6
7 ```python
8 message(action="send", message="消息内容", target="user_open_id")
9 ```
10
11 ## 发送图片
12
13 ```python
14 message(action="send", filePath="~/.openclaw/workspace/temp_imgs/xxx.png", message="图片描述", target="user_open_id")
15 ```
16
17 ## 发送视频
18
19 ```python
20 message(action="send", filePath="~/.openclaw/workspace/temp_imgs/xxx.mp4", message="视频描述", target="user_open_id")
21 ```
22
23 ## 参数说明
24
25 | 参数 | 说明 |
26 |------|------|
27 | action | 固定为 "send" |
28 | message | 消息文本内容 |
29 | filePath | 本地文件路径(可选) |
30 | target | 用户 Open ID |
31
32 ## ⚠️ 强制要求
33
34 1. **必须直接发送文件**:使用 `filePath` 参数直接发送,禁止只发送路径或 URL
35 2. **下载到本地**:生成媒体后必须先下载到 `~/.openclaw/workspace/temp_imgs/` 目录
36
37 ## 下载图片示例
38
39 ```python
40 import requests
41 import os
42
43 temp_dir = os.path.expanduser("~/.openclaw/workspace/temp_imgs")
44 os.makedirs(temp_dir, exist_ok=True)
45
46 # 从后端下载图片
47 url = "http://localhost:8000/code/result/image/xxx.png"
48 local_path = os.path.join(temp_dir, "xxx.png")
49
50 resp = requests.get(url)
51 with open(local_path, 'wb') as f:
52 f.write(resp.content)
53
54 # 发送给用户
55 message(action="send", filePath=local_path, message="图片描述", target="user_open_id")
56 ```
57
58 ## ⚠️ 违规警告
59
60 - 禁止只告诉用户"图片已保存到 xxx 路径"而不发送
61 - 禁止只发送 URL 而不发送文件
62 - 违规后果:用户必须主动要求"把图片发给我",这是严重失误!
63
64 ## 常见问题
65
66 | 错误 | 原因 | 解决方法 |
67 |------|------|----------|
68 | 文件下载失败 | URL 错误或后端未运行 | 检查 URL 是否正确,确认后端已启动 |
69 | 文件太小/无效 | 下载的可能是错误页面 | 验证文件大小 > 1KB |
70 | 找不到文件 | 路径不存在 | 确认 `~/.openclaw/workspace/temp_imgs/` 目录下有文件 |
71 | message 发送失败 | user_open_id 错误 | 确认 target 参数正确 |
71 lines MARKDOWN