1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-03-07 17:50:11 +08:00

Requests input in IO dispatcher

This commit is contained in:
Him188 2020-04-25 12:47:24 +08:00
parent cebd4a8079
commit 97dda77f04

View File

@ -62,9 +62,13 @@ class DefaultLoginSolver(
@MiraiExperimentalAPI
class DefaultLoginSolverImpl(
private val input: suspend () -> String,
input: suspend () -> String,
private val overrideLogger: MiraiLogger? = null
) : LoginSolver() {
private val input: suspend () -> String = suspend {
withContext(Dispatchers.IO) { input() }
}
override suspend fun onSolvePicCaptcha(bot: Bot, data: ByteArray): String? = loginSolverLock.withLock {
val logger = overrideLogger ?: bot.logger
val tempFile: File = createTempFile(suffix = ".png").apply { deleteOnExit() }