feat: migrate to multi-instance ronebot

This commit is contained in:
2024-10-24 16:55:14 +08:00
parent bc28a4fefc
commit 41463b8b18
30 files changed
+88 -101

No files matched your search

@@ -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)
}
}
}