Skip to content

Latest commit

 

History

History
555 lines (461 loc) · 13.9 KB

MessageType.md

File metadata and controls

555 lines (461 loc) · 13.9 KB

消息类型说明

消息链类型

好友消息

{
    "type": "FriendMessage",
    "sender": {
        "id": 123,
        "nickname": "",
        "remark": ""
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

群消息

{
    "type": "GroupMessage",
    "sender": {
        "id": 123,
        "memberName": "",
        "specialTitle": "",
        "permission": "OWNER",
        "joinTimestamp": 0,
        "lastSpeakTimestamp": 0,
        "muteTimeRemaining": 0,
        "group": {
            "id": 321,
            "name": "",
            "permission": "MEMBER",
        },
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

群临时消息

{
    "type": "TempMessage",
    "sender": {
        "id": 123,
        "memberName": "",
        "specialTitle": "",
        "permission": "OWNER",
        "joinTimestamp": 0,
        "lastSpeakTimestamp": 0,
        "muteTimeRemaining": 0,
        "group": {
            "id": 321,
            "name": "",
            "permission": "MEMBER",
        },
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

陌生人消息

{
    "type": "StrangerMessage",
    "sender": {
        "id": 123,
        "nickname": "",
        "remark": ""
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

其他客户端消息

{
    "type": "OtherClientMessage",
    "sender": {
        "id": 123,
        "platform": "MOBILE"
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

同步消息链类型

同步消息和普通消息一样, 但是由 Bot 账号的其他客户端发送的消息, 同步到 mirai 时产生的事件. 此类事发送人永远是 Bot 本身, 故省略

同步好友消息

{
    "type": "FriendSyncMessage",
    "subject": {
        "id": 123,
        "nickname": "",
        "remark": ""
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

subject 为发送的目标好友

同步群消息

{
    "type": "GroupSyncMessage",
    "subject": {
      "id": 321,
      "name": "",
      "permission": "MEMBER",
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

subject 为发送的目标群

同步群临时消息

{
    "type": "TempSyncMessage",
    "subject": {
        "id": 123,
        "memberName": "",
        "specialTitle": "",
        "permission": "OWNER",
        "joinTimestamp": 0,
        "lastSpeakTimestamp": 0,
        "muteTimeRemaining": 0,
        "group": {
            "id": 321,
            "name": "",
            "permission": "MEMBER",
        },
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

subject 为发送的目标群成员,对应群信息在群成员的 group 字段

同步陌生人消息

{
    "type": "StrangerSyncMessage",
    "subject": {
        "id": 123,
        "nickname": "",
        "remark": ""
    },
    "messageChain": [] // 数组,内容为下文消息类型
}

subject 为发送的目前陌生人账号

消息类型

Source

{
    "type": "Source",
    "id": 123456,
    "time": 123456
}
名字 类型 说明
id Int 消息的识别号,用于引用回复(Source类型永远为chain的第一个元素)
time Int 时间戳

Quote

{
    "type": "Quote",
    "id": 123456,
    "groupId": 123456789,
    "senderId": 987654321,
    "targetId": 9876543210,
    "origin": [
        { "type": "Plain", text: "text" }
    ] 
}
名字 类型 说明
id Int 被引用回复的原消息的messageId
groupId Long 被引用回复的原消息所接收的群号,当为好友消息时为0
senderId Long 被引用回复的原消息的发送者的QQ号
targetId Long 被引用回复的原消息的接收者者的QQ号(或群号)
origin Object 被引用回复的原消息的消息链对象

At

{
    "type": "At",
    "target": 123456,
    "display": "@Mirai"
}
名字 类型 说明
target Long 群员QQ号
display String At时显示的文字,发送消息时无效,自动使用群名片

AtAll

{
    "type": "AtAll"
}
名字 类型 说明
- - -

Face

{
    "type": "Face",
    "faceId": 123,
    "name": "bu",
    "superFace": false
}
名字 类型 说明
faceId Int QQ表情编号,可选,优先高于name
name String QQ表情拼音,可选
isSuperFace Boolean 超级表情,默认 false

Plain

{
    "type": "Plain",
    "text": "Mirai牛逼"
}
名字 类型 说明
text String 文字消息

Image

{
    "type": "Image",
    "imageId": "{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.mirai",  //群图片格式
    //"imageId": "/f8f1ab55-bf8e-4236-b55e-955848d7069f"      //好友图片格式
    "url": "https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "path": null,
    "base64": null,
    "width": 0,
    "height": 0,
    "size": 0,
    "imageType": "UNKNOWN",
    "isEmoji": false
}
名字 类型 说明
imageId String 图片的imageId,群图片与好友图片格式不同。不为空时将忽略url属性
url String 图片的URL,发送时可作网络图片的链接;接收时为腾讯图片服务器的链接,可用于图片下载
path String 图片的路径,发送本地图片,路径相对于 JVM 工作路径(默认是当前路径,可通过 -Duser.dir=...指定),也可传入绝对路径。
base64 String 图片的 Base64 编码
width Int 图片宽度
height Int 图片高度
size Long 图片大小
imageType String 图片类型,bmp,jpg 等
isEmoji Boolean 图片是否为动画表情

FlashImage

{
    "type": "FlashImage",
    "imageId": "{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.mirai",  //群图片格式
    //"imageId": "/f8f1ab55-bf8e-4236-b55e-955848d7069f"      //好友图片格式
    "url": "https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "path": null,
    "base64": null,
    "width": 0,
    "height": 0,
    "size": 0,
    "imageType": "UNKNOWN",
    "isEmoji": false
}

Image

三个参数任选其一,出现多个参数时,按照imageId > url > path > base64的优先级

Voice

{
    "type": "Voice",
    "voiceId": "23C477720A37FEB6A9EE4BCCF654014F.amr",
    "url": "https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "path": null,
    "base64": null,
    "length": 1024,
}
名字 类型 说明
voiceId String 语音的voiceId,不为空时将忽略url属性
url String 语音的URL,发送时可作网络语音的链接;接收时为腾讯语音服务器的链接,可用于语音下载
path String 语音的路径,发送本地语音,路径相对于 JVM 工作路径(默认是当前路径,可通过 -Duser.dir=...指定),也可传入绝对路径。
base64 String 语音的 Base64 编码
length Long 返回的语音长度, 发送消息时可以不传

三个参数任选其一,出现多个参数时,按照voiceId > url > path > base64的优先级

Xml

{
    "type": "Xml",
    "xml": "XML"
}
名字 类型 说明
xml String XML文本

Json

{
    "type": "Json",
    "json": "{}"
}
名字 类型 说明
json String Json文本

App

{
    "type": "App",
    "content": "<>"
}
名字 类型 说明
content String 内容

Poke

{
    "type": "Poke",
    "name": "SixSixSix"
}
名字 类型 说明
name String 戳一戳的类型
  1. "Poke": 戳一戳
  2. "ShowLove": 比心
  3. "Like": 点赞
  4. "Heartbroken": 心碎
  5. "SixSixSix": 666
  6. "FangDaZhao": 放大招

Dice

{
  "type": "Dice",
  "value": 1
}
名字 类型 说明
value Int 点数

MarketFace

{
  "type": "MarketFace",
  "id": 123,
  "name": "商城表情"
}
名字 类型 说明
id Int 商城表情唯一标识
name String 表情显示名称

目前商城表情仅支持接收和转发,不支持构造发送

MusicShare

{
  "type": "MusicShare",
  "kind": "String",
  "title": "String",
  "summary": "String",
  "jumpUrl": "String",
  "pictureUrl": "String",
  "musicUrl": "String",
  "brief": "String"
}
名字 类型 说明
kind String 类型
title String 标题
summary String 概括
jumpUrl String 跳转路径
pictureUrl String 封面路径
musicUrl String 音源路径
brief String 简介

ForwardMessage

{
  "type": "Forward",
  "display": {
    "title": "群聊的聊天记录",
    "brief": "[聊天记录]",
    "source": "聊天记录",
    "preview": ["msg1", "msg2", "msg3", "msg4"],
    "summary": "查看x条转发消息"
  },
  "nodeList": [
    {
      "senderId": 123,
      "time": 0,
      "senderName": "sender name",
      "messageChain": [],
      "messageId": 123,
      "messageRef": {
        "messageId": 123,
        "target": 321,
      }
    }
  ] 
}
名字 类型 说明
display object 转发消息的卡片显示文本,参考上文json确认参数含义,值为表示使用客户端默认值;display为空表示全用默认值
nodeList object 消息节点
senderId Long 发送人QQ号
time Int 发送时间
senderName String 显示名称
messageChain Array 消息数组
messageId Int 可以只使用消息messageId,从当前对话上下文缓存中读取一条消息作为节点
messageRef object 引用缓存中其他对话上下文的消息作为节点
messageRef.messageId Int 引用的 messageId
messageRef.target Int 引用的上下文目标,群号、好友账号

(senderId, time, senderName, messageChain), messageId, messageRef 是三种不同构造引用节点的方式,选其中一个/组传参即可

File

{
  "type": "File",
  "id": "",
  "name": "",
  "size": 0
}
名字 类型 说明
id String 文件识别id
name String 文件名
size Long 文件大小

ShortVideo

{
  "type": "ShortVideo",
  "videoId": "",
  "fileMd5": "",
  "fileSize": 0,
  "fileFormat": "",
  "filename": "",
  "videoUrl": "",
  "thumbnailUrl": null
}
名字 类型 说明
videoId String 短视频id
fileMd5 String 短视频MD5
fileSize Long 文件大小
fileFormat String 文件格式
filename String 文件名,不含扩展名
videoUrl String 适配文件下载地址, 离线消息可能为 null
thumbnailUrl String 封面地址,一般为 null

MiraiCode

{
  "type": "MiraiCode",
  "code": "hello[mirai:at:1234567]"
}
名字 类型 说明
code String MiraiCode

MiraiCode的使用