mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-21 10:42:25 +08:00
Old network: re-init client on BotOfflineEvent.Force. #1205 for 2.7-M1
This commit is contained in:
parent
84d444843d
commit
6854252c77
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user