mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 17:20:11 +08:00
Add timeout for logout on close
This commit is contained in:
parent
6d0e5adf95
commit
753342d99e
@ -52,6 +52,7 @@ import net.mamoe.mirai.utils.BotConfiguration
|
|||||||
import net.mamoe.mirai.utils.MiraiLogger
|
import net.mamoe.mirai.utils.MiraiLogger
|
||||||
import net.mamoe.mirai.utils.lateinitMutableProperty
|
import net.mamoe.mirai.utils.lateinitMutableProperty
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
internal fun Bot.asQQAndroidBot(): QQAndroidBot {
|
internal fun Bot.asQQAndroidBot(): QQAndroidBot {
|
||||||
contract {
|
contract {
|
||||||
@ -73,7 +74,9 @@ internal open class QQAndroidBot constructor(
|
|||||||
if (!this.isActive) return
|
if (!this.isActive) return
|
||||||
runBlocking {
|
runBlocking {
|
||||||
try { // this may not be very good but
|
try { // this may not be very good but
|
||||||
components[SsoProcessor].logout(network)
|
withTimeoutOrNull(5.seconds) {
|
||||||
|
components[SsoProcessor].logout(network)
|
||||||
|
}
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user