Old network: re-init client on BotOfflineEvent.Force. #1205 for 2.7-M1

This commit is contained in:
Him188 2021-05-04 12:42:32 +08:00
parent 84d444843d
commit 6854252c77
2 changed files with 2 additions and 1 deletions

View File

@ -104,6 +104,7 @@ internal abstract class AbstractBot<N : BotNetworkHandler> 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<N : BotNetworkHandler> 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)

View File

@ -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()