Mirai Console (Terminal)V0.01

This commit is contained in:
jiahua.liu 2020-02-16 17:47:26 +08:00
parent d0fb1383a0
commit 758ea29caa
3 changed files with 21 additions and 5 deletions

View File

@ -44,6 +44,11 @@ import kotlin.system.exitProcess
object MiraiConsoleTerminalUI : MiraiConsoleUI { object MiraiConsoleTerminalUI : MiraiConsoleUI {
val cacheLogSize = 50 val cacheLogSize = 50
var mainTitle = "Mirai Console v0.01 Core v0.15"
override fun pushVersion(consoleVersion: String, consoleBuild: String, coreVersion: String) {
mainTitle = "Mirai Console(Terminal) $consoleVersion $consoleBuild Core $coreVersion"
}
override fun pushLog(identity: Long, message: String) { override fun pushLog(identity: Long, message: String) {
log[identity]!!.push(message) log[identity]!!.push(message)
@ -70,7 +75,7 @@ object MiraiConsoleTerminalUI : MiraiConsoleUI {
override suspend fun requestInput(question: String): String { override suspend fun requestInput(question: String): String {
requesting = true requesting = true
while (requesting) { while (requesting) {
Thread.sleep(100)//不然会卡死 迷惑吧 delay(100)//不然会卡死 迷惑吧
} }
return requestResult!! return requestResult!!
} }
@ -96,6 +101,7 @@ object MiraiConsoleTerminalUI : MiraiConsoleUI {
val log = ConcurrentHashMap<Long, LimitLinkedQueue<String>>().also { val log = ConcurrentHashMap<Long, LimitLinkedQueue<String>>().also {
it[0L] = LimitLinkedQueue(cacheLogSize) it[0L] = LimitLinkedQueue(cacheLogSize)
} }
val botAdminCount = ConcurrentHashMap<Long, Int>() val botAdminCount = ConcurrentHashMap<Long, Int>()
private val screens = mutableListOf(0L) private val screens = mutableListOf(0L)
@ -294,7 +300,6 @@ object MiraiConsoleTerminalUI : MiraiConsoleUI {
val height = terminal.terminalSize.rows val height = terminal.terminalSize.rows
terminal.setBackgroundColor(TextColor.ANSI.DEFAULT) terminal.setBackgroundColor(TextColor.ANSI.DEFAULT)
val mainTitle = "Mirai Console v0.01 Core v0.15"
textGraphics.foregroundColor = TextColor.ANSI.WHITE textGraphics.foregroundColor = TextColor.ANSI.WHITE
textGraphics.backgroundColor = TextColor.ANSI.GREEN textGraphics.backgroundColor = TextColor.ANSI.GREEN
textGraphics.putString((width - mainTitle.length) / 2, 1, mainTitle, SGR.BOLD) textGraphics.putString((width - mainTitle.length) / 2, 1, mainTitle, SGR.BOLD)

View File

@ -45,8 +45,8 @@ object MiraiConsole {
var path: String = System.getProperty("user.dir") var path: String = System.getProperty("user.dir")
val version = "0.01" val version = "v0.01"
var coreVersion = "0.15" var coreVersion = "v0.15.1"
val build = "Beta" val build = "Beta"
lateinit var frontEnd: MiraiConsoleUI lateinit var frontEnd: MiraiConsoleUI
@ -54,7 +54,10 @@ object MiraiConsole {
frontEnd: MiraiConsoleUI frontEnd: MiraiConsoleUI
) { ) {
this.frontEnd = frontEnd this.frontEnd = frontEnd
logger("Mirai-console [v$version $build | core version v$coreVersion] is still in testing stage, majority feature is available") frontEnd.pushVersion(
version, build, coreVersion
)
logger("Mirai-console [$version $build | core version $coreVersion] is still in testing stage, majority feature is available")
logger( logger(
"Mirai-console now running under " + System.getProperty( "Mirai-console now running under " + System.getProperty(
"user.dir" "user.dir"

View File

@ -32,6 +32,13 @@ interface MiraiConsoleUI {
bot: Bot bot: Bot
) )
fun pushVersion(
consoleVersion: String,
consoleBuild: String,
coreVersion: String
)
/** /**
* 让UI层提供一个Input * 让UI层提供一个Input
* 这个Input 等于 Command * 这个Input 等于 Command
@ -41,6 +48,7 @@ interface MiraiConsoleUI {
question: String question: String
): String ): String
/** /**
* 让UI层更新BOT管理员的数据 * 让UI层更新BOT管理员的数据
*/ */