Commit dc55dbb4 authored by Him188's avatar Him188

Merge remote-tracking branch 'origin/master'

parents 4738de33 1b3b543c
......@@ -343,9 +343,10 @@ Content-Type:multipart/form-data
#### 消息是构成消息链的基本对象,目前支持的消息类型有
+ [x] At,@消息
+ [x] AtAll,@全体成员
+ [x] Face,表情消息
+ [x] Plain,文字消息
+ [ ] Image,图片消息
+ [x] Image,图片消息
+ [ ] Xml,Xml卡片消息
+ [ ] 敬请期待
......@@ -364,6 +365,18 @@ Content-Type:multipart/form-data
| target | Long | 群员QQ号 |
| display | String | @时显示的文本如:"@Mirai" |
#### AtAll
```json5
{
"type": "AtAll"
}
```
| 名字 | 类型 | 说明 |
| ------- | ------ | ------------------------- |
| - | - | - |
#### Face
```json5
......
......@@ -39,6 +39,9 @@ data class UnKnownMessagePacketDTO(val msg: String) : MessagePacketDTO()
@SerialName("At")
data class AtDTO(val target: Long, val display: String) : MessageDTO()
@Serializable
@SerialName("AtAll")
data class AtAllDTO(val target: Long = 0) : MessageDTO() // target为保留字段
@Serializable
@SerialName("Face")
data class FaceDTO(val faceId: Int) : MessageDTO()
@Serializable
......@@ -83,6 +86,7 @@ fun MessageChainDTO.toMessageChain() =
@UseExperimental(ExperimentalUnsignedTypes::class)
fun Message.toDTO() = when (this) {
is At -> AtDTO(target, display)
is AtAll -> AtAllDTO(0L)
is Face -> FaceDTO(id.value.toInt())
is PlainText -> PlainDTO(stringValue)
is Image -> ImageDTO(imageId)
......@@ -93,6 +97,7 @@ fun Message.toDTO() = when (this) {
@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
fun MessageDTO.toMessage() = when (this) {
is AtDTO -> At(target, display)
is AtAllDTO -> AtAll
is FaceDTO -> Face(FaceId(faceId.toUByte()))
is PlainDTO -> PlainText(text)
is ImageDTO -> Image(imageId)
......
......@@ -51,6 +51,7 @@ object MiraiJson {
}
polymorphic(MessageDTO.serializer()) {
AtDTO::class with AtDTO.serializer()
AtAllDTO::class with AtAllDTO.serializer()
FaceDTO::class with FaceDTO.serializer()
PlainDTO::class with PlainDTO.serializer()
ImageDTO::class with ImageDTO.serializer()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment