feat: migrate to multi-instance ronebot
This commit is contained in:
30 files changed
+88
-101
No files matched your search
@@ -8,7 +8,6 @@
|
||||
package cn.rtast.fancybot.commands
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.configManager
|
||||
import cn.rtast.fancybot.enums.CommandAction
|
||||
import cn.rtast.fancybot.util.file.insertActionRecord
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
@@ -21,7 +20,7 @@ class EchoCommand : BaseCommand() {
|
||||
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
if (message.sender.isAdmin || message.sender.isOwner) {
|
||||
listener.sendGroupMessage(message.groupId, args.joinToString(" "))
|
||||
message.reply(args.joinToString(" "))
|
||||
insertActionRecord(CommandAction.Echo, message.sender.userId)
|
||||
} else {
|
||||
message.reply("你不许用echo")
|
||||
@@ -37,7 +36,7 @@ class ShuffleEchoCommand : BaseCommand() {
|
||||
if (message.sender.isAdmin || message.sender.isOwner) {
|
||||
message.reply(message.rawMessage.toList().shuffled().joinToString(""))
|
||||
insertActionRecord(CommandAction.Echo, message.sender.userId)
|
||||
} else{
|
||||
} else {
|
||||
message.reply("你不许用echo")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import cn.rtast.fancybot.entity.gpt.ChatCompletionsResponse
|
||||
import cn.rtast.fancybot.entity.gpt.LlamaResponse
|
||||
import cn.rtast.fancybot.entity.gpt.ModelList
|
||||
import cn.rtast.fancybot.enums.CommandAction
|
||||
import cn.rtast.fancybot.instance
|
||||
import cn.rtast.fancybot.util.Http
|
||||
import cn.rtast.fancybot.util.file.insertActionRecord
|
||||
import cn.rtast.fancybot.util.str.toJson
|
||||
@@ -69,7 +70,7 @@ class AICommand : BaseCommand() {
|
||||
.addText(response.choices.first().message.content)
|
||||
.build()
|
||||
nodeMsg.addMessageChain(msg, configManager.selfId)
|
||||
listener.sendGroupForwardMsg(message.groupId, nodeMsg.build())
|
||||
instance.action.sendGroupForwardMsg(message.groupId, nodeMsg.build())
|
||||
insertActionRecord(CommandAction.AI, message.sender.userId, "$content-$model-GPT")
|
||||
}
|
||||
}
|
||||
@@ -96,7 +97,7 @@ class LlamaCommand : BaseCommand() {
|
||||
.addText(response.message.content)
|
||||
.build()
|
||||
nodeMsg.addMessageChain(msg, configManager.selfId)
|
||||
listener.sendGroupForwardMsg(message.groupId, nodeMsg.build())
|
||||
instance.action.sendGroupForwardMsg(message.groupId, nodeMsg.build())
|
||||
insertActionRecord(CommandAction.AI, message.sender.userId, "$prompt-LLAMA")
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,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.instance
|
||||
import cn.rtast.fancybot.util.Http
|
||||
import cn.rtast.fancybot.util.str.encodeToBase64
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
@@ -58,7 +59,7 @@ class AnimeSearchCommand : BaseCommand() {
|
||||
}
|
||||
val footerNode = MessageChain.Builder().addText("数据来源: Bangumi").build()
|
||||
nodeMsg.addMessageChain(footerNode, configManager.selfId)
|
||||
listener.sendGroupForwardMsg(message.groupId, nodeMsg.build())
|
||||
instance.action.sendGroupForwardMsg(message.groupId, nodeMsg.build())
|
||||
} catch (_: Exception) {
|
||||
message.reply("没有搜索到结果呢~")
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class MusicCommand : BaseCommand() {
|
||||
val msg = MessageChain.Builder()
|
||||
.addMusicShare(MusicShareType.Netease, finalResult.id.toString())
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
} catch (_: Exception) {
|
||||
message.reply("输入有误请重新搜索本次搜索结果已清除")
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class MusicCommand : BaseCommand() {
|
||||
.addNewLine()
|
||||
.addText("发送`点歌 <歌名> [l|legacy]`即可使用旧版点歌系统")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class MusicCommand : BaseCommand() {
|
||||
val msg = MessageChain.Builder()
|
||||
.addMusicShare(MusicShareType.Netease, result.toString())
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class MusicPlayUrlCommand : BaseCommand() {
|
||||
.addReply(message.messageId)
|
||||
.addText(url)
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +162,6 @@ class QQMusicCommand : BaseCommand() {
|
||||
mapOf("key" to keyword)
|
||||
).response.data.song.list.first().songId
|
||||
val msg = MessageChain.Builder().addMusicShare(MusicShareType.QQ, response.toString()).build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package cn.rtast.fancybot.commands.lookup
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.instance
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.enums.ArrayMessageType
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
@@ -30,7 +31,7 @@ class ShotSelfCommand : BaseCommand() {
|
||||
override val commandNames = listOf("骂我")
|
||||
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
listener.sendGroupForwardMsg(message.groupId, generateNodeMessage(message.sender.userId.toString()))
|
||||
instance.action.sendGroupForwardMsg(message.groupId, generateNodeMessage(message.sender.userId.toString()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +41,14 @@ class ShotOtherCommand : BaseCommand() {
|
||||
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
if (args.isEmpty()) {
|
||||
listener.sendGroupForwardMsg(message.groupId, generateNodeMessage(message.sender.userId.toString(), 20))
|
||||
instance.action.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()
|
||||
if (times >= 200) times = 10
|
||||
val target = message.message.find { it.type == ArrayMessageType.at }?.data!!
|
||||
listener.sendGroupForwardMsg(message.groupId, generateNodeMessage(target.qq!!, times))
|
||||
instance.action.sendGroupForwardMsg(message.groupId, generateNodeMessage(target.qq!!, times))
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class WeatherCommand : BaseCommand() {
|
||||
.addAt(message.sender.userId)
|
||||
.addText("发送/weather <地区名>即可查看实时天气哦~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
return
|
||||
}
|
||||
try {
|
||||
@@ -81,13 +81,13 @@ class WeatherCommand : BaseCommand() {
|
||||
.addReply(message.messageId)
|
||||
.addImage(this.createWeatherCard(weather, lookupLocation), true)
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
} catch (_: NullPointerException) {
|
||||
val msg = MessageChain.Builder()
|
||||
.addAt(message.sender.userId)
|
||||
.addText("没有查询到该城市的天气信息哦~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ package cn.rtast.fancybot.commands.misc
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.enums.CommandAction
|
||||
import cn.rtast.fancybot.instance
|
||||
import cn.rtast.fancybot.util.file.insertActionRecord
|
||||
import cn.rtast.rob.entity.ArrayMessage
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
@@ -23,12 +24,12 @@ class AntiRevokeCommand : BaseCommand() {
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
if (message.sender.isAdmin || message.sender.isOwner) {
|
||||
val messageId = args.first().toLong()
|
||||
val getMsg = listener.getMessage(messageId)
|
||||
val getMsg = instance.action.getMessage(messageId)
|
||||
val msgList = mutableListOf<ArrayMessage>()
|
||||
msgList.add(ArrayMessage(ArrayMessageType.at, ArrayMessage.Data(qq = message.sender.userId.toString())))
|
||||
msgList.add(ArrayMessage(ArrayMessageType.text, ArrayMessage.Data(text = "\n被撤回的消息如下: \n")))
|
||||
msgList.addAll(getMsg.message)
|
||||
listener.sendGroupMessage(message.groupId, msgList)
|
||||
instance.action.sendGroupMessage(message.groupId, msgList)
|
||||
insertActionRecord(CommandAction.AntiRevoke, message.sender.userId, getMsg.messageId.toString())
|
||||
} else {
|
||||
message.reply("你不许用防撤回")
|
||||
|
||||
@@ -63,7 +63,7 @@ class CompilerCommand : BaseCommand() {
|
||||
.addNewLine()
|
||||
.addText(response.replace("<outStream>", "").replace("</outStream>", ""))
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
} catch (e: Exception) {
|
||||
message.reply("执行错误: ${e.message}")
|
||||
} finally {
|
||||
|
||||
@@ -26,7 +26,7 @@ class JrrpCommand : BaseCommand() {
|
||||
.addAt(message.sender.userId)
|
||||
.addText("你今天已经今日人品过啦, 明天再来吧~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
return
|
||||
}
|
||||
val randomPoint = jrrpManager.jrrp(message.sender.userId)
|
||||
@@ -41,6 +41,6 @@ class JrrpCommand : BaseCommand() {
|
||||
.addAt(message.sender.userId)
|
||||
.addText("$scoreDesc($randomPoint)")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,6 @@ class JueCommand : BaseCommand() {
|
||||
val source = message.sender.userId.toString()
|
||||
val gif = this.createJueGIF(source, target)
|
||||
val msg = MessageChain.Builder().addImage(gif, true).build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,6 @@ import okhttp3.FormBody
|
||||
import java.awt.AlphaComposite
|
||||
import java.awt.Color
|
||||
import java.awt.image.BufferedImage
|
||||
import java.net.InetAddress
|
||||
import java.net.SocketException
|
||||
import java.net.URI
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
@@ -25,7 +25,7 @@ class RUACommand : BaseCommand() {
|
||||
.addText("使用rua @xxxx")
|
||||
.addText("即可rua某人啦~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
return
|
||||
}
|
||||
try {
|
||||
@@ -38,13 +38,13 @@ class RUACommand : BaseCommand() {
|
||||
.addText(" ")
|
||||
.addText("rua了你~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
} catch (_: NullPointerException) {
|
||||
val msg = MessageChain.Builder()
|
||||
.addAt(message.sender.userId)
|
||||
.addText("要@才有用哦~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,6 @@ class RandomMusicCommand : BaseCommand() {
|
||||
val msg = MessageChain.Builder()
|
||||
.addMusicShare(MusicShareType.Netease, id.toString())
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,11 @@ class ReactionCommand : BaseCommand() {
|
||||
override val commandNames = listOf("reaction", "回应")
|
||||
|
||||
companion object {
|
||||
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()
|
||||
)
|
||||
}
|
||||
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<String>) =
|
||||
reaction(listener, message, message.messageId)
|
||||
reaction(message)
|
||||
}
|
||||
@@ -40,6 +40,6 @@ class RemakeCommand : BaseCommand() {
|
||||
msg.addText("重开成功! 你转生在${country.chineseName}的$location, 是一个$role")
|
||||
} else
|
||||
msg.addText("转生失败~")
|
||||
listener.sendGroupMessage(message.groupId, msg.build())
|
||||
message.reply(msg.build())
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/10/15
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.commands.misc
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
|
||||
@CommandDescription("复读鸡")
|
||||
object RepeatCommand {
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package cn.rtast.fancybot.commands.misc
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.instance
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
@@ -18,11 +19,11 @@ class SendLikeCommand : BaseCommand() {
|
||||
override val commandNames = listOf("赞我")
|
||||
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
listener.sendLike(message.sender.userId, 10)
|
||||
instance.action.sendLike(message.sender.userId, 10)
|
||||
val msg = MessageChain.Builder()
|
||||
.addReply(message.messageId)
|
||||
.addText("👍了你十下~~😁")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,6 @@ class TTSCommand : BaseCommand() {
|
||||
val msg = MessageChain.Builder()
|
||||
.addRecord(response.url.proxy)
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package cn.rtast.fancybot.commands.misc
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.instance
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.entity.PrivateMessage
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
@@ -55,7 +56,7 @@ class UnsetZiBiCommand : BaseCommand() {
|
||||
message.reply(msg)
|
||||
return
|
||||
}
|
||||
listener.setGroupBan(users.getValue(message.sender.userId), message.sender.userId, 0)
|
||||
instance.action.setGroupBan(users.getValue(message.sender.userId), message.sender.userId, 0)
|
||||
val msg = MessageChain.Builder()
|
||||
.addText("祝你天天开心不要自闭~~")
|
||||
.build()
|
||||
|
||||
@@ -37,6 +37,6 @@ class MyNiuziCommand : BaseCommand() {
|
||||
else -> "牛子也太长啦把天捅穿啦!!!!!!"
|
||||
}
|
||||
msg.addText(niuziString)
|
||||
listener.sendGroupMessage(message.groupId, msg.build())
|
||||
message.reply(msg.build())
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ package cn.rtast.fancybot.commands.niuzi
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.commands
|
||||
import cn.rtast.fancybot.instance
|
||||
import cn.rtast.fancybot.niuziBankManager
|
||||
import cn.rtast.fancybot.niuziManager
|
||||
import cn.rtast.fancybot.util.misc.getUserName
|
||||
@@ -68,7 +69,7 @@ class CreateBankAccountCommand : BaseCommand() {
|
||||
message.reply("你已经有账户了!")
|
||||
return
|
||||
}
|
||||
val userInfo = listener.getGroupMemberInfo(message.groupId, message.sender.userId)
|
||||
val userInfo = instance.action.getGroupMemberInfo(message.groupId, message.sender.userId)
|
||||
niuziBankManager.createBlankAccount(message.sender.userId, userInfo.card ?: userInfo.nickname)
|
||||
message.reply("成功创建了一个账户!")
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class NiuziJiJianCommand : BaseCommand() {
|
||||
.addNewLine()
|
||||
.addText("所以你不能和他们击剑~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
return
|
||||
}
|
||||
if (message.sender.userId == targetId) {
|
||||
@@ -69,7 +69,7 @@ class NiuziJiJianCommand : BaseCommand() {
|
||||
.addNewLine()
|
||||
.addText("对方的牛子增加了${result.second}cm~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
package cn.rtast.fancybot.commands.niuzi
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.configManager
|
||||
import cn.rtast.fancybot.niuziBankManager
|
||||
import cn.rtast.fancybot.niuziManager
|
||||
import cn.rtast.fancybot.util.misc.getUserName
|
||||
|
||||
@@ -32,6 +32,6 @@ class NiuziSignCommand : BaseCommand() {
|
||||
.addNewLine()
|
||||
.addText("你的牛子增加了${afterStatus.first}cm~ 总长度为: ${afterStatus.second?.length}")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
@@ -233,7 +233,7 @@ object BiliVideoParseCommand {
|
||||
.addImage(image, true)
|
||||
.addText(shortUrl)
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
@@ -285,7 +285,7 @@ object BiliUserParseCommand {
|
||||
val msg = MessageChain.Builder()
|
||||
.addImage(userCardImage, true)
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user