From 5ac05f052a5e7f8bb5c341fe05b0dd7fac05edb5 Mon Sep 17 00:00:00 2001 From: RTAkland Date: Fri, 11 Oct 2024 19:28:22 +0800 Subject: [PATCH] feat: add reaction other's message command --- src/main/kotlin/cn/rtast/fancybot/FancyBot.kt | 3 ++- .../rtast/fancybot/commands/misc/ReactionCommand.kt | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt b/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt index e2b04a7..23b7723 100644 --- a/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt +++ b/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt @@ -7,6 +7,7 @@ package cn.rtast.fancybot +import cn.rtast.fancybot.commands.misc.ReactionCommand import cn.rtast.fancybot.commands.misc.ScanQRCodeCommand import cn.rtast.fancybot.commands.misc.ShortLinkCommand.Companion.makeShortLink import cn.rtast.fancybot.commands.parse.* @@ -81,7 +82,7 @@ class FancyBot : OneBotListener { val getMsg = this.getMessage(replyId.toString().toLong()) ImageURLCommand.callback(message, getMsg) } - + if (command.contains("reaction")) ReactionCommand.reaction(message) if (command.contains("图床")) { val getMsg = this.getMessage(replyId.toString().toLong()) val imagesUrl = ImageURLCommand.getImageUrl(getMsg) diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/misc/ReactionCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/misc/ReactionCommand.kt index 2f21d80..d57a1d8 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/misc/ReactionCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/misc/ReactionCommand.kt @@ -17,9 +17,14 @@ import cn.rtast.rob.util.ob.OneBotListener class ReactionCommand : BaseCommand() { override val commandNames = listOf("reaction", "回应") - override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List) { - (0..29).forEach { _ -> - message.reaction(QQFace.entries.random()) + companion object { + suspend fun reaction(message: GroupMessage, limit: Int = 30) { + (0..limit - 1).forEach { _ -> + message.reaction(QQFace.entries.random()) + } } } + + override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List) = + reaction(message) } \ No newline at end of file