diff --git a/README.md b/README.md index 5de5177bf..62d24d219 100644 --- a/README.md +++ b/README.md @@ -187,3 +187,4 @@ bot.subscribeAlways { ## Acknowledgement 特别感谢 [JetBrains](https://www.jetbrains.com/?from=mirai) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai) 等 IDE 的授权 [](https://www.jetbrains.com/?from=mirai) + \ No newline at end of file diff --git a/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleTerminalLoader.kt b/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleTerminalLoader.kt index 33ca3c002..d302d7db7 100644 --- a/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleTerminalLoader.kt +++ b/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleTerminalLoader.kt @@ -6,11 +6,20 @@ class MiraiConsoleTerminalLoader { companion object { @JvmStatic fun main(args: Array) { - MiraiConsoleTerminalUI.start() - thread { - MiraiConsole.start( - MiraiConsoleTerminalUI - ) + if (args.contains("pure") || args.contains("-pure") || System.getProperty( + "os.name", + "" + ).toLowerCase().contains("windows") + ) { + println("[MiraiConsoleTerminalLoader]: 将以Pure[兼容模式]启动Console") + MiraiConsole.start(MiraiConsoleUIPure) + } else { + MiraiConsoleTerminalUI.start() + thread { + MiraiConsole.start( + MiraiConsoleTerminalUI + ) + } } Runtime.getRuntime().addShutdownHook(thread(start = false) { MiraiConsole.stop() diff --git a/mirai-console/build.gradle.kts b/mirai-console/build.gradle.kts index 540eeb6ff..ea4cb0589 100644 --- a/mirai-console/build.gradle.kts +++ b/mirai-console/build.gradle.kts @@ -23,6 +23,11 @@ fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$v fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version" +tasks.withType() { + manifest { + attributes["Main-Class"] = "net.mamoe.mirai.console.MiraiConsoleUIPureLoader" + } +} dependencies { diff --git a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleUIPure.kt b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleUIPure.kt new file mode 100644 index 000000000..de07c0c10 --- /dev/null +++ b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleUIPure.kt @@ -0,0 +1,50 @@ +package net.mamoe.mirai.console + +import net.mamoe.mirai.Bot +import net.mamoe.mirai.utils.DefaultLoginSolver +import net.mamoe.mirai.utils.LoginSolver +import kotlin.concurrent.thread + +object MiraiConsoleUIPure : MiraiConsoleUI { + override fun pushLog(identity: Long, message: String) { + println(message) + } + + override fun prePushBot(identity: Long) { + + } + + override fun pushBot(bot: Bot) { + + } + + override fun pushVersion(consoleVersion: String, consoleBuild: String, coreVersion: String) { + + } + + override suspend fun requestInput(question: String): String { + return readLine() ?: "" + } + + override fun pushBotAdminStatus(identity: Long, admins: List) { + + } + + override fun createLoginSolver(): LoginSolver { + return DefaultLoginSolver() + } + +} + + +class MiraiConsolePureLoader { + companion object { + @JvmStatic + fun main(args: Array) { + MiraiConsole.start(MiraiConsoleUIPure) + Runtime.getRuntime().addShutdownHook(thread(start = false) { + MiraiConsole.stop() + }) + } + } +} \ No newline at end of file