1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-04-25 04:50:26 +08:00
This commit is contained in:
Him188 2020-07-16 22:07:35 +08:00
parent 58908d60b2
commit 0a7ebffd95
2 changed files with 18 additions and 4 deletions
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network

View File

@ -24,6 +24,7 @@ import net.mamoe.mirai.event.events.BotOfflineEvent
import net.mamoe.mirai.event.events.BotOnlineEvent
import net.mamoe.mirai.event.events.BotReloginEvent
import net.mamoe.mirai.message.MessageEvent
import net.mamoe.mirai.network.RetryLaterException
import net.mamoe.mirai.network.UnsupportedSMSLoginException
import net.mamoe.mirai.network.WrongPasswordException
import net.mamoe.mirai.qqandroid.QQAndroidBot
@ -176,8 +177,12 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
}
}
is WtLogin.Login.LoginPacketResponse.Error ->
is WtLogin.Login.LoginPacketResponse.Error -> {
if (response.message.contains("0x9a")) { //Error(title=登录失败, message=请你稍后重试。(0x9a), errorInfo=)
throw RetryLaterException()
}
throw WrongPasswordException(response.toString())
}
is WtLogin.Login.LoginPacketResponse.DeviceLockLogin -> {
response = WtLogin.Login.SubCommand20(

View File

@ -13,6 +13,8 @@ package net.mamoe.mirai.network
import net.mamoe.mirai.Bot
import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.MiraiInternalAPI
import net.mamoe.mirai.utils.SinceMirai
/**
* [登录][Bot.login] 失败时抛出, 可正常地中断登录过程.
@ -29,17 +31,24 @@ sealed class LoginFailedException constructor(
/**
* 密码输入错误 (有时候也会是其他错误, `"当前上网环境异常,请更换网络环境或在常用设备上登录或稍后再试。"`)
*/
class WrongPasswordException(message: String?) : LoginFailedException(true, message)
class WrongPasswordException @MiraiInternalAPI constructor(message: String?) : LoginFailedException(true, message)
/**
* 无可用服务器
*/
class NoServerAvailableException(override val cause: Throwable?) : LoginFailedException(false, "no server available")
class NoServerAvailableException @MiraiInternalAPI constructor(override val cause: Throwable?) :
LoginFailedException(false, "no server available")
/**
* 服务器要求稍后重试
*/
@SinceMirai("1.2.0")
class RetryLaterException @MiraiInternalAPI constructor() : LoginFailedException(false, "server requests retrial later")
/**
* 无标准输入或 Kotlin 不支持此输入.
*/
class NoStandardInputForCaptchaException(override val cause: Throwable?) :
class NoStandardInputForCaptchaException @MiraiInternalAPI constructor(override val cause: Throwable?) :
LoginFailedException(true, "no standard input for captcha")
/**