1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-05-06 05:52:33 +08:00

Improve SeleniumLoginSolver loading

This commit is contained in:
Karlatemp 2020-12-30 18:24:45 +08:00
parent e9e9a12137
commit 9ba4a99cb1
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -10,13 +10,19 @@
package net.mamoe.mirai.utils.internal
import net.mamoe.mirai.utils.LoginSolver
import net.mamoe.mirai.utils.MiraiLogger
internal val SeleniumLoginSolver: LoginSolver? by lazy {
runCatching {
try {
Class.forName("net.mamoe.mirai.selenium.SeleniumLoginSolver")
.getMethod("getInstance")
.invoke(null) as? LoginSolver
}.getOrNull()
} catch (ignore: ClassNotFoundException) {
null
} catch (error: Throwable) {
MiraiLogger.TopLevel.warning("Error in loading mirai-login-solver-selenium, skip", error)
null
}
}
// null -> 该情况为 user 确认能自己传入 ticket, 不需要 Selenium 的帮助