Commit 0a7ebffd authored by Him188's avatar Him188

Fix #428

parent 58908d60
...@@ -24,6 +24,7 @@ import net.mamoe.mirai.event.events.BotOfflineEvent ...@@ -24,6 +24,7 @@ import net.mamoe.mirai.event.events.BotOfflineEvent
import net.mamoe.mirai.event.events.BotOnlineEvent import net.mamoe.mirai.event.events.BotOnlineEvent
import net.mamoe.mirai.event.events.BotReloginEvent import net.mamoe.mirai.event.events.BotReloginEvent
import net.mamoe.mirai.message.MessageEvent import net.mamoe.mirai.message.MessageEvent
import net.mamoe.mirai.network.RetryLaterException
import net.mamoe.mirai.network.UnsupportedSMSLoginException import net.mamoe.mirai.network.UnsupportedSMSLoginException
import net.mamoe.mirai.network.WrongPasswordException import net.mamoe.mirai.network.WrongPasswordException
import net.mamoe.mirai.qqandroid.QQAndroidBot import net.mamoe.mirai.qqandroid.QQAndroidBot
...@@ -176,8 +177,12 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo ...@@ -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()) throw WrongPasswordException(response.toString())
}
is WtLogin.Login.LoginPacketResponse.DeviceLockLogin -> { is WtLogin.Login.LoginPacketResponse.DeviceLockLogin -> {
response = WtLogin.Login.SubCommand20( response = WtLogin.Login.SubCommand20(
......
...@@ -13,6 +13,8 @@ package net.mamoe.mirai.network ...@@ -13,6 +13,8 @@ package net.mamoe.mirai.network
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.utils.MiraiExperimentalAPI import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.MiraiInternalAPI
import net.mamoe.mirai.utils.SinceMirai
/** /**
* 在 [登录][Bot.login] 失败时抛出, 可正常地中断登录过程. * 在 [登录][Bot.login] 失败时抛出, 可正常地中断登录过程.
...@@ -29,17 +31,24 @@ sealed class LoginFailedException constructor( ...@@ -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 不支持此输入. * 无标准输入或 Kotlin 不支持此输入.
*/ */
class NoStandardInputForCaptchaException(override val cause: Throwable?) : class NoStandardInputForCaptchaException @MiraiInternalAPI constructor(override val cause: Throwable?) :
LoginFailedException(true, "no standard input for captcha") LoginFailedException(true, "no standard input for captcha")
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment