diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt index fa2d41d8b..d87d7c999 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt @@ -99,9 +99,11 @@ fun MessageChain.toDTOChain() = mutableListOf(this[MessageSource].toDTO()).apply fun MessageChainDTO.toMessageChain(contact: Contact) = MessageChain().apply { this@toMessageChain.forEach { add(it.toMessage(contact)) } } +internal fun MessageSource.calMessageId() = (messageUid.toLong() shl 32) or (sequenceId.toLong() and 0xFFFFFFFF) + @UseExperimental(ExperimentalUnsignedTypes::class) fun Message.toDTO() = when (this) { - is MessageSource -> MessageSourceDTO(messageUid.toLong() and 0xFFffFFff) + is MessageSource -> MessageSourceDTO(calMessageId()) is At -> AtDTO(target, display) is AtAll -> AtAllDTO(0L) is Face -> FaceDTO(id) diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt index 5d4e03399..b2eb44fd2 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt @@ -11,6 +11,7 @@ package net.mamoe.mirai.api.http.queue import net.mamoe.mirai.api.http.data.common.EventDTO import net.mamoe.mirai.api.http.data.common.IgnoreEventDTO +import net.mamoe.mirai.api.http.data.common.calMessageId import net.mamoe.mirai.api.http.data.common.toDTO import net.mamoe.mirai.event.events.BotEvent import net.mamoe.mirai.message.GroupMessage @@ -46,7 +47,7 @@ class MessageQueue : ConcurrentLinkedDeque() { } private fun addQuoteCache(msg: GroupMessage) { - quoteCache[msg.message[MessageSource].messageUid.toLong()] = msg + quoteCache[msg.message[MessageSource].calMessageId()] = msg if (quoteCache.size > quoteCacheSize) { quoteCache.remove(quoteCache.firstKey()) }