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