mirror of
https://github.com/mamoe/mirai.git
synced 2024-12-29 10:00:13 +08:00
fix command sender flush bug
This commit is contained in:
parent
a126e3f660
commit
9ff70b0dbb
@ -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() {
|
||||
|
@ -237,6 +237,7 @@ object DefaultCommands {
|
||||
onCommand {
|
||||
CommandManager.getCommands().let {
|
||||
var size = 0
|
||||
appendMessage("")//\n
|
||||
it.toSet().forEach {
|
||||
++size
|
||||
appendMessage("-> " + it.name + " :" + it.description)
|
||||
|
Loading…
Reference in New Issue
Block a user