2024-09-03 16:15:26 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2024 RTAkland
|
|
|
|
|
* Author: RTAkland
|
|
|
|
|
* Date: 2024/9/3
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package cn.rtast.fancybot.commands
|
|
|
|
|
|
2024-09-26 05:20:10 +08:00
|
|
|
import cn.rtast.fancybot.annotations.CommandDescription
|
2024-09-03 16:15:26 +08:00
|
|
|
import cn.rtast.fancybot.commands
|
|
|
|
|
import cn.rtast.rob.entity.GroupMessage
|
|
|
|
|
import cn.rtast.rob.util.BaseCommand
|
|
|
|
|
import cn.rtast.rob.util.ob.MessageChain
|
2024-09-19 11:06:40 +08:00
|
|
|
import cn.rtast.rob.util.ob.OneBotListener
|
2024-09-03 16:15:26 +08:00
|
|
|
|
2024-09-26 05:21:42 +08:00
|
|
|
@CommandDescription("帮助")
|
2024-09-03 16:15:26 +08:00
|
|
|
class HelpCommand : BaseCommand() {
|
|
|
|
|
override val commandNames = listOf("/help", "/帮助")
|
|
|
|
|
|
2024-09-19 11:06:40 +08:00
|
|
|
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
2024-09-03 16:15:26 +08:00
|
|
|
val msg = MessageChain.Builder()
|
2024-09-26 05:20:10 +08:00
|
|
|
commands.sortedBy { it::class.simpleName }.forEach {
|
|
|
|
|
val description =
|
|
|
|
|
if (!it.javaClass.isAnnotationPresent(CommandDescription::class.java)) {
|
|
|
|
|
"暂无描述"
|
|
|
|
|
} else {
|
|
|
|
|
it.javaClass.getAnnotation(CommandDescription::class.java)?.description!!
|
|
|
|
|
}
|
|
|
|
|
val commandName = it::class.simpleName?.replace("Command", "")!!
|
|
|
|
|
val commandNames = it.commandNames.joinToString(",")
|
|
|
|
|
msg.addText("[$commandName] [$description] 命令: $commandNames")
|
|
|
|
|
.addNewLine()
|
|
|
|
|
}
|
|
|
|
|
message.reply(msg.build())
|
2024-09-03 16:15:26 +08:00
|
|
|
}
|
|
|
|
|
}
|