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 net.mamoe.mirai.Mirai
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.event.events.BotOfflineEvent
import net.mamoe.mirai.event.events.OtherClientOfflineEvent
@ -273,11 +275,16 @@ internal class StatSvc {
?: kotlin.run {
delay(2000) // sometimes server sync slow
Mirai.getOnlineOtherClientsList(bot).find { it.appId == appId }
} ?: throw contextualBugReportException(
"SvcReqMSFLoginNotify (OtherClient online)",
notify._miraiContentToString(),
additional = "Failed to find corresponding instanceInfo."
} ?: kotlin.run {
// 你的帐号在平板电脑上登录了
val kind = notify.info?.substringAfter("")?.substringBefore("").orEmpty()
OtherClientInfo(
appId,
Platform.MOBILE,
deviceName = kind,
deviceKind = kind
)
}
val client = bot.createOtherClient(info)
bot.otherClients.delegate.add(client)