mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 17:39:17 +08:00
http-api support AtAll
This commit is contained in:
parent
afb74ec652
commit
c6a2229fc2
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user