mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-03 15:10:14 +08:00
parent
490198e70c
commit
e9e9a12137
@ -174,9 +174,9 @@ public class StandardCharImageLoginSolver @JvmOverloads constructor(
|
||||
|
||||
override suspend fun onSolveSliderCaptcha(bot: Bot, url: String): String = loginSolverLock.withLock {
|
||||
val logger = loggerSupplier(bot)
|
||||
logger.info { "[SliderCaptcha] 需要滑动验证码, 请在 Chrome 浏览器中打开以下链接并完成验证码, 完成后请输入提示 ticket." }
|
||||
logger.info { "[SliderCaptcha] Slider captcha required, please open the following link in Chrome browser and solve the captcha. Type ticket here after completion." }
|
||||
logger.info { "[SliderCaptcha] Chrome Extension: https://github.com/project-mirai/mirai-login-solver-selenium#%E4%B8%8B%E8%BD%BD-chrome-%E6%89%A9%E5%B1%95%E6%8F%92%E4%BB%B6" }
|
||||
logger.info { "[SliderCaptcha] 需要滑动验证码, 请在浏览器中打开以下链接并完成验证码, 完成后请输入提示 ticket." }
|
||||
logger.info { "[SliderCaptcha] Slider captcha required, please open the following link in any browser and solve the captcha. Type ticket here after completion." }
|
||||
logger.info { "[SliderCaptcha] @see https://github.com/project-mirai/mirai-login-solver-selenium#%E4%B8%8B%E8%BD%BD-chrome-%E6%89%A9%E5%B1%95%E6%8F%92%E4%BB%B6" }
|
||||
logger.info(url)
|
||||
return input().also {
|
||||
logger.info { "[SliderCaptcha] 正在提交中..." }
|
||||
|
@ -35,20 +35,17 @@ public object SwingSolver : LoginSolver() {
|
||||
}
|
||||
}
|
||||
|
||||
public override suspend fun onSolveSliderCaptcha(bot: Bot, url: String): String {
|
||||
public override suspend fun onSolveSliderCaptcha(bot: Bot, url: String): String? {
|
||||
return openWindow("Mirai SliderCaptcha(${bot.id})") {
|
||||
JLabel("""
|
||||
JLabel(
|
||||
"""
|
||||
<html>
|
||||
需要滑动验证码, 完成后请输入ticket<br/>
|
||||
Chrome浏览器扩展下载: https://github.com/project-mirai/mirai-login-solver-selenium
|
||||
""".trimIndent()).append()
|
||||
// Try to open browser safely. #694
|
||||
kotlin.runCatching {
|
||||
Desktop.getDesktop().browse(URI(url))
|
||||
}.onFailure {
|
||||
JTextField(url).last()
|
||||
}
|
||||
}
|
||||
@see: https://github.com/project-mirai/mirai-login-solver-selenium
|
||||
""".trimIndent()
|
||||
).append()
|
||||
JTextField(url).last()
|
||||
}.takeIf { it.isNotEmpty() }
|
||||
}
|
||||
|
||||
public override suspend fun onSolveUnsafeDeviceLoginVerify(bot: Bot, url: String): String {
|
||||
|
@ -121,7 +121,7 @@ kotlin {
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation("org.pcap4j:pcap4j-distribution:1.8.2")
|
||||
implementation("net.mamoe:mirai-login-solver-selenium:1.0-dev-5")
|
||||
implementation("net.mamoe:mirai-login-solver-selenium:1.0-dev-9")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,19 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
||||
}
|
||||
)
|
||||
}
|
||||
val ticket = loginSolverNotNull().onSolveSliderCaptcha(bot, response.url).orEmpty()
|
||||
val ticket = try {
|
||||
loginSolverNotNull().onSolveSliderCaptcha(bot, response.url)
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
?: return closeEverythingAndRelogin(host, port, cause, step)
|
||||
} catch (lfe: LoginFailedException) {
|
||||
throw lfe
|
||||
} catch (error: Throwable) {
|
||||
if (step == 0) {
|
||||
logger.warning(error)
|
||||
return closeEverythingAndRelogin(host, port, error, 1)
|
||||
}
|
||||
throw error
|
||||
}
|
||||
response = WtLogin.Login.SubCommand2.SubmitSliderCaptcha(bot.client, ticket).sendAndExpect()
|
||||
continue@mainloop
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user