From 6cd7fa9709c4e3f1484eead9b510ea8042f52abc Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sun, 5 Sep 2021 22:39:54 +0800 Subject: [PATCH] #1509 try to fix bot is closed manually --- mirai-core/src/commonMain/kotlin/QQAndroidBot.kt | 3 +-- .../kotlin/network/impl/netty/NettyNetworkHandler.kt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt b/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt index 31466dc69..d82e8731a 100644 --- a/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt +++ b/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt @@ -132,8 +132,7 @@ internal open class QQAndroidBot constructor( cause is NetworkException && cause.recoverable -> { eventDispatcher.broadcastAsync(BotOfflineEvent.Dropped(bot, cause)) } - cause == null ->{ - eventDispatcher.broadcastAsync(BotOfflineEvent.Dropped(bot, null)) + cause is BotClosedByEvent -> { } else -> { // any other unexpected exceptions considered as an error diff --git a/mirai-core/src/commonMain/kotlin/network/impl/netty/NettyNetworkHandler.kt b/mirai-core/src/commonMain/kotlin/network/impl/netty/NettyNetworkHandler.kt index 0fd22c82e..a84ba7249 100644 --- a/mirai-core/src/commonMain/kotlin/network/impl/netty/NettyNetworkHandler.kt +++ b/mirai-core/src/commonMain/kotlin/network/impl/netty/NettyNetworkHandler.kt @@ -159,7 +159,7 @@ internal open class NettyNetworkHandler( future.channel().closeFuture().addListener { if (_state.correspondingState == State.CLOSED) return@addListener - close(it.cause()) + close(NettyChannelException(cause = it.cause())) } return contextResult.await()