Skip to content

Commit 19ca0f7

Browse files
committed
fix: request input
1 parent 4f38a6a commit 19ca0f7

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/main/kotlin/io/github/gnuf0rce/mirai/netdisk/command/BaiduOAuthCommand.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ internal object BaiduOAuthCommand : CompositeCommand(
1616
) {
1717
private val logger by NetDiskFileSyncPlugin::logger
1818

19-
private suspend fun CommandSender.read(): String {
19+
private suspend fun CommandSender.requestInput(hint: String): String {
2020
return when (this) {
21-
is ConsoleCommandSender -> MiraiConsole.requestInput("")
22-
is CommandSenderOnMessage<*> -> fromEvent.nextMessage().content
21+
is ConsoleCommandSender -> MiraiConsole.requestInput(hint)
22+
is CommandSenderOnMessage<*> -> {
23+
sendMessage(hint)
24+
fromEvent.nextMessage().content
25+
}
2326
else -> throw IllegalStateException("未知环境 $this")
2427
}
2528
}
@@ -28,8 +31,7 @@ internal object BaiduOAuthCommand : CompositeCommand(
2831
suspend fun CommandSender.oauth() {
2932
NetDisk.runCatching {
3033
authorize { url ->
31-
sendMessage("请打开连接,然后在十分钟内输入获得的认证码, $url")
32-
read()
34+
requestInput("请打开连接,然后在十分钟内输入获得的认证码, $url")
3335
} to user()
3436
}.onSuccess { (token, user) ->
3537
logger.info { "百度云用户认证成功, ${user.baiduName} by $token" }

0 commit comments

Comments
 (0)