chore: improve rdm command
This commit is contained in:
19 files changed
+82
-82
No files matched your search
@@ -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("/", "")
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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("没有搜索到结果呢~")
|
||||
|
||||
@@ -45,11 +45,7 @@ class MusicCommand : BaseCommand() {
|
||||
|
||||
private suspend fun legacyMusicCommand(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class ShotOtherCommand : BaseCommand() {
|
||||
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -44,11 +44,7 @@ class SendMailCommand : BaseCommand() {
|
||||
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
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("正在发送邮件, 请查收~(可能会出现在垃圾桶中~)")
|
||||
}
|
||||
}
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user