mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 14:20:24 +08:00
Http api follow MessageSource update
This commit is contained in:
parent
d99e2afec9
commit
bb1879f2ca
@ -99,11 +99,9 @@ fun MessageChain.toDTOChain() = mutableListOf(this[MessageSource].toDTO()).apply
|
|||||||
fun MessageChainDTO.toMessageChain(contact: Contact) =
|
fun MessageChainDTO.toMessageChain(contact: Contact) =
|
||||||
MessageChain().apply { this@toMessageChain.forEach { add(it.toMessage(contact)) } }
|
MessageChain().apply { this@toMessageChain.forEach { add(it.toMessage(contact)) } }
|
||||||
|
|
||||||
internal fun MessageSource.calMessageId() = (messageRandom.toLong() shl 32) or (sequenceId.toLong() and 0xFFFFFFFF)
|
|
||||||
|
|
||||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||||
fun Message.toDTO() = when (this) {
|
fun Message.toDTO() = when (this) {
|
||||||
is MessageSource -> MessageSourceDTO(calMessageId())
|
is MessageSource -> MessageSourceDTO(id)
|
||||||
is At -> AtDTO(target, display)
|
is At -> AtDTO(target, display)
|
||||||
is AtAll -> AtAllDTO(0L)
|
is AtAll -> AtAllDTO(0L)
|
||||||
is Face -> FaceDTO(id)
|
is Face -> FaceDTO(id)
|
||||||
|
@ -11,7 +11,6 @@ package net.mamoe.mirai.api.http.queue
|
|||||||
|
|
||||||
import net.mamoe.mirai.api.http.data.common.EventDTO
|
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.IgnoreEventDTO
|
||||||
import net.mamoe.mirai.api.http.data.common.calMessageId
|
|
||||||
import net.mamoe.mirai.api.http.data.common.toDTO
|
import net.mamoe.mirai.api.http.data.common.toDTO
|
||||||
import net.mamoe.mirai.event.events.BotEvent
|
import net.mamoe.mirai.event.events.BotEvent
|
||||||
import net.mamoe.mirai.message.GroupMessage
|
import net.mamoe.mirai.message.GroupMessage
|
||||||
@ -47,7 +46,7 @@ class MessageQueue : ConcurrentLinkedDeque<BotEvent>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addQuoteCache(msg: GroupMessage) {
|
private fun addQuoteCache(msg: GroupMessage) {
|
||||||
quoteCache[msg.message[MessageSource].calMessageId()] = msg
|
quoteCache[msg.message[MessageSource].id] = msg
|
||||||
if (quoteCache.size > quoteCacheSize) {
|
if (quoteCache.size > quoteCacheSize) {
|
||||||
quoteCache.remove(quoteCache.firstKey())
|
quoteCache.remove(quoteCache.firstKey())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user