|
@@ -21,9 +21,12 @@
|
|
|
package net.mamoe.mirai.console.pure
|
|
package net.mamoe.mirai.console.pure
|
|
|
|
|
|
|
|
import kotlinx.coroutines.isActive
|
|
import kotlinx.coroutines.isActive
|
|
|
|
|
+import net.mamoe.mirai.console.MiraiConsole
|
|
|
import net.mamoe.mirai.console.command.CommandExecuteStatus
|
|
import net.mamoe.mirai.console.command.CommandExecuteStatus
|
|
|
|
|
+import net.mamoe.mirai.console.command.CommandPrefix
|
|
|
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
|
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
|
|
import net.mamoe.mirai.console.command.executeCommandDetailed
|
|
import net.mamoe.mirai.console.command.executeCommandDetailed
|
|
|
|
|
+import net.mamoe.mirai.console.job
|
|
|
import net.mamoe.mirai.console.pure.MiraiConsolePure.Companion.start
|
|
import net.mamoe.mirai.console.pure.MiraiConsolePure.Companion.start
|
|
|
import net.mamoe.mirai.console.utils.ConsoleInternalAPI
|
|
import net.mamoe.mirai.console.utils.ConsoleInternalAPI
|
|
|
import net.mamoe.mirai.message.data.Message
|
|
import net.mamoe.mirai.message.data.Message
|
|
@@ -42,8 +45,8 @@ object MiraiConsolePureLoader {
|
|
|
|
|
|
|
|
|
|
|
|
|
internal fun startup() {
|
|
internal fun startup() {
|
|
|
- startConsoleThread()
|
|
|
|
|
MiraiConsolePure().start()
|
|
MiraiConsolePure().start()
|
|
|
|
|
+ startConsoleThread()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
internal fun startConsoleThread() {
|
|
internal fun startConsoleThread() {
|
|
@@ -51,7 +54,11 @@ internal fun startConsoleThread() {
|
|
|
val consoleLogger = DefaultLogger("Console")
|
|
val consoleLogger = DefaultLogger("Console")
|
|
|
kotlinx.coroutines.runBlocking {
|
|
kotlinx.coroutines.runBlocking {
|
|
|
while (isActive) {
|
|
while (isActive) {
|
|
|
- val next = MiraiConsoleFrontEndPure.requestInput("")
|
|
|
|
|
|
|
+ val next = MiraiConsoleFrontEndPure.requestInput("").let {
|
|
|
|
|
+ if (it.startsWith(CommandPrefix)) {
|
|
|
|
|
+ it
|
|
|
|
|
+ } else CommandPrefix + it
|
|
|
|
|
+ }
|
|
|
if (next.isBlank()) {
|
|
if (next.isBlank()) {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
@@ -71,6 +78,10 @@ internal fun startConsoleThread() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ }.let { thread ->
|
|
|
|
|
+ MiraiConsole.job.invokeOnCompletion {
|
|
|
|
|
+ thread.interrupt()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|