mirai console shutdown logic

This commit is contained in:
jiahua.liu 2020-02-17 16:56:03 +08:00
parent 2a82fe6b80
commit e284267d47

View File

@ -49,6 +49,8 @@ object MiraiConsole {
var coreVersion = "v0.15.1" var coreVersion = "v0.15.1"
val build = "Beta" val build = "Beta"
var allDown = false
lateinit var frontEnd: MiraiConsoleUI lateinit var frontEnd: MiraiConsoleUI
fun start( fun start(
frontEnd: MiraiConsoleUI frontEnd: MiraiConsoleUI
@ -80,6 +82,7 @@ object MiraiConsole {
fun stop() { fun stop() {
PluginManager.disableAllPlugins() PluginManager.disableAllPlugins()
allDown = true
bots.forEach { bots.forEach {
it.get()?.close() it.get()?.close()
} }
@ -290,6 +293,9 @@ object MiraiConsole {
} }
tailrec fun processNextCommandLine() { tailrec fun processNextCommandLine() {
if (allDown) {
return
}
var fullCommand = commandChannel.poll() var fullCommand = commandChannel.poll()
if (fullCommand != null) { if (fullCommand != null) {
if (!fullCommand.startsWith("/")) { if (!fullCommand.startsWith("/")) {