Ignore offline messages

This commit is contained in:
Him188 2020-02-07 12:31:20 +08:00
parent f634a5282f
commit f7092976f1

View File

@ -121,12 +121,15 @@ internal class MessageSvc {
val messages = resp.uinPairMsgs.asSequence().filterNot { it.msg == null }.flatMap { it.msg!!.asSequence() }.mapNotNull { val messages = resp.uinPairMsgs.asSequence().filterNot { it.msg == null }.flatMap { it.msg!!.asSequence() }.mapNotNull {
when (it.msgHead.msgType) { when (it.msgHead.msgType) {
166 -> { 166 -> {
if (it.msgHead.fromUin == bot.uin) null when {
else FriendMessage( it.msgHead.fromUin == bot.uin -> null
bot, !bot.firstLoginSucceed -> null
bot.getFriend(it.msgHead.fromUin), else -> FriendMessage(
it.msgBody.richText.toMessageChain() bot,
) bot.getFriend(it.msgHead.fromUin),
it.msgBody.richText.toMessageChain()
)
}
} }
else -> null else -> null
} }
@ -173,7 +176,7 @@ internal class MessageSvc {
} }
data class Failed(val errorCode: Int, val errorMessage: String) : Response() { data class Failed(val errorCode: Int, val errorMessage: String) : Response() {
override fun toString(): String = "MessageSvc.PbSendMsg.Response.Failed(errorCode=$errorCode, errorMessage=$errorMessage" override fun toString(): String = "MessageSvc.PbSendMsg.Response.Failed(errorCode=$errorCode, errorMessage=$errorMessage)"
} }
} }