[core] Add internal message when failed to transform internal message to facade message

This commit is contained in:
Karlatemp 2023-02-18 23:43:45 +08:00
parent ec5870e0b3
commit 00486e7900
No known key found for this signature in database
GPG Key ID: BA173CA2B9956C59

View File

@ -24,6 +24,7 @@ import net.mamoe.mirai.internal.message.source.*
import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm
import net.mamoe.mirai.message.data.*
import net.mamoe.mirai.utils.structureToString
import net.mamoe.mirai.utils.toLongUnsigned
/**
@ -104,6 +105,24 @@ private fun List<MsgComm.Msg>.toMessageChain(
onlineSource: Boolean?,
messageSourceKind: MessageSourceKind,
facade: MessageProtocolFacade = MessageProtocolFacade,
): MessageChain {
try {
return toMessageChainImpl(bot, groupIdOrZero, onlineSource, messageSourceKind, facade)
} catch (e: Exception) {
throw IllegalStateException(
"Failed to transform internal message to facade message, msg=${this@toMessageChain.structureToString()}",
e
)
}
}
private fun List<MsgComm.Msg>.toMessageChainImpl(
bot: Bot,
groupIdOrZero: Long,
onlineSource: Boolean?,
messageSourceKind: MessageSourceKind,
facade: MessageProtocolFacade = MessageProtocolFacade,
): MessageChain {
val messageList = this