mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 23:50:08 +08:00
Drop InternalFlag in MessageReceipt
This commit is contained in:
parent
bd041e43d1
commit
736f52275f
@ -12,11 +12,11 @@ package net.mamoe.mirai.internal.message
|
||||
import kotlinx.serialization.Transient
|
||||
import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.internal.contact.SendMessageHandler
|
||||
import net.mamoe.mirai.internal.message.LightMessageRefiner.dropMiraiInternalFlags
|
||||
import net.mamoe.mirai.internal.message.LightMessageRefiner.refineLight
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.utils.cast
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
|
||||
@ -80,7 +80,9 @@ internal fun <C : Contact> OnlineMessageSource.Outgoing.createMessageReceipt(
|
||||
): MessageReceipt<C> {
|
||||
if (doLightRefine) {
|
||||
check(this is OutgoingMessageSourceInternal) { "Internal error: source !is OutgoingMessageSourceInternal" }
|
||||
this.originalMessage = this.originalMessage.refineLight(bot)
|
||||
this.originalMessage = this.originalMessage
|
||||
.dropMiraiInternalFlags()
|
||||
.refineLight(bot)
|
||||
}
|
||||
return MessageReceipt(this, target)
|
||||
}
|
||||
|
@ -166,6 +166,15 @@ internal object LightMessageRefiner : MessageRefiner() {
|
||||
): MessageChain {
|
||||
return refineImpl(bot) { it.tryRefine(bot, this, refineContext) }
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除 [MessageChain] 携带的内部标识
|
||||
*
|
||||
* 用于 [createMessageReceipt] <- `RemoteFile.uploadAndSend` (文件操作API v1)
|
||||
*/
|
||||
fun MessageChain.dropMiraiInternalFlags(): MessageChain {
|
||||
return asSequence().filterNot { it is InternalFlagOnlyMessage }.toMessageChain()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user