From f9986ffb445133764363ea4e5327333937708dd3 Mon Sep 17 00:00:00 2001 From: Him188 Date: Tue, 26 Nov 2019 12:10:40 +0800 Subject: [PATCH] Add configurations for captcha --- .../network/protocol/tim/packet/login/LoginResult.kt | 7 +++++++ .../kotlin/net.mamoe.mirai/utils/BotConfiguration.kt | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/login/LoginResult.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/login/LoginResult.kt index 35f48287b..c439e7b50 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/login/LoginResult.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/login/LoginResult.kt @@ -1,6 +1,7 @@ package net.mamoe.mirai.network.protocol.tim.packet.login import net.mamoe.mirai.network.protocol.tim.packet.login.LoginResult.Companion.SUCCESS +import net.mamoe.mirai.utils.BotConfiguration import kotlin.contracts.ExperimentalContracts import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -72,6 +73,12 @@ inline class LoginResult(val id: Byte) { @JvmStatic val NETWORK_UNAVAILABLE = LoginResult(9) + /** + * 需要验证码且 [BotConfiguration.failOnCaptcha] 为 `true` + */ + @JvmStatic + val CAPTCHA = LoginResult(10) + @JvmStatic val values: List by lazy { listOf( diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt index 5d8fbbc6e..4076aa7a3 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt @@ -42,7 +42,10 @@ class BotConfiguration { * 一旦心跳超时, 整个网络服务将会重启 (将消耗约 1s). 除正在进行的任务 (如图片上传) 会被中断外, 事件和插件均不受影响. */ var heartbeatTimeout: TimeSpan = 2.seconds - + /** + * 有验证码要求就失败 + */ + var failOnCaptcha = false /** * 验证码处理器 */