feat: add buy me a coffee command(打钱)

This commit is contained in:
2024-10-07 20:12:04 +08:00
parent b0ae938722
commit 0ad3314ddb
3 files changed
+36 -4

No files matched your search

+3 -1
View File
@@ -12,6 +12,7 @@ import cn.rtast.fancybot.commands.AboutCommand
import cn.rtast.fancybot.commands.EchoCommand import cn.rtast.fancybot.commands.EchoCommand
import cn.rtast.fancybot.commands.HelpCommand import cn.rtast.fancybot.commands.HelpCommand
import cn.rtast.fancybot.commands.StatusCommand import cn.rtast.fancybot.commands.StatusCommand
import cn.rtast.fancybot.commands.SupportMeCommand
import cn.rtast.fancybot.commands.lookup.* import cn.rtast.fancybot.commands.lookup.*
import cn.rtast.fancybot.commands.misc.* import cn.rtast.fancybot.commands.misc.*
import cn.rtast.fancybot.commands.niuzi.* import cn.rtast.fancybot.commands.niuzi.*
@@ -119,5 +120,6 @@ val commands = listOf(
ReactionCommand(), MCSkinCommand(), ReactionCommand(), MCSkinCommand(),
GithubLatestCommitCommand(), RandomMusicCommand(), GithubLatestCommitCommand(), RandomMusicCommand(),
ZDJDCommand(), ScanQRCodeCommand(), ZDJDCommand(), ScanQRCodeCommand(),
TTSCommand(), SlimeChunkHelperCommand() TTSCommand(), SlimeChunkHelperCommand(),
SupportMeCommand()
) )
@@ -26,13 +26,12 @@ class HelpCommand : BaseCommand() {
if (args.isEmpty()) { if (args.isEmpty()) {
val node = NodeMessageChain.Builder() val node = NodeMessageChain.Builder()
val msg = MessageChain.Builder() val msg = MessageChain.Builder()
commands.sortedBy { it::class.simpleName }.forEach { commands.sortedBy { it::class.simpleName }.toMutableList().forEach {
val description = if (!it::class.hasAnnotation<CommandDescription>()) "暂无描述" val description = if (!it::class.hasAnnotation<CommandDescription>()) "暂无描述"
else it::class.findAnnotation<CommandDescription>()?.description!! else it::class.findAnnotation<CommandDescription>()?.description!!
val commandName = it::class.simpleName?.replace("Command", "")!! val commandName = it::class.simpleName?.replace("Command", "")!!
val commandNames = it.commandNames.joinToString(",") val commandNames = it.commandNames.joinToString(",")
msg.addText("[$commandName] [$description] 命令: $commandNames") msg.addText("[$commandName] [$description] 命令: $commandNames").addNewLine()
.addNewLine()
} }
msg.addText("共计${commands.size}条命令") msg.addText("共计${commands.size}条命令")
node.addMessageChain(msg.build(), configManager.selfId) node.addMessageChain(msg.build(), configManager.selfId)
@@ -0,0 +1,31 @@
/*
* Copyright © 2024 RTAkland
* Author: RTAkland
* Date: 2024/10/7
*/
package cn.rtast.fancybot.commands
import cn.rtast.fancybot.ASSETS_BASE_URL
import cn.rtast.fancybot.annotations.CommandDescription
import cn.rtast.fancybot.util.str.encodeToBase64
import cn.rtast.rob.entity.GroupMessage
import cn.rtast.rob.util.BaseCommand
import cn.rtast.rob.util.ob.MessageChain
import cn.rtast.rob.util.ob.OneBotListener
import java.net.URI
@CommandDescription("给我打钱!")
class SupportMeCommand : BaseCommand() {
override val commandNames = listOf("打钱", "给我打钱")
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
val image = URI("$ASSETS_BASE_URL/images/048cc8af57f19850ca176f29e50b6215.png")
.toURL().readBytes().encodeToBase64()
val msg = MessageChain.Builder()
.addImage(image, true)
.build()
message.reply(msg)
}
}