http-api support AtAll

This commit is contained in:
ryoii 2020-02-14 21:25:34 +08:00
parent afb74ec652
commit c6a2229fc2
3 changed files with 20 additions and 1 deletions

View File

@ -343,9 +343,10 @@ Content-Typemultipart/form-data
#### 消息是构成消息链的基本对象,目前支持的消息类型有 #### 消息是构成消息链的基本对象,目前支持的消息类型有
+ [x] At@消息 + [x] At@消息
+ [x] AtAll@全体成员
+ [x] Face表情消息 + [x] Face表情消息
+ [x] Plain文字消息 + [x] Plain文字消息
+ [ ] Image图片消息 + [x] Image图片消息
+ [ ] XmlXml卡片消息 + [ ] XmlXml卡片消息
+ [ ] 敬请期待 + [ ] 敬请期待
@ -364,6 +365,18 @@ Content-Typemultipart/form-data
| target | Long | 群员QQ号 | | target | Long | 群员QQ号 |
| display | String | @时显示的文本如"@Mirai" | | display | String | @时显示的文本如"@Mirai" |
#### AtAll
```json5
{
"type": "AtAll"
}
```
| 名字 | 类型 | 说明 |
| ------- | ------ | ------------------------- |
| - | - | - |
#### Face #### Face
```json5 ```json5

View File

@ -39,6 +39,9 @@ data class UnKnownMessagePacketDTO(val msg: String) : MessagePacketDTO()
@SerialName("At") @SerialName("At")
data class AtDTO(val target: Long, val display: String) : MessageDTO() data class AtDTO(val target: Long, val display: String) : MessageDTO()
@Serializable @Serializable
@SerialName("AtAll")
data class AtAllDTO(val target: Long = 0) : MessageDTO() // target为保留字段
@Serializable
@SerialName("Face") @SerialName("Face")
data class FaceDTO(val faceId: Int) : MessageDTO() data class FaceDTO(val faceId: Int) : MessageDTO()
@Serializable @Serializable
@ -83,6 +86,7 @@ fun MessageChainDTO.toMessageChain() =
@UseExperimental(ExperimentalUnsignedTypes::class) @UseExperimental(ExperimentalUnsignedTypes::class)
fun Message.toDTO() = when (this) { fun Message.toDTO() = when (this) {
is At -> AtDTO(target, display) is At -> AtDTO(target, display)
is AtAll -> AtAllDTO(0L)
is Face -> FaceDTO(id.value.toInt()) is Face -> FaceDTO(id.value.toInt())
is PlainText -> PlainDTO(stringValue) is PlainText -> PlainDTO(stringValue)
is Image -> ImageDTO(imageId) is Image -> ImageDTO(imageId)
@ -93,6 +97,7 @@ fun Message.toDTO() = when (this) {
@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) @UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
fun MessageDTO.toMessage() = when (this) { fun MessageDTO.toMessage() = when (this) {
is AtDTO -> At(target, display) is AtDTO -> At(target, display)
is AtAllDTO -> AtAll
is FaceDTO -> Face(FaceId(faceId.toUByte())) is FaceDTO -> Face(FaceId(faceId.toUByte()))
is PlainDTO -> PlainText(text) is PlainDTO -> PlainText(text)
is ImageDTO -> Image(imageId) is ImageDTO -> Image(imageId)

View File

@ -51,6 +51,7 @@ object MiraiJson {
} }
polymorphic(MessageDTO.serializer()) { polymorphic(MessageDTO.serializer()) {
AtDTO::class with AtDTO.serializer() AtDTO::class with AtDTO.serializer()
AtAllDTO::class with AtAllDTO.serializer()
FaceDTO::class with FaceDTO.serializer() FaceDTO::class with FaceDTO.serializer()
PlainDTO::class with PlainDTO.serializer() PlainDTO::class with PlainDTO.serializer()
ImageDTO::class with ImageDTO.serializer() ImageDTO::class with ImageDTO.serializer()