mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-17 09:39:49 +08:00
Pure mode supported
This commit is contained in:
parent
72cd7b3319
commit
3eeb640f77
@ -187,3 +187,4 @@ bot.subscribeAlways<MemberPermissionChangedEvent> {
|
||||
## Acknowledgement
|
||||
特别感谢 [JetBrains](https://www.jetbrains.com/?from=mirai) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai) 等 IDE 的授权
|
||||
[<img src=".github/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=mirai)
|
||||
|
@ -6,11 +6,20 @@ class MiraiConsoleTerminalLoader {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
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()
|
||||
|
@ -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<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>() {
|
||||
manifest {
|
||||
attributes["Main-Class"] = "net.mamoe.mirai.console.MiraiConsoleUIPureLoader"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
|
@ -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<Long>) {
|
||||
|
||||
}
|
||||
|
||||
override fun createLoginSolver(): LoginSolver {
|
||||
return DefaultLoginSolver()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class MiraiConsolePureLoader {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
MiraiConsole.start(MiraiConsoleUIPure)
|
||||
Runtime.getRuntime().addShutdownHook(thread(start = false) {
|
||||
MiraiConsole.stop()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user