chore: improve help command
This commit is contained in:
1 file changed
+5
-1
@@ -12,6 +12,7 @@ import cn.rtast.fancybot.commands
|
|||||||
import cn.rtast.rob.entity.GroupMessage
|
import cn.rtast.rob.entity.GroupMessage
|
||||||
import cn.rtast.rob.util.BaseCommand
|
import cn.rtast.rob.util.BaseCommand
|
||||||
import cn.rtast.rob.util.ob.MessageChain
|
import cn.rtast.rob.util.ob.MessageChain
|
||||||
|
import cn.rtast.rob.util.ob.NodeMessageChain
|
||||||
import cn.rtast.rob.util.ob.OneBotListener
|
import cn.rtast.rob.util.ob.OneBotListener
|
||||||
import kotlin.reflect.full.findAnnotation
|
import kotlin.reflect.full.findAnnotation
|
||||||
import kotlin.reflect.full.hasAnnotation
|
import kotlin.reflect.full.hasAnnotation
|
||||||
@@ -21,6 +22,7 @@ class HelpCommand : BaseCommand() {
|
|||||||
override val commandNames = listOf("/help", "/帮助")
|
override val commandNames = listOf("/help", "/帮助")
|
||||||
|
|
||||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||||
|
val node = NodeMessageChain.Builder()
|
||||||
val msg = MessageChain.Builder()
|
val msg = MessageChain.Builder()
|
||||||
commands.sortedBy { it::class.simpleName }.forEach {
|
commands.sortedBy { it::class.simpleName }.forEach {
|
||||||
val description = if (!it::class.hasAnnotation<CommandDescription>()) "暂无描述"
|
val description = if (!it::class.hasAnnotation<CommandDescription>()) "暂无描述"
|
||||||
@@ -30,6 +32,8 @@ class HelpCommand : BaseCommand() {
|
|||||||
msg.addText("[$commandName] [$description] 命令: $commandNames")
|
msg.addText("[$commandName] [$description] 命令: $commandNames")
|
||||||
.addNewLine()
|
.addNewLine()
|
||||||
}
|
}
|
||||||
message.reply(msg.build())
|
msg.addText("共计${commands.size}条命令")
|
||||||
|
node.addMessageChain(msg.build(), message.sender.userId)
|
||||||
|
message.reply(node.build())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user