mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-03 07:00:49 +08:00
Support New QQ System Faces (#720)
* Update QQ original faces name * Add missed channel check * Change data struct to array * Revert "Add missed channel check" This reverts commite30f97dc
* Remove author * Make internal * Update Face implement * Support decode and encode new system faces * Correct the magic number * Lazy name val * Fix naming inconsistent * Revert "Fix naming inconsistent" This reverts commitb7db927f
* Fix naming inconsistent again
This commit is contained in:
parent
a097e494ef
commit
23114b7e81
File diff suppressed because it is too large
Load Diff
@ -59,7 +59,7 @@ internal class ConstrainSingleTest {
|
||||
|
||||
val result = buildMessageChain {
|
||||
add(" ")
|
||||
add(Face(Face.hao))
|
||||
add(Face(Face.OK))
|
||||
add(TestConstrainSingleMessage())
|
||||
add(
|
||||
PlainText("ss")
|
||||
|
@ -148,7 +148,13 @@ internal fun MessageChain.toRichTextElems(
|
||||
is OfflineFriendImage -> elements.add(ImMsgBody.Elem(notOnlineImage = it.toJceData()))
|
||||
is FlashImage -> elements.add(it.toJceData()).also { transformOneMessage(UNSUPPORTED_FLASH_MESSAGE_PLAIN) }
|
||||
is AtAll -> elements.add(atAllData)
|
||||
is Face -> elements.add(ImMsgBody.Elem(face = it.toJceData()))
|
||||
is Face -> elements.add(
|
||||
if (it.id >= 260) {
|
||||
ImMsgBody.Elem(commonElem = it.toCommData())
|
||||
} else {
|
||||
ImMsgBody.Elem(face = it.toJceData())
|
||||
}
|
||||
)
|
||||
is QuoteReply -> {
|
||||
if (forGroup) {
|
||||
when (val source = it.source) {
|
||||
@ -512,6 +518,11 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, botId:
|
||||
list.add(FlashImage(OnlineFriendImageImpl(proto.flashC2cPic)))
|
||||
}
|
||||
}
|
||||
33 -> {
|
||||
val proto = element.commonElem.pbElem.loadAs(HummerCommelem.MsgElemInfoServtype33.serializer())
|
||||
list.add(Face(proto.index))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
|
@ -9,8 +9,11 @@
|
||||
|
||||
package net.mamoe.mirai.internal.message
|
||||
|
||||
import kotlinx.io.core.toByteArray
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.HummerCommelem
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.internal.utils.hexToBytes
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.internal.utils.toByteArray
|
||||
import net.mamoe.mirai.message.data.Face
|
||||
|
||||
@ -23,3 +26,16 @@ internal fun Face.toJceData(): ImMsgBody.Face {
|
||||
buf = FACE_BUF
|
||||
)
|
||||
}
|
||||
|
||||
internal fun Face.toCommData(): ImMsgBody.CommonElem {
|
||||
return ImMsgBody.CommonElem(
|
||||
serviceType = 33,
|
||||
pbElem = HummerCommelem.MsgElemInfoServtype33(
|
||||
index = this.id,
|
||||
name = "/${this.name}".toByteArray(),
|
||||
compat = "/${this.name}".toByteArray()
|
||||
).toByteArray(HummerCommelem.MsgElemInfoServtype33.serializer()),
|
||||
businessType = 1
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
|
||||
internal class HummerCommelem : ProtoBuf {
|
||||
@Serializable
|
||||
@ -234,6 +233,14 @@ internal class HummerCommelem : ProtoBuf {
|
||||
@ProtoNumber(2) @JvmField val ext: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class MsgElemInfoServtype33(
|
||||
@ProtoNumber(1) @JvmField val index: Int = 0,
|
||||
@ProtoNumber(2) @JvmField val name: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@ProtoNumber(3) @JvmField val compat: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@ProtoNumber(4) @JvmField val buf: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class MsgElemInfoServtype4(
|
||||
@ProtoNumber(1) @JvmField val imsgType: Int = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user