mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 13:54:45 +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())
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val MIRAI_CUSTOM_ELEM_TYPE = 103904510 // "mirai.hashCode()"
|
||||
}
|
||||
|
||||
private class Encoder : MessageEncoder<CustomMessage> {
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user