From 2ac7d3b20bc9cfa8099f51151e75cde00fd0c531 Mon Sep 17 00:00:00 2001 From: RTAkland Date: Fri, 11 Oct 2024 19:36:22 +0800 Subject: [PATCH] fix: fix message target --- src/main/kotlin/cn/rtast/fancybot/FancyBot.kt | 5 ++++- .../rtast/fancybot/commands/misc/ReactionCommand.kt | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt b/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt index 23b7723..70dc5a6 100644 --- a/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt +++ b/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt @@ -82,7 +82,10 @@ class FancyBot : OneBotListener { val getMsg = this.getMessage(replyId.toString().toLong()) ImageURLCommand.callback(message, getMsg) } - if (command.contains("reaction")) ReactionCommand.reaction(message) + if (command.contains("reaction")) { + val getMsg = this.getMessage(replyId.toString().toLong()) + ReactionCommand.reaction(this, message, getMsg.messageId) + } 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 d57a1d8..8b9db01 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/misc/ReactionCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/misc/ReactionCommand.kt @@ -18,13 +18,17 @@ class ReactionCommand : BaseCommand() { override val commandNames = listOf("reaction", "回应") companion object { - suspend fun reaction(message: GroupMessage, limit: Int = 30) { - (0..limit - 1).forEach { _ -> - message.reaction(QQFace.entries.random()) + suspend fun reaction(listener: OneBotListener, message: GroupMessage, messageId: Long, limit: Int = 30) { + (0..limit - 1).forEach { + listener.reaction( + message.groupId, + messageId, + QQFace.entries.random().id.toString() + ) } } } override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List) = - reaction(message) + reaction(listener, message, message.messageId) } \ No newline at end of file