mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
parent
e391936679
commit
e5bc588da7
@ -55,8 +55,8 @@ internal fun startupConsoleThread() {
|
|||||||
}
|
}
|
||||||
MiraiConsole.launch(CoroutineName("Console Command")) {
|
MiraiConsole.launch(CoroutineName("Console Command")) {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
val next = try {
|
||||||
val next = MiraiConsole.requestInput("").let {
|
MiraiConsole.requestInput("").let {
|
||||||
when {
|
when {
|
||||||
it.isBlank() -> it
|
it.isBlank() -> it
|
||||||
it.startsWith(CommandManager.commandPrefix) -> it
|
it.startsWith(CommandManager.commandPrefix) -> it
|
||||||
@ -64,9 +64,25 @@ internal fun startupConsoleThread() {
|
|||||||
else -> CommandManager.commandPrefix + it
|
else -> CommandManager.commandPrefix + it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (next.isBlank()) {
|
} catch (e: InterruptedException) {
|
||||||
continue
|
return@launch
|
||||||
}
|
} catch (e: CancellationException) {
|
||||||
|
return@launch
|
||||||
|
} catch (e: UserInterruptException) {
|
||||||
|
BuiltInCommands.StopCommand.run { ConsoleCommandSender.handle() }
|
||||||
|
return@launch
|
||||||
|
} catch (eof: EndOfFileException) {
|
||||||
|
consoleLogger.warning("Closing input service...")
|
||||||
|
return@launch
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
consoleLogger.error("Error in reading next command", e)
|
||||||
|
consoleLogger.warning("Closing input service...")
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
if (next.isBlank()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
try {
|
||||||
// consoleLogger.debug("INPUT> $next")
|
// consoleLogger.debug("INPUT> $next")
|
||||||
when (val result = ConsoleCommandSender.executeCommand(next)) {
|
when (val result = ConsoleCommandSender.executeCommand(next)) {
|
||||||
is Success -> {
|
is Success -> {
|
||||||
@ -97,12 +113,6 @@ internal fun startupConsoleThread() {
|
|||||||
return@launch
|
return@launch
|
||||||
} catch (e: CancellationException) {
|
} catch (e: CancellationException) {
|
||||||
return@launch
|
return@launch
|
||||||
} catch (e: UserInterruptException) {
|
|
||||||
BuiltInCommands.StopCommand.run { ConsoleCommandSender.handle() }
|
|
||||||
return@launch
|
|
||||||
} catch (eof: EndOfFileException) {
|
|
||||||
consoleLogger.warning("Closing input service...")
|
|
||||||
return@launch
|
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
consoleLogger.error("Unhandled exception", e)
|
consoleLogger.error("Unhandled exception", e)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user