diff --git a/mirai-core/src/commonMain/kotlin/AbstractBot.kt b/mirai-core/src/commonMain/kotlin/AbstractBot.kt index f503112e2..7e2ff38c4 100644 --- a/mirai-core/src/commonMain/kotlin/AbstractBot.kt +++ b/mirai-core/src/commonMain/kotlin/AbstractBot.kt @@ -104,6 +104,7 @@ internal abstract class AbstractBot constructor( priority = MONITOR, concurrency = ConcurrencyKind.LOCKED ) { event -> + val bot = bot.asQQAndroidBot() if ( !event.bot.isActive // bot closed || !::_network.isInitialized // bot 还未登录就被 close @@ -129,6 +130,7 @@ internal abstract class AbstractBot constructor( is BotOfflineEvent.Force -> { bot.logger.info { "Connection occupied by another android device: ${event.message}" } bot.asQQAndroidBot().accountSecretsFile.delete() + bot.client = bot.initClient() if (event.reconnect) { bot.logger.info { "Reconnecting..." } // delay(3000) diff --git a/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt b/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt index d65b497a3..a04a24e08 100644 --- a/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt +++ b/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt @@ -122,7 +122,6 @@ internal class QQAndroidBot constructor( /////////////////////////// accounts secrets end var client: QQAndroidClient = initClient() - private set fun initClient(): QQAndroidClient { val device = configuration.deviceInfo?.invoke(this) ?: DeviceInfo.random()