From 7836b2a4b3a3cffe8d5639bba2aee95d9231e168 Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 6 Jun 2022 00:36:01 +0100 Subject: [PATCH] Broadcast BotOfflineEvent.Active after state OK -> CLOSED --- .../src/commonMain/kotlin/QQAndroidBot.kt | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt b/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt index 20462872c..f8615b865 100644 --- a/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt +++ b/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt @@ -30,8 +30,11 @@ import net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.BaseStateI import net.mamoe.mirai.internal.network.handler.selector.KeepAliveNetworkHandlerSelector import net.mamoe.mirai.internal.network.handler.selector.NetworkException import net.mamoe.mirai.internal.network.handler.selector.SelectorNetworkHandler -import net.mamoe.mirai.internal.network.handler.state.* import net.mamoe.mirai.internal.network.handler.state.CombinedStateObserver.Companion.plus +import net.mamoe.mirai.internal.network.handler.state.LoggingStateObserver +import net.mamoe.mirai.internal.network.handler.state.StateChangedObserver +import net.mamoe.mirai.internal.network.handler.state.StateObserver +import net.mamoe.mirai.internal.network.handler.state.safe import net.mamoe.mirai.internal.network.impl.ForceOfflineException import net.mamoe.mirai.internal.network.notice.TraceLoggingNoticeProcessor import net.mamoe.mirai.internal.network.notice.UnconsumedNoticesAlerter @@ -139,20 +142,6 @@ internal open class QQAndroidBot constructor( } cause is BotClosedByEvent -> { } - else -> { - // handled by BotOfflineEventBroadcasterBefore - } - } - }, - BeforeStateChangedObserver("BotOfflineEventBroadcasterBefore", State.OK, State.CLOSED) { new -> - // logging performed by BotOfflineEventMonitor - val cause = new.getCause() - when { - // handled by BotOfflineEventBroadcasterAfter - cause is ForceOfflineException -> {} - cause is StatSvc.ReqMSFOffline.MsfOfflineToken -> {} - cause is NetworkException && cause.recoverable -> {} - cause is BotClosedByEvent -> {} else -> { // any other unexpected exceptions considered as an error