Create OtherClientInfo from known information, fix #1109

This commit is contained in:
Him188 2021-03-30 12:14:20 +08:00
parent fc70bb9ed8
commit cea4d23d7f

View File

@ -17,6 +17,8 @@ import kotlinx.io.core.ByteReadPacket
import kotlinx.serialization.protobuf.ProtoBuf import kotlinx.serialization.protobuf.ProtoBuf
import net.mamoe.mirai.Mirai import net.mamoe.mirai.Mirai
import net.mamoe.mirai.contact.ClientKind import net.mamoe.mirai.contact.ClientKind
import net.mamoe.mirai.contact.OtherClientInfo
import net.mamoe.mirai.contact.Platform
import net.mamoe.mirai.data.OnlineStatus import net.mamoe.mirai.data.OnlineStatus
import net.mamoe.mirai.event.events.BotOfflineEvent import net.mamoe.mirai.event.events.BotOfflineEvent
import net.mamoe.mirai.event.events.OtherClientOfflineEvent import net.mamoe.mirai.event.events.OtherClientOfflineEvent
@ -116,7 +118,7 @@ internal class StatSvc {
) = impl(client, 1 or 2 or 4, client.onlineStatus, regPushReason) { ) = impl(client, 1 or 2 or 4, client.onlineStatus, regPushReason) {
client.bot.friendListCache?.let { friendListCache: FriendListCache -> client.bot.friendListCache?.let { friendListCache: FriendListCache ->
iLargeSeq = friendListCache.friendListSeq iLargeSeq = friendListCache.friendListSeq
// timeStamp = friendListCache.timeStamp // timeStamp = friendListCache.timeStamp
} }
} }
@ -273,11 +275,16 @@ internal class StatSvc {
?: kotlin.run { ?: kotlin.run {
delay(2000) // sometimes server sync slow delay(2000) // sometimes server sync slow
Mirai.getOnlineOtherClientsList(bot).find { it.appId == appId } Mirai.getOnlineOtherClientsList(bot).find { it.appId == appId }
} ?: throw contextualBugReportException( } ?: kotlin.run {
"SvcReqMSFLoginNotify (OtherClient online)", // 你的帐号在平板电脑上登录了
notify._miraiContentToString(), val kind = notify.info?.substringAfter("")?.substringBefore("").orEmpty()
additional = "Failed to find corresponding instanceInfo." OtherClientInfo(
) appId,
Platform.MOBILE,
deviceName = kind,
deviceKind = kind
)
}
val client = bot.createOtherClient(info) val client = bot.createOtherClient(info)
bot.otherClients.delegate.add(client) bot.otherClients.delegate.add(client)