Skip to content

消息段类型参考

消息由一组**段(segment)**组成,每个段是 { "type": "xxx", "data": {...} } 格式的对象。 发送消息时传段数组,收到消息时 message 字段也是段数组。

不支持 CQ 码

发送时若 message 传字符串,会被当作纯文本,不会解析 [CQ:...]。事件里的 raw_message 也是纯文本(仅文本段拼接)。

段类型一览

类型说明常用
text纯文本
at@某人 / @全体
face / sfaceQQ 表情
image / flash图片 / 闪照
reply / quote回复引用
record语音
video / bubble视频 / 气泡视频
file文件
jsonJSON 卡片
xmlXML 卡片
share链接分享
location位置
music音乐分享(QQ音乐/网易云/自定义)
contact推荐联系人/群
poke戳一戳
mface商城表情
bface原创表情
rps / dice猜拳 / 骰子
markdownMarkdown
button按钮
node转发节点(合并转发用)
forward合并转发引用
long_msg长消息引用
miraimirai 数据透传
forum论坛/帖子

未识别的段类型会原样透传为 Unknown,不会丢失。


text —— 纯文本

字段类型说明
textstring文本内容。
json
{ "type": "text", "data": { "text": "你好世界" } }

at —— 提及

字段类型说明
qqstring被 @ 的 QQ 号;"all" 表示全体成员。
idstring频道场景下的 guild tiny_id(非 0/空时优先于 qq)。
textstring可选,@ 的展示文本。
dummybool可选。
json
{ "type": "at", "data": { "qq": "<friend_id>" } }

face / sface —— QQ 表情

字段类型说明
idint表情 id。
textstring可选,表情文字。
bigbool可选,是否大表情。
stickerIdstring可选,超级表情贴纸 id。
stickerTypeint可选,贴纸类型。
json
{ "type": "face", "data": { "id": 4 } }

bface —— 原创表情

字段类型说明
filestring表情文件标识。
textstring表情文字。
json
{ "type": "bface", "data": { "file": "<file>", "text": "[斗图]" } }

rps / dice —— 猜拳 / 骰子(魔法表情)

字段类型说明
idint可选,点数/结果。
json
{ "type": "dice", "data": {} }

image / flash —— 图片(flash 为闪照)

字段类型说明
filestring图片来源(路径 / URL / base64 / 已上传 fid)。
urlstring可选,图片 URL。
cachebool可选,是否使用缓存。
timeoutint可选,下载超时(秒)。
namestring可选,文件名。
asfacebool可选,是否作为表情发送。
originbool可选,是否原图。
summarystring可选,图片摘要/描述。
fidstring可选,已上传文件标识。
md5 / sha1string可选,校验值。
height / widthint可选,像素尺寸。
sizeint可选,字节大小。
ntbool可选,是否走 NT 媒体通道。
json
{ "type": "image", "data": { "file": "https://example.com/a.jpg" } }

reply / quote —— 回复

quotereply 的别名。

字段类型说明
idstring被回复消息的 message_id
textstring可选,回复展示文本。
json
{ "type": "reply", "data": { "id": "<message_id>" } }

record —— 语音

字段类型说明
filestring语音来源。
urlstring可选,语音 URL。
namestring可选,文件名。
fidstring可选,已上传标识。
md5 / sha1string可选,校验值。
sizeint可选,字节大小。
secondsint可选,时长(秒)。
transcodebool可选,是否转码(需 ffmpeg)。
temp / ntbool可选。
json
{ "type": "record", "data": { "file": "/path/to/voice.amr" } }

video / bubble —— 视频(bubble 为气泡视频)

字段与 record 同族(媒体元素),另含 width / height / brief

字段类型说明
filestring视频来源。
urlstring可选,视频 URL。
width / heightint可选,分辨率。
secondsint可选,时长(秒)。
sizeint可选,字节大小。
briefstring可选,摘要。
md5 / sha1 / fid / namestring可选。
transcode / temp / ntbool可选。
json
{ "type": "video", "data": { "file": "/path/to/clip.mp4" } }

file —— 文件

字段类型说明
filestring文件来源。
namestring可选,文件名。
fidstring可选,已上传标识。
md5 / sha1string可选,校验值。
sizeint可选,字节大小。
durationint可选。
tempbool可选。
json
{ "type": "file", "data": { "file": "/path/to/doc.pdf", "name": "doc.pdf" } }

json —— JSON 卡片

字段类型说明
dataobject/stringJSON 卡片内容(原样透传)。
json
{ "type": "json", "data": { "data": { "app": "com.tencent.miniapp" } } }

xml —— XML 卡片

字段类型说明
datastringXML 内容。
idint可选,服务 id。
json
{ "type": "xml", "data": { "data": "<msg>...</msg>" } }

share —— 链接分享

字段类型说明
urlstring分享链接。
titlestring标题。
imagestring可选,封面图。
contentstring可选,描述。
audiostring可选,音频。
json
{ "type": "share", "data": { "url": "https://example.com", "title": "标题" } }

location —— 位置

字段类型说明
latfloat纬度。
lngfloat经度。
addressstring地址。
namestring可选,地点名。
idstring可选,地点 id。
json
{ "type": "location", "data": { "lat": 39.9, "lng": 116.3, "address": "北京" } }

music —— 音乐分享

字段类型说明
typestring平台:qq / 163 / custom / …(缺省 qq)。
idstring平台音乐 id(非 custom 时)。
urlstringcustom:跳转链接。
audiostringcustom:音频直链。
titlestringcustom:标题。
contentstringcustom:描述。
imagestringcustom:封面。
json
{ "type": "music", "data": { "type": "163", "id": "<music_id>" } }

contact —— 推荐联系人

字段类型说明
typestringqqgroup
idstring被推荐的 QQ 号或群号。
json
{ "type": "contact", "data": { "type": "group", "id": "<group_id>" } }

poke —— 戳一戳

字段类型说明
idint戳一戳类型 id。
textstring可选,文字。
json
{ "type": "poke", "data": { "id": 1 } }

mface —— 商城表情(market face)

字段类型说明
emoji_package_idint表情包 id(亦接受 package_id)。
emoji_idstring表情 id(亦接受 face_id)。
keystring表情 key。
summarystring摘要(亦接受 text)。
json
{
  "type": "mface",
  "data": {
    "emoji_package_id": 1357,
    "emoji_id": "0123456789abcdef",
    "key": "deadbeef",
    "summary": "[暗示]"
  }
}

markdown —— Markdown

字段类型说明
contentstringMarkdown 内容。
configobject可选,配置。
json
{ "type": "markdown", "data": { "content": "# 标题" } }

button —— 按钮

字段类型说明
contentobject按钮内容(原样透传)。

node —— 转发节点

用于构造合并转发;content 是子段数组。

字段类型说明
user_idint节点作者 QQ 号。
nicknamestring可选,作者昵称。
contentarray子消息段数组。
timeint可选,时间戳。
seq / randint可选。
previewstring可选,预览文本。
json
{
  "type": "node",
  "data": {
    "user_id": 10001,
    "nickname": "Alice",
    "content": [{ "type": "text", "data": { "text": "转发内容" } }]
  }
}

forward —— 合并转发(已上传)

字段类型说明
id / residstring转发资源 id。
filenamestring可选。
titlestring可选。
contentstring可选。
previewarray可选,预览行。
promptstring可选。
json
{ "type": "forward", "data": { "id": "<resid>" } }

其它段

type主要字段说明
long_msgresid长消息引用。
miraidatamirai 私有数据透传。
forumid, create_time论坛/帖子。

未识别的 type 会原样透传为 Unknown(保留其 typedata),不会丢失。