From 32c822c3a11bd1190b2e69e6a3d2d8ee9c64c307 Mon Sep 17 00:00:00 2001 From: RTAkland Date: Sat, 28 Sep 2024 16:31:55 +0800 Subject: [PATCH] chore: improve rdm command --- gradle/libs.versions.toml | 2 +- src/main/kotlin/cn/rtast/fancybot/Const.kt | 4 +-- src/main/kotlin/cn/rtast/fancybot/FancyBot.kt | 8 +++-- .../cn/rtast/fancybot/commands/HelpCommand.kt | 3 +- .../fancybot/commands/lookup/AICommand.kt | 4 +-- .../commands/lookup/CigaretteCommand.kt | 5 ++-- .../commands/lookup/DMSearchCommand.kt | 5 ++-- .../fancybot/commands/lookup/MusicCommand.kt | 30 +++++-------------- .../fancybot/commands/lookup/PixivCommand.kt | 7 +++-- .../fancybot/commands/lookup/ShotCommand.kt | 2 +- .../commands/misc/BullShitGenerateCommand.kt | 3 +- .../fancybot/commands/misc/SendMailCommand.kt | 12 ++------ .../fancybot/commands/misc/TenSetuCommand.kt | 5 ++-- .../commands/niuzi/NiuziRedeemCommand.kt | 21 ++++++------- .../cn/rtast/fancybot/items/BaisiItem.kt | 10 +++++-- .../cn/rtast/fancybot/items/HeisiItem.kt | 10 +++++-- .../cn/rtast/fancybot/items/NiuziItem.kt | 9 ++++-- .../cn/rtast/fancybot/items/SetuItem.kt | 13 ++++---- .../cn/rtast/fancybot/util/item/Item.kt | 11 +++---- 19 files changed, 82 insertions(+), 82 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e268a32..b167771 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] kotlinVersion = "2.0.10" -ronebotVersion = "1.11.4" +ronebotVersion = "1.11.5" shadowVersion = "8.3.0" okhttpVersion = "5.0.0-alpha.14" exposedVersion = "0.53.0" diff --git a/src/main/kotlin/cn/rtast/fancybot/Const.kt b/src/main/kotlin/cn/rtast/fancybot/Const.kt index 07d84c4..58f57ac 100644 --- a/src/main/kotlin/cn/rtast/fancybot/Const.kt +++ b/src/main/kotlin/cn/rtast/fancybot/Const.kt @@ -76,8 +76,8 @@ val niuziBankManager = NiuziBankManager() val START_UP_TIME = Instant.now().epochSecond val items = listOf( - HeisiItem(), BaisiItem(), SetuItem(), - NiuziItem() + HeisiItem(), BaisiItem(), + SetuItem(), NiuziItem() ) val commands = listOf( diff --git a/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt b/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt index b1f633c..2fe4230 100644 --- a/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt +++ b/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt @@ -39,13 +39,17 @@ class FancyBot : OneBotListener { val messageId = message.messageId println("$sender($senderId: $groupId >>> $messageId): $msg") - ReverseGIFCommand.callback(message) - AsciiArtCommand.callback(message) + if (message.message.any { it.type == ArrayMessageType.face && it.data.id.toString() == "419" }) { + message.reply("你发牛魔的火车呢, 我直接就是打断") + } if (message.rawMessage.contains("原神")) { message.reply("你原神牛魔呢") } + ReverseGIFCommand.callback(message) + AsciiArtCommand.callback(message) + if (message.rawMessage.toList().any { it in arrayListOf('*', '-', '/', '+', '=') }) { val calculateResult = CalculateCommand.parse(message.rawMessage) calculateResult?.let { message.reply(calculateResult) } diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/HelpCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/HelpCommand.kt index 5b819a3..2c09c69 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/HelpCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/HelpCommand.kt @@ -9,6 +9,7 @@ package cn.rtast.fancybot.commands import cn.rtast.fancybot.annotations.CommandDescription import cn.rtast.fancybot.commands +import cn.rtast.fancybot.configManager import cn.rtast.rob.entity.GroupMessage import cn.rtast.rob.util.BaseCommand import cn.rtast.rob.util.ob.MessageChain @@ -34,7 +35,7 @@ class HelpCommand : BaseCommand() { .addNewLine() } msg.addText("共计${commands.size}条命令") - node.addMessageChain(msg.build(), message.sender.userId) + node.addMessageChain(msg.build(), configManager.selfId) message.reply(node.build()) } else { val commandName = args.first().replace("/", "") diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/AICommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/AICommand.kt index af3e374..425a356 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/AICommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/AICommand.kt @@ -66,7 +66,7 @@ class AICommand : BaseCommand() { val msg = MessageChain.Builder() .addText(response.choices.first().message.content) .build() - nodeMsg.addMessageChain(msg, message.sender.userId) + nodeMsg.addMessageChain(msg, configManager.selfId) listener.sendGroupForwardMsg(message.groupId, nodeMsg.build()) } } @@ -92,7 +92,7 @@ class LlamaCommand : BaseCommand() { .addNewLine() .addText(response.message.content) .build() - nodeMsg.addMessageChain(msg, message.sender.userId) + nodeMsg.addMessageChain(msg, configManager.selfId) listener.sendGroupForwardMsg(message.groupId, nodeMsg.build()) } } \ No newline at end of file diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/CigaretteCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/CigaretteCommand.kt index 7154c51..4c29776 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/CigaretteCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/CigaretteCommand.kt @@ -8,6 +8,7 @@ package cn.rtast.fancybot.commands.lookup import cn.rtast.fancybot.annotations.CommandDescription +import cn.rtast.fancybot.configManager import cn.rtast.fancybot.entity.cigarette.Cigarette import cn.rtast.fancybot.util.Http import cn.rtast.fancybot.util.str.encodeToBase64 @@ -53,12 +54,12 @@ class CigaretteCommand : BaseCommand() { .addText("参考价: 单盒: ${it.packPrice}元 | 整条: ${it.barPrice}元") .addNewLine() .build() - nodeMsg.addMessageChain(tempMsg, message.sender.userId) + nodeMsg.addMessageChain(tempMsg, configManager.selfId) } val footerMsg = MessageChain.Builder() .addText("吸烟有害健康, 尽早戒烟有益健康。") .build() - nodeMsg.addMessageChain(footerMsg, message.sender.userId) + nodeMsg.addMessageChain(footerMsg, configManager.selfId) message.reply(nodeMsg.build()) message.sender.groupPoke() } diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/DMSearchCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/DMSearchCommand.kt index 91e3019..78de39a 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/DMSearchCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/DMSearchCommand.kt @@ -8,6 +8,7 @@ package cn.rtast.fancybot.commands.lookup import cn.rtast.fancybot.annotations.CommandDescription +import cn.rtast.fancybot.configManager import cn.rtast.fancybot.entity.bgm.BGMSearch import cn.rtast.fancybot.util.Http import cn.rtast.fancybot.util.str.encodeToBase64 @@ -53,10 +54,10 @@ class DMSearchCommand : BaseCommand() { .addNewLine() .addText(it.url) .build() - nodeMsg.addMessageChain(tempMsg, message.sender.userId) + nodeMsg.addMessageChain(tempMsg, configManager.selfId) } val footerNode = MessageChain.Builder().addText("数据来源: Bangumi").build() - nodeMsg.addMessageChain(footerNode, message.sender.userId) + nodeMsg.addMessageChain(footerNode, configManager.selfId) listener.sendGroupForwardMsg(message.groupId, nodeMsg.build()) } catch (_: Exception) { message.reply("没有搜索到结果呢~") diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/MusicCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/MusicCommand.kt index 9000b0b..7cf3be7 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/MusicCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/MusicCommand.kt @@ -45,11 +45,7 @@ class MusicCommand : BaseCommand() { private suspend fun legacyMusicCommand(listener: OneBotListener, message: GroupMessage, args: List) { if (args.isEmpty()) { - val msg = MessageChain.Builder() - .addAt(message.sender.userId) - .addText("发送`/点歌`或者`/music` <关键词> 来搜索音乐~") - .build() - listener.sendGroupMessage(message.groupId, msg) + message.reply("发送`/点歌` <关键词> 来搜索音乐~") return } searchedResult.forEach { (key, results) -> @@ -72,13 +68,9 @@ class MusicCommand : BaseCommand() { val msg = MessageChain.Builder() .addMusicShare(MusicShareType.Netease, finalResult.id.toString()) .build() - listener.sendGroupMessage(message.groupId, msg) + message.reply(msg) } catch (_: Exception) { - val msg = MessageChain.Builder() - .addAt(message.sender.userId) - .addText("输入有误请重新搜索本次搜索结果已清除") - .build() - listener.sendGroupMessage(message.groupId, msg) + message.reply("输入有误请重新搜索本次搜索结果已清除") } searchedResult.remove(message.sender.userId) } @@ -86,11 +78,7 @@ class MusicCommand : BaseCommand() { else -> { if (searchedResult.containsKey(message.sender.userId)) { searchedResult.remove(message.sender.userId) - val msg = MessageChain.Builder() - .addAt(message.sender.userId) - .addText("你上次的搜索结果还没用呢, 已经帮你把上次的搜索结果清除掉啦~") - .build() - listener.sendGroupMessage(message.groupId, msg) + message.reply("你上次的搜索结果还没用呢, 已经帮你把上次的搜索结果清除掉啦~") } val keyword = args.joinToString(" ") val result = searchSong(keyword) @@ -105,11 +93,7 @@ class MusicCommand : BaseCommand() { stringResult.append("| $index | 《${searchedResult.name}》-- ${searchedResult.artists}\n") } stringResult.append("输入/music p <序号> 播放\n你有30秒的时间进行操作") - val msg = MessageChain.Builder() - .addAt(message.sender.userId) - .addText(stringResult.toString()) - .build() - listener.sendGroupMessage(message.groupId, msg) + message.reply(stringResult.toString()) } } } @@ -121,7 +105,7 @@ class MusicCommand : BaseCommand() { } if (args.isEmpty()) { val msg = MessageChain.Builder() - .addAt(message.sender.userId) + .addReply(message.messageId) .addText("发送`点歌 <歌名>`即可点第一首搜索到的歌曲~") .addNewLine() .addText("发送`点歌 <歌名> [l|legacy]`即可使用旧版点歌系统") @@ -243,7 +227,7 @@ class QQMusicCommand : BaseCommand() { .addNewLine() .addText("时长: ${it.interval.formatToMinutes()}") .build() - nodeMsg.addMessageChain(msg, message.sender.userId) + nodeMsg.addMessageChain(msg, configManager.selfId) } catch (_: FileNotFoundException) { } } diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/PixivCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/PixivCommand.kt index 99c42dd..d8ff472 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/PixivCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/PixivCommand.kt @@ -8,6 +8,7 @@ package cn.rtast.fancybot.commands.lookup import cn.rtast.fancybot.annotations.CommandDescription +import cn.rtast.fancybot.configManager import cn.rtast.fancybot.entity.pixiv.Ranking import cn.rtast.fancybot.util.Http import cn.rtast.fancybot.util.str.encodeToBase64 @@ -51,11 +52,13 @@ class PixivCommand : BaseCommand() { .addText("用户: ${it.userName}(${it.userId}) | 作品ID: ${it.illustId}") .addNewLine() .addText("日期: ${it.date}") - node.addMessageChain(msg.build(), message.sender.userId) + node.addMessageChain(msg.build(), configManager.selfId) } catch (_: Exception) { } } - node.addMessageChain(MessageChain.Builder().addText("图片来源: Pixiv").build(), message.sender.userId) + node.addMessageChain(MessageChain.Builder() + .addText("图片来源: Pixiv") + .build(), configManager.selfId) message.reply(node.build()) return } diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/ShotCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/ShotCommand.kt index 3f2092c..47e43d0 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/ShotCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/ShotCommand.kt @@ -40,7 +40,7 @@ class ShotOtherCommand : BaseCommand() { override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List) { if (args.isEmpty()) { - message.reply("发送`骂 @某人`可以骂他~") + listener.sendGroupForwardMsg(message.groupId, generateNodeMessage(message.sender.userId.toString(), 20)) return } var times = if (args.size == 1) 10 else if (args.last() == "") 10 else args.last().toInt() diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/misc/BullShitGenerateCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/misc/BullShitGenerateCommand.kt index 52b7bb4..86d56f8 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/misc/BullShitGenerateCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/misc/BullShitGenerateCommand.kt @@ -7,6 +7,7 @@ package cn.rtast.fancybot.commands.misc +import cn.rtast.fancybot.configManager import cn.rtast.fancybot.entity.bullshit.BullShit import cn.rtast.fancybot.util.Resources import cn.rtast.fancybot.util.str.fromJson @@ -61,7 +62,7 @@ class BullShitGenerateCommand : BaseCommand() { } val finalText = output.toString().replace("x", topic) val node = NodeMessageChain.Builder() - .addMessageChain(MessageChain.Builder().addText(finalText).build(), message.sender.userId) + .addMessageChain(MessageChain.Builder().addText(finalText).build(), configManager.selfId) .build() message.reply(node) message.sender.groupPoke() diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/misc/SendMailCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/misc/SendMailCommand.kt index fa5be65..1fc377a 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/misc/SendMailCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/misc/SendMailCommand.kt @@ -44,11 +44,7 @@ class SendMailCommand : BaseCommand() { override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List) { if (args.isEmpty()) { - val msg = MessageChain.Builder() - .addAt(message.sender.userId) - .addText("发送`/mail <收件人地址>`即可发送测试邮件~") - .build() - listener.sendGroupMessage(message.groupId, msg) + message.reply("发送`/mail <收件人地址>`即可发送测试邮件~") return } if (message.sender.userId !in configManager.admins) { @@ -61,10 +57,6 @@ class SendMailCommand : BaseCommand() { } val target = args.first() this.sendMail(target) - val msg = MessageChain.Builder() - .addAt(message.sender.userId) - .addText("正在发送邮件, 请查收~(可能会出现在垃圾桶中~)") - .build() - listener.sendGroupMessage(message.groupId, msg) + message.reply("正在发送邮件, 请查收~(可能会出现在垃圾桶中~)") } } \ No newline at end of file diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/misc/TenSetuCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/misc/TenSetuCommand.kt index adb9dc2..cea6fdb 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/misc/TenSetuCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/misc/TenSetuCommand.kt @@ -8,6 +8,7 @@ package cn.rtast.fancybot.commands.misc import cn.rtast.fancybot.annotations.CommandDescription +import cn.rtast.fancybot.configManager import cn.rtast.fancybot.entity.Setu import cn.rtast.fancybot.util.Http import cn.rtast.fancybot.util.str.encodeToBase64 @@ -30,7 +31,7 @@ class TenSetuCommand : BaseCommand() { try { val imageBase64 = URI(it).toURL().readBytes().encodeToBase64() val tempMsg = MessageChain.Builder().addImage(imageBase64, true).build() - nodeMsg.addMessageChain(tempMsg, message.sender.userId) + nodeMsg.addMessageChain(tempMsg, configManager.selfId) } catch (_: Exception) { } } @@ -39,7 +40,7 @@ class TenSetuCommand : BaseCommand() { .addNewLine() .addText("因为过滤了R18的图片~") .build() - nodeMsg.addMessageChain(footerMsg, message.sender.userId) + nodeMsg.addMessageChain(footerMsg, configManager.selfId) listener.sendGroupForwardMsg(message.groupId, nodeMsg.build()) } } \ No newline at end of file diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/niuzi/NiuziRedeemCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/niuzi/NiuziRedeemCommand.kt index de45ea4..8f8f69b 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/niuzi/NiuziRedeemCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/niuzi/NiuziRedeemCommand.kt @@ -34,18 +34,13 @@ class NiuziRedeemCommand : BaseCommand() { } val status = niuziManager.getUser(message.sender.userId) if (status == null) { - val msg = MessageChain.Builder() - .addReply(message.messageId) - .addText("你还没有签到过呢要签到一次才能兑换哦~") - .build() - listener.sendGroupMessage(message.groupId, msg) + message.reply("你还没有签到过呢要签到一次才能兑换哦~") return } val item = args.first() if (item == "list" || item == "列表") { - val priceTable = - itemManager.items.joinToString("\n") - { "[${it.itemNames.joinToString("|")}]:${it.itemPrice}cm" } + val priceTable = itemManager.items.joinToString("\n") + { "[${it.itemNames.joinToString("|")}]:${it.itemPrice}cm" } message.reply(priceTable) return } @@ -72,13 +67,15 @@ class NiuziRedeemCommand : BaseCommand() { return } val afterStatus = niuziManager.redeemItem(message.sender.userId, selectedItemPrice)?.length!! + val action = selectedItem.redeemInGroup(listener, message, afterStatus) val msg = MessageChain.Builder() .addReply(message.messageId) - .addText("兑换成功正在发送奖品中~") + .addText("兑换成功! 你花费了${selectedItemPrice}cm来兑换奖品, 还剩${afterStatus}cm") .addNewLine() - .addText("你花费了${selectedItemPrice}cm来兑换奖品, 还剩${afterStatus}cm") + .addText("-------------------") + .addNewLine() + .addMessageChain(action) .build() - listener.sendGroupMessage(message.groupId, msg) - selectedItem.redeemGroup(listener, message, afterStatus) + message.reply(msg) } } \ No newline at end of file diff --git a/src/main/kotlin/cn/rtast/fancybot/items/BaisiItem.kt b/src/main/kotlin/cn/rtast/fancybot/items/BaisiItem.kt index 314cd71..7f219d1 100644 --- a/src/main/kotlin/cn/rtast/fancybot/items/BaisiItem.kt +++ b/src/main/kotlin/cn/rtast/fancybot/items/BaisiItem.kt @@ -18,9 +18,13 @@ class BaisiItem : Item() { override val itemNames = listOf("baisi", "白丝", "bs") override val itemPrice = 5.0 - override suspend fun redeemInGroup(listener: OneBotListener, message: GroupMessage, after: Double) { + override suspend fun redeemInGroup( + listener: OneBotListener, + message: GroupMessage, + after: Double + ): MessageChain.Builder { val url = Http.get("https://v2.api-m.com/api/baisi").data - val msg = MessageChain.Builder().addImage(url).build() - message.reply(msg) + val msg = MessageChain.Builder().addImage(url) + return msg } } \ No newline at end of file diff --git a/src/main/kotlin/cn/rtast/fancybot/items/HeisiItem.kt b/src/main/kotlin/cn/rtast/fancybot/items/HeisiItem.kt index 9ed46d4..09fcdea 100644 --- a/src/main/kotlin/cn/rtast/fancybot/items/HeisiItem.kt +++ b/src/main/kotlin/cn/rtast/fancybot/items/HeisiItem.kt @@ -18,9 +18,13 @@ class HeisiItem : Item() { override val itemNames = listOf("heisi", "黑丝", "hs") override val itemPrice = 5.0 - override suspend fun redeemInGroup(listener: OneBotListener, message: GroupMessage, after: Double) { + override suspend fun redeemInGroup( + listener: OneBotListener, + message: GroupMessage, + after: Double + ): MessageChain.Builder { val url = Http.get("https://v2.api-m.com/api/heisi").data - val msg = MessageChain.Builder().addImage(url).build() - message.reply(msg) + val msg = MessageChain.Builder().addImage(url) + return msg } } \ No newline at end of file diff --git a/src/main/kotlin/cn/rtast/fancybot/items/NiuziItem.kt b/src/main/kotlin/cn/rtast/fancybot/items/NiuziItem.kt index 62c7330..c2eadbe 100644 --- a/src/main/kotlin/cn/rtast/fancybot/items/NiuziItem.kt +++ b/src/main/kotlin/cn/rtast/fancybot/items/NiuziItem.kt @@ -17,14 +17,17 @@ class NiuziItem : Item() { override val itemNames = listOf("牛子", "nz", "niuzi") override val itemPrice = 10.0 - override suspend fun redeemInGroup(listener: OneBotListener, message: GroupMessage, after: Double) { + override suspend fun redeemInGroup( + listener: OneBotListener, + message: GroupMessage, + after: Double + ): MessageChain.Builder { val before = niuziManager.getUser(message.sender.userId)!! val afterNiuzi = niuziManager.updateLength(message.sender.userId, -2.0)!! val msg = MessageChain.Builder() .addText("你的牛子到账啦, 你的牛子现在有${afterNiuzi.length}cm长呢!") .addNewLine() .addText("(之前的长度是${before.length}cm!)") - .build() - message.reply(msg) + return msg } } \ No newline at end of file diff --git a/src/main/kotlin/cn/rtast/fancybot/items/SetuItem.kt b/src/main/kotlin/cn/rtast/fancybot/items/SetuItem.kt index b224dd1..da5f7ff 100644 --- a/src/main/kotlin/cn/rtast/fancybot/items/SetuItem.kt +++ b/src/main/kotlin/cn/rtast/fancybot/items/SetuItem.kt @@ -22,16 +22,19 @@ class SetuItem : Item() { override val itemNames = listOf("setu", "色图", "st") override val itemPrice = 10.0 - override suspend fun redeemInGroup(listener: OneBotListener, message: GroupMessage, after: Double) { + override suspend fun redeemInGroup( + listener: OneBotListener, + message: GroupMessage, + after: Double + ): MessageChain.Builder { val response = Http.get("https://api.rtast.cn/api/setu") .fromArrayJson>().first() if (response.r18) { niuziManager.updateLength(message.sender.userId, itemPrice) - message.reply("不好意思这张图片是R18所以不能发~, 牛子长度已经退还~") - return + return MessageChain.Builder().addText("不好意思这张图片是R18所以不能发~, 牛子长度已经退还~") } val imageBase64 = URI(response.urls.large).toURL().readBytes().encodeToBase64() - val msg = MessageChain.Builder().addImage(imageBase64, true).build() - message.reply(msg) + val msg = MessageChain.Builder().addImage(imageBase64, true) + return msg } } \ No newline at end of file diff --git a/src/main/kotlin/cn/rtast/fancybot/util/item/Item.kt b/src/main/kotlin/cn/rtast/fancybot/util/item/Item.kt index b7d7f12..9dbe899 100644 --- a/src/main/kotlin/cn/rtast/fancybot/util/item/Item.kt +++ b/src/main/kotlin/cn/rtast/fancybot/util/item/Item.kt @@ -8,15 +8,16 @@ package cn.rtast.fancybot.util.item import cn.rtast.rob.entity.GroupMessage +import cn.rtast.rob.util.ob.MessageChain import cn.rtast.rob.util.ob.OneBotListener abstract class Item { abstract val itemNames: List abstract val itemPrice: Double - protected open suspend fun redeemInGroup(listener: OneBotListener, message: GroupMessage, after: Double) {} - - suspend fun redeemGroup(listener: OneBotListener, message: GroupMessage, after: Double) { - this.redeemInGroup(listener, message, after) - } + abstract suspend fun redeemInGroup( + listener: OneBotListener, + message: GroupMessage, + after: Double + ): MessageChain.Builder } \ No newline at end of file