diff --git a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt index b95d35684..17bc58c21 100644 --- a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt +++ b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt @@ -106,13 +106,13 @@ interface CommandSender { } abstract class CommandSenderImpl : CommandSender { - private val builder = StringBuilder() + internal val builder = StringBuilder() override fun appendMessage(message: String) { builder.append(message).append("\n") } - internal suspend fun flushMessage() { + internal open suspend fun flushMessage() { if (!builder.isEmpty()) { sendMessage(builder.toString().removeSuffix("\n")) } @@ -127,6 +127,11 @@ object ConsoleCommandSender : CommandSenderImpl() { override suspend fun sendMessage(message: String) { MiraiConsole.logger("[Command]", 0, message) } + + override suspend fun flushMessage() { + super.flushMessage() + builder.clear() + } } open class ContactCommandSender(val contact: Contact) : CommandSenderImpl() { diff --git a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/DefaultCommands.kt b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/DefaultCommands.kt index 6f13bd9b0..651eb423b 100644 --- a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/DefaultCommands.kt +++ b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/DefaultCommands.kt @@ -237,6 +237,7 @@ object DefaultCommands { onCommand { CommandManager.getCommands().let { var size = 0 + appendMessage("")//\n it.toSet().forEach { ++size appendMessage("-> " + it.name + " :" + it.description)