Explorar o código

Support SuperFace

ryoii %!s(int64=2) %!d(string=hai) anos
pai
achega
0e2751afce

+ 7 - 5
docs/api/MessageType.md

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

+ 2 - 2
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/convertor/convertor.kt

@@ -1,5 +1,5 @@
 /*
- * Copyright 2020 Mamoe Technologies and contributors.
+ * Copyright 2023 Mamoe Technologies and contributors.
  *
  * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@@ -68,7 +68,7 @@ internal suspend fun MessageDTO.toMessage(contact: Contact, cache: Persistence)
         faceId >= 0 -> Face(faceId)
         name.isNotEmpty() -> Face(FaceMap[name])
         else -> Face(255)
-    }
+    }.let { if (isSuperFace) it.toSuperFace() else it }
 
     is PlainDTO -> PlainText(text)
     is ImageDTO -> imageLikeToMessage(contact)

+ 3 - 2
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/convertor/message.kt

@@ -1,5 +1,5 @@
 /*
- * Copyright 2020 Mamoe Technologies and contributors.
+ * Copyright 2023 Mamoe Technologies and contributors.
  *
  * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@@ -61,7 +61,8 @@ internal suspend fun Message.toDTO() = when (this) {
     is MessageSource -> MessageSourceDTO(ids.firstOrNull() ?: 0, time)
     is At -> AtDTO(target, "")
     is AtAll -> AtAllDTO(0L)
-    is Face -> FaceDTO(id, FaceMap[id])
+    is Face -> FaceDTO(id, FaceMap[id], isSuperFace = false)
+    is SuperFace -> FaceDTO(face, FaceMap[face], isSuperFace = true)
     is PlainText -> PlainDTO(content)
     is Image -> ImageDTO(imageId, queryUrl(), width = width, height = height, size = size, imageType = imageType.name, isEmoji = isEmoji)
     is FlashImage -> with(image) {

+ 2 - 2
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/message.kt

@@ -1,5 +1,5 @@
 /*
- * Copyright 2020 Mamoe Technologies and contributors.
+ * Copyright 2023 Mamoe Technologies and contributors.
  *
  * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@@ -73,7 +73,7 @@ internal data class AtAllDTO(val target: Long = 0) : MessageDTO() // target为
 
 @Serializable
 @SerialName("Face")
-internal data class FaceDTO(val faceId: Int = -1, val name: String = "") : MessageDTO()
+internal data class FaceDTO(val faceId: Int = -1, val name: String = "", val isSuperFace: Boolean = false) : MessageDTO()
 
 @Serializable
 @SerialName("Plain")