消息段类型
OneBot v11 消息由消息段(segment)数组组成。每个消息段有 type 和 data 两个字段。
支持矩阵
| 类型 | 接收 | 发送 | 说明 |
|---|---|---|---|
text | ✅ | ✅ | 纯文本 |
at | ✅ | ✅ | @成员 |
face | ✅ | ✅ | QQ 表情 |
image | ✅ | ✅ | 图片 |
reply | ✅ | ✅ | 回复 |
record | ✅ | ✅ | 语音 |
video | ✅ | ✅ | 视频 |
file | ✅ | ✅ | 文件 |
json | ✅ | ✅ | JSON 卡片 |
forward | ✅ | ✅ | 合并转发 |
dice | ✅ | ✅ | 骰子 |
rps | ✅ | ✅ | 猜拳 |
music | — | ✅ | 音乐分享 |
shake | ✅ | — | 戳一戳 |
mface | ✅ | — | 商城表情 |
markdown | ✅ | — | Markdown |
详细说明
text — 纯文本
json
{ "type": "text", "data": { "text": "Hello World" } }at — @成员
json
{ "type": "at", "data": { "qq": "123456" } }
{ "type": "at", "data": { "qq": "all" } }发送时 Waylay 会自动解析 UID 和昵称,生成可点击的 @ 效果。
face — QQ 表情
json
{ "type": "face", "data": { "id": "178" } }image — 图片
接收:
json
{
"type": "image",
"data": {
"file": "abc123.jpg",
"url": "http://127.0.0.1:3001/file/abc123def456.jpg",
"file_size": "102400"
}
}自 v0.4.1 起,接收图片的
url指向 Waylay 本地代理而非 QQ CDN 直链,解决了 rkey 过期导致 URL 无法访问的问题。代理地址为http://127.0.0.1:{ONEBOT_WS_PORT}/file/{md5}.{ext}。
发送(支持多种来源):
json
{ "type": "image", "data": { "file": "file:///tmp/pic.jpg" } }
{ "type": "image", "data": { "file": "https://example.com/pic.jpg" } }
{ "type": "image", "data": { "file": "base64://iVBORw0KGgo..." } }video — 视频
发送:
json
{ "type": "video", "data": { "file": "file:///tmp/video.mp4" } }
{ "type": "video", "data": { "file": "https://example.com/video.mp4" } }Waylay 会自动:
- 用 ffmpeg 提取缩略图和时长
- 注册到 NTQQ 媒体路径
- 通过 BDH 上传
record — 语音
发送:
json
{ "type": "record", "data": { "file": "file:///tmp/voice.amr" } }file — 文件
发送:
json
{ "type": "file", "data": { "file": "file:///tmp/doc.pdf", "name": "文档.pdf" } }reply — 回复
json
{ "type": "reply", "data": { "id": "12345" } }json — JSON 卡片
json
{ "type": "json", "data": { "data": "{\"app\":\"com.tencent.structmsg\",...}" } }dice — 骰子
json
{ "type": "dice", "data": { "result": "3" } }result 可选,不传则随机 1-6。
rps — 猜拳
json
{ "type": "rps", "data": { "result": "1" } }result 可选,不传则随机 1-3。
music — 音乐分享
json
{
"type": "music",
"data": {
"type": "custom",
"title": "歌曲名",
"content": "歌手名",
"url": "https://music.163.com/...",
"audio": "https://music.163.com/song/media/...",
"image": "https://p1.music.126.net/..."
}
}mface — 商城表情(仅接收)
json
{
"type": "mface",
"data": {
"summary": "[表情名]",
"url": "https://gxh.vip.qq.com/club/item/parcel/item/...",
"emoji_id": "...",
"emoji_package_id": "...",
"key": "..."
}
}