mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-18 05:22:24 +08:00
Pure mode supported
This commit is contained in:
parent
72cd7b3319
commit
3eeb640f77
@ -187,3 +187,4 @@ bot.subscribeAlways<MemberPermissionChangedEvent> {
|
|||||||
## Acknowledgement
|
## Acknowledgement
|
||||||
特别感谢 [JetBrains](https://www.jetbrains.com/?from=mirai) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai) 等 IDE 的授权
|
特别感谢 [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)
|
[<img src=".github/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=mirai)
|
||||||
|
|
@ -6,12 +6,21 @@ class MiraiConsoleTerminalLoader {
|
|||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
if (args.contains("pure") || args.contains("-pure") || System.getProperty(
|
||||||
|
"os.name",
|
||||||
|
""
|
||||||
|
).toLowerCase().contains("windows")
|
||||||
|
) {
|
||||||
|
println("[MiraiConsoleTerminalLoader]: 将以Pure[兼容模式]启动Console")
|
||||||
|
MiraiConsole.start(MiraiConsoleUIPure)
|
||||||
|
} else {
|
||||||
MiraiConsoleTerminalUI.start()
|
MiraiConsoleTerminalUI.start()
|
||||||
thread {
|
thread {
|
||||||
MiraiConsole.start(
|
MiraiConsole.start(
|
||||||
MiraiConsoleTerminalUI
|
MiraiConsoleTerminalUI
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Runtime.getRuntime().addShutdownHook(thread(start = false) {
|
Runtime.getRuntime().addShutdownHook(thread(start = false) {
|
||||||
MiraiConsole.stop()
|
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"
|
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 {
|
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