mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-04 15:56:57 +08:00
Fix builtin command Login
This commit is contained in:
parent
657c2ac613
commit
2843f91d02
@ -122,34 +122,34 @@ public object BuiltInCommands {
|
|||||||
}
|
}
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public object Login : SimpleCommand(
|
public object Login : SimpleCommand(
|
||||||
ConsoleCommandOwner, "login",
|
ConsoleCommandOwner, "login",
|
||||||
description = "Log in a bot account."
|
description = "Log in a bot account."
|
||||||
), BuiltInCommand {
|
), BuiltInCommand {
|
||||||
@Handler
|
@Handler
|
||||||
public suspend fun CommandSender.handle(id: Long, password: String) {
|
public suspend fun CommandSender.handle(id: Long, password: String) {
|
||||||
|
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
MiraiConsole.addBot(id, password).alsoLogin()
|
MiraiConsole.addBot(id, password).alsoLogin()
|
||||||
}.fold(
|
}.fold(
|
||||||
onSuccess = { sendMessage("${it.nick} ($id) Login succeed") },
|
onSuccess = { sendMessage("${it.nick} ($id) Login succeed") },
|
||||||
onFailure = { throwable ->
|
onFailure = { throwable ->
|
||||||
sendMessage(
|
sendMessage(
|
||||||
"Login failed: ${throwable.localizedMessage ?: throwable.message ?: throwable.toString()}" +
|
"Login failed: ${throwable.localizedMessage ?: throwable.message ?: throwable.toString()}" +
|
||||||
if (this is MessageEventContextAware<*>) {
|
if (this is MessageEventContextAware<*>) {
|
||||||
this.fromEvent.selectMessagesUnit {
|
this.fromEvent.selectMessagesUnit {
|
||||||
"stacktrace" reply {
|
"stacktrace" reply {
|
||||||
throwable.stackTraceToString()
|
throwable.stackTraceToString()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"test"
|
}
|
||||||
} else "")
|
"test"
|
||||||
|
} else "")
|
||||||
|
|
||||||
throw throwable
|
throw throwable
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user