mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-13 06:30:13 +08:00
Review: misc improvements
This commit is contained in:
parent
7fb9056572
commit
02173d96df
@ -7,6 +7,7 @@ import javafx.stage.StageStyle
|
||||
import kotlinx.coroutines.delay
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.console.command.CommandManager
|
||||
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||
import net.mamoe.mirai.console.graphical.model.*
|
||||
import net.mamoe.mirai.console.graphical.view.VerificationCodeFragment
|
||||
import net.mamoe.mirai.console.plugins.PluginManager
|
||||
@ -30,10 +31,10 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
|
||||
val consoleInfo = ConsoleInfo()
|
||||
|
||||
fun login(qq: String, psd: String) {
|
||||
CommandManager.runConsoleCommand("/login $qq $psd")
|
||||
CommandManager.runCommand(ConsoleCommandSender, "/login $qq $psd")
|
||||
}
|
||||
|
||||
fun sendCommand(command: String) = CommandManager.runConsoleCommand(command)
|
||||
fun sendCommand(command: String) = CommandManager.runCommand(ConsoleCommandSender, command)
|
||||
|
||||
override fun pushLog(identity: Long, message: String) = Platform.runLater {
|
||||
fun ObservableList<*>.trim() {
|
||||
|
@ -23,6 +23,7 @@ import net.mamoe.mirai.console.MiraiConsoleTerminalUI.LoggerDrawer.cleanPage
|
||||
import net.mamoe.mirai.console.MiraiConsoleTerminalUI.LoggerDrawer.drawLog
|
||||
import net.mamoe.mirai.console.MiraiConsoleTerminalUI.LoggerDrawer.redrawLogs
|
||||
import net.mamoe.mirai.console.command.CommandManager
|
||||
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||
import net.mamoe.mirai.console.utils.MiraiConsoleUI
|
||||
import net.mamoe.mirai.utils.LoginSolver
|
||||
import net.mamoe.mirai.utils.SimpleLogger.LogPriority
|
||||
@ -124,7 +125,7 @@ object MiraiConsoleTerminalUI : MiraiConsoleUI {
|
||||
requestResult = input
|
||||
requesting = false
|
||||
} else {
|
||||
CommandManager.runConsoleCommand(commandBuilder.toString())
|
||||
CommandManager.runCommand(ConsoleCommandSender, commandBuilder.toString())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,11 @@
|
||||
|
||||
package net.mamoe.mirai.console
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.console.command.CommandManager
|
||||
import net.mamoe.mirai.console.command.CommandSender
|
||||
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||
import net.mamoe.mirai.console.command.DefaultCommands
|
||||
import net.mamoe.mirai.console.plugins.PluginManager
|
||||
import net.mamoe.mirai.console.utils.MiraiConsoleUI
|
||||
@ -45,14 +46,16 @@ object MiraiConsole {
|
||||
* Console运行路径
|
||||
*/
|
||||
var path: String = System.getProperty("user.dir")
|
||||
internal set
|
||||
|
||||
/**
|
||||
* Console前端接口
|
||||
*/
|
||||
lateinit var frontEnd: MiraiConsoleUI
|
||||
internal set
|
||||
|
||||
|
||||
var start = false
|
||||
private var started = false
|
||||
|
||||
|
||||
/**
|
||||
@ -63,10 +66,10 @@ object MiraiConsole {
|
||||
coreVersion: String = "0.0.0",
|
||||
consoleVersion: String = "0.0.0"
|
||||
) {
|
||||
if (start) {
|
||||
if (started) {
|
||||
return
|
||||
}
|
||||
start = true
|
||||
started = true
|
||||
|
||||
/* 初始化前端 */
|
||||
this.version = consoleVersion
|
||||
@ -110,49 +113,55 @@ object MiraiConsole {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("RedundantSuspendModifier") // binary compatibility
|
||||
@Deprecated("Please use CommandManager directly, this will be removed in later release")
|
||||
object CommandProcessor{
|
||||
@Deprecated("Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runConsoleCommand(command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
)
|
||||
object CommandProcessor {
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runConsoleCommand(command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
), level = DeprecationLevel.ERROR
|
||||
)
|
||||
suspend fun runConsoleCommand(command: String) {
|
||||
CommandManager.runConsoleCommand(command)
|
||||
}
|
||||
@Deprecated("Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runCommand(sender, command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
)
|
||||
)
|
||||
suspend fun runCommand(sender: CommandSender, command: String) {
|
||||
CommandManager.runCommand(sender,command)
|
||||
CommandManager.runCommand(ConsoleCommandSender, command)
|
||||
}
|
||||
|
||||
@Deprecated("Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runConsoleCommand(command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runCommand(sender, command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
), level = DeprecationLevel.ERROR
|
||||
)
|
||||
suspend fun runCommand(sender: CommandSender, command: String) {
|
||||
CommandManager.runCommand(sender, command)
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runCommand(command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager",
|
||||
"net.mamoe.mirai.console.command.ConsoleCommandSender"
|
||||
), level = DeprecationLevel.ERROR
|
||||
)
|
||||
fun runConsoleCommandBlocking(command: String) = runBlocking { runConsoleCommand(command)}
|
||||
fun runConsoleCommandBlocking(command: String) =
|
||||
runBlocking { CommandManager.runCommand(ConsoleCommandSender, command) }
|
||||
|
||||
|
||||
@Suppress("unused")
|
||||
@Deprecated("Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runCommand(sender, command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runCommand(sender, command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
)
|
||||
)
|
||||
)
|
||||
fun runCommandBlocking(sender: CommandSender, command: String) = runBlocking { runCommand(sender, command) }
|
||||
fun runCommandBlocking(sender: CommandSender, command: String) = runBlocking {
|
||||
CommandManager.runCommand(sender, command)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mirai Console的logger
|
||||
* 它用于适配不同的Console前段
|
||||
*/
|
||||
internal object MiraiConsoleLogger {
|
||||
operator fun invoke(any: Any? = null) {
|
||||
invoke(
|
||||
|
@ -143,7 +143,7 @@ object DefaultCommands {
|
||||
startsWith("/") { message ->
|
||||
if (bot.checkManager(this.sender.id)) {
|
||||
val sender = ContactCommandSender(this.subject)
|
||||
MiraiConsole.CommandProcessor.runCommand(
|
||||
CommandManager.runCommand(
|
||||
sender, message
|
||||
)
|
||||
}
|
||||
|
@ -14,14 +14,3 @@ import net.mamoe.mirai.event.Event
|
||||
import net.mamoe.mirai.event.broadcast
|
||||
|
||||
internal fun <E : Event> broadcast(e: E): E = runBlocking { e.broadcast() }
|
||||
|
||||
class A{
|
||||
|
||||
var x = 0
|
||||
|
||||
var width:Int
|
||||
get() = x
|
||||
set(value){
|
||||
x = value
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ package net.mamoe.mirai.console.pure
|
||||
import kotlinx.coroutines.delay
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.console.command.CommandManager
|
||||
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||
import net.mamoe.mirai.console.utils.MiraiConsoleUI
|
||||
import net.mamoe.mirai.utils.DefaultLoginSolver
|
||||
import net.mamoe.mirai.utils.LoginSolver
|
||||
@ -49,7 +50,7 @@ class MiraiConsoleUIPure : MiraiConsoleUI {
|
||||
requestStr = input
|
||||
requesting = false
|
||||
} else {
|
||||
CommandManager.runConsoleCommand(input)
|
||||
CommandManager.runCommand(ConsoleCommandSender, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user