[core] Introduce UnsupportedCaptchaMethodException & UnsupportedQRCodeCaptchaException

This commit is contained in:
Karlatemp 2023-02-27 23:19:48 +08:00
parent 7038d32aa5
commit 55dc5b3cf7
No known key found for this signature in database
GPG Key ID: BA173CA2B9956C59
2 changed files with 21 additions and 3 deletions

View File

@ -72,16 +72,33 @@ public class NoStandardInputForCaptchaException @MiraiInternalApi constructor(
public override val cause: Throwable? = null
) : LoginFailedException(true, "no standard input for captcha")
/**
* 当前 [LoginSolver] 不支持此验证方式
*
* @since 2.15
*/
public open class UnsupportedCaptchaMethodException : LoginFailedException {
public constructor(killBot: Boolean) : super(killBot)
public constructor(killBot: Boolean, message: String?) : super(killBot, message)
public constructor(killBot: Boolean, message: String?, cause: Throwable?) : super(killBot, message, cause)
public constructor(killBot: Boolean, cause: Throwable?) : super(killBot, cause = cause)
}
/**
* 需要强制短信验证, 且当前 [LoginSolver] 不支持时抛出.
* @since 2.13
*/
public class UnsupportedSmsLoginException(message: String?) : LoginFailedException(true, message)
public class UnsupportedSmsLoginException(message: String?) : UnsupportedCaptchaMethodException(true, message)
/**
* 无法完成滑块验证
*/
public class UnsupportedSliderCaptchaException(message: String?) : LoginFailedException(true, message)
public class UnsupportedSliderCaptchaException(message: String?) : UnsupportedCaptchaMethodException(true, message)
/**
* 需要二维码登录, 且当前 [LoginSolver] 不支持时抛出
*/
public class UnsupportedQRCodeCaptchaException(message: String?) : UnsupportedCaptchaMethodException(true, message)
/**
* mirai 实现的异常

View File

@ -16,6 +16,7 @@ import net.mamoe.mirai.Bot
import net.mamoe.mirai.auth.QRCodeLoginListener
import net.mamoe.mirai.network.LoginFailedException
import net.mamoe.mirai.network.RetryLaterException
import net.mamoe.mirai.network.UnsupportedQRCodeCaptchaException
import net.mamoe.mirai.network.UnsupportedSmsLoginException
import net.mamoe.mirai.utils.LoginSolver.Companion.Default
import kotlin.jvm.JvmField
@ -61,7 +62,7 @@ public abstract class LoginSolver {
* @since 2.15
*/
public open fun createQRCodeLoginListener(bot: Bot): QRCodeLoginListener {
throw UnsupportedSmsLoginException("This login session requires QRCode login, but current LoginSolver($this) does not support it. Please override `LoginSolver.createQRCodeLoginListener`.")
throw UnsupportedQRCodeCaptchaException("This login session requires QRCode login, but current LoginSolver($this) does not support it. Please override `LoginSolver.createQRCodeLoginListener`.")
}
/**