diff --git a/mirai-core/src/commonMain/kotlin/message/protocol/impl/CustomMessageProtocol.kt b/mirai-core/src/commonMain/kotlin/message/protocol/impl/CustomMessageProtocol.kt index 230c51e44..264be5a6f 100644 --- a/mirai-core/src/commonMain/kotlin/message/protocol/impl/CustomMessageProtocol.kt +++ b/mirai-core/src/commonMain/kotlin/message/protocol/impl/CustomMessageProtocol.kt @@ -21,6 +21,10 @@ internal class CustomMessageProtocol : MessageProtocol() { add(Decoder()) } + private companion object { + private const val MIRAI_CUSTOM_ELEM_TYPE = 103904510 // "mirai.hashCode()" + } + private class Encoder : MessageEncoder { override suspend fun MessageEncoderContext.process(data: CustomMessage) { 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 { @@ -49,6 +50,7 @@ internal class CustomMessageProtocol : MessageProtocol() { if (data.customElem == null) return markAsConsumed() kotlin.runCatching { + if (data.customElem.enumType != MIRAI_CUSTOM_ELEM_TYPE) return data.customElem.data.read { CustomMessage.load(this) }