mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 17:14:42 +08:00
Filter out customElem without MIRAI_CUSTOM_ELEM_TYPE
This commit is contained in:
parent
617b32aa14
commit
4b79c197e7
@ -21,6 +21,10 @@ internal class CustomMessageProtocol : MessageProtocol() {
|
|||||||
add(Decoder())
|
add(Decoder())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
private const val MIRAI_CUSTOM_ELEM_TYPE = 103904510 // "mirai.hashCode()"
|
||||||
|
}
|
||||||
|
|
||||||
private class Encoder : MessageEncoder<CustomMessage> {
|
private class Encoder : MessageEncoder<CustomMessage> {
|
||||||
override suspend fun MessageEncoderContext.process(data: CustomMessage) {
|
override suspend fun MessageEncoderContext.process(data: CustomMessage) {
|
||||||
markAsConsumed()
|
markAsConsumed()
|
||||||
@ -39,9 +43,6 @@ internal class CustomMessageProtocol : MessageProtocol() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
|
||||||
private const val MIRAI_CUSTOM_ELEM_TYPE = 103904510 // "mirai.hashCode()"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Decoder : MessageDecoder {
|
private class Decoder : MessageDecoder {
|
||||||
@ -49,6 +50,7 @@ internal class CustomMessageProtocol : MessageProtocol() {
|
|||||||
if (data.customElem == null) return
|
if (data.customElem == null) return
|
||||||
markAsConsumed()
|
markAsConsumed()
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
|
if (data.customElem.enumType != MIRAI_CUSTOM_ELEM_TYPE) return
|
||||||
data.customElem.data.read {
|
data.customElem.data.read {
|
||||||
CustomMessage.load(this)
|
CustomMessage.load(this)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user