Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41463b8b18 |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
[versions]
|
||||
kotlinVersion = "2.0.20"
|
||||
ronebotVersion = "1.14.1"
|
||||
ronebotVersion = "2.0.2-SNAPSHOT"
|
||||
shadowVersion = "8.3.0"
|
||||
okhttpVersion = "5.0.0-alpha.14"
|
||||
exposedVersion = "0.53.0"
|
||||
|
||||
@@ -34,7 +34,6 @@ import cn.rtast.fancybot.util.file.NiuziBankManager
|
||||
import cn.rtast.fancybot.util.file.NiuziManager
|
||||
import cn.rtast.fancybot.util.file.RCONManager
|
||||
import cn.rtast.fancybot.util.item.ItemManager
|
||||
import cn.rtast.rob.ROneBotFactory
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import java.time.Instant
|
||||
@@ -115,7 +114,7 @@ val items = listOf(
|
||||
val tasks = mapOf(
|
||||
10000000L to suspend {
|
||||
configManager.admins.forEach {
|
||||
ROneBotFactory.action.sendLike(it, 1)
|
||||
instance.action.sendLike(it, 1)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -31,6 +31,7 @@ import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OneBotListener
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
@@ -41,7 +42,7 @@ class FancyBot : OneBotListener {
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
|
||||
override suspend fun onWebsocketOpenEvent() {
|
||||
this.sendPrivateMessage(configManager.noticeUser, "FancyBot启动完成~")
|
||||
instance.action.sendPrivateMessage(configManager.noticeUser, "FancyBot启动完成~")
|
||||
}
|
||||
|
||||
override suspend fun onGroupMessage(message: GroupMessage, json: String) {
|
||||
@@ -57,11 +58,11 @@ class FancyBot : OneBotListener {
|
||||
message.reply("你发牛魔的火车呢, 我直接就是打断")
|
||||
}
|
||||
|
||||
if (message.rawMessage.contains("原神")) {
|
||||
(0..10).forEach { _ ->
|
||||
message.reaction(QQFace.entries.random())
|
||||
}
|
||||
if (message.text.contains("原神")) {
|
||||
(0..10).forEach { _ -> message.reaction(QQFace.entries.random()) }
|
||||
message.reply("你原神牛魔呢")
|
||||
delay(1500L)
|
||||
message.reply("但是话又说回来.....启动!!")
|
||||
}
|
||||
|
||||
GitHubParseCommand.parse(message)
|
||||
@@ -73,7 +74,7 @@ class FancyBot : OneBotListener {
|
||||
DouyinVideoParseCommand.parse(message)
|
||||
YoutubeVideoParseCommand.parse(message)
|
||||
|
||||
if (message.rawMessage.toList().any { it in arrayListOf('*', '-', '/', '+', '=') }) {
|
||||
if (message.text.toList().any { it in arrayListOf('*', '-', '/', '+', '=') }) {
|
||||
val calculateResult = CalculateCommand.parse(message.rawMessage)
|
||||
calculateResult?.let { message.reply(calculateResult) }
|
||||
}
|
||||
@@ -81,7 +82,7 @@ class FancyBot : OneBotListener {
|
||||
if (message.message.any { it.type == ArrayMessageType.reply }) {
|
||||
val command = message.message.reversed().find { it.type == ArrayMessageType.text }!!.data.text!!
|
||||
val replyId = message.message.find { it.type == ArrayMessageType.reply }!!.data.id!!
|
||||
val getMsg = this.getMessage(replyId.toString().toLong())
|
||||
val getMsg = instance.action.getMessage(replyId.toString().toLong())
|
||||
val plainTextContent = getMsg.message
|
||||
.filter { it.type == ArrayMessageType.text }
|
||||
.joinToString { it.data.text!! }
|
||||
@@ -110,7 +111,7 @@ class FancyBot : OneBotListener {
|
||||
}
|
||||
if (command.contains("reaction")) {
|
||||
// 使用reaction刷屏回应一条消息
|
||||
ReactionCommand.reaction(this, message, getMsg.messageId)
|
||||
ReactionCommand.reaction(message)
|
||||
}
|
||||
if (command.contains("图床")) {
|
||||
// 将一个图片上传到图床
|
||||
@@ -139,7 +140,7 @@ class FancyBot : OneBotListener {
|
||||
.addNewLine()
|
||||
.addText("使用/revoke ${message.messageId} 来获取被撤回的消息")
|
||||
.build()
|
||||
this.sendGroupMessage(message.groupId, msg)
|
||||
instance.action.sendGroupMessage(message.groupId, msg)
|
||||
}
|
||||
|
||||
override suspend fun onWebsocketErrorEvent(ex: Exception) {
|
||||
@@ -162,7 +163,7 @@ class FancyBot : OneBotListener {
|
||||
.addNewLine()
|
||||
.addText("下次再见吧~~~")
|
||||
.build()
|
||||
this.sendGroupMessage(groupId, msg)
|
||||
instance.action.sendGroupMessage(groupId, msg)
|
||||
}
|
||||
|
||||
override suspend fun onGroupPoke(event: PokeEvent) {
|
||||
@@ -171,36 +172,37 @@ class FancyBot : OneBotListener {
|
||||
.addAt(event.userId)
|
||||
.addText("你${event.action.first()}牛魔呢")
|
||||
.build()
|
||||
this.sendGroupMessage(event.groupId!!, msg)
|
||||
instance.action.sendGroupMessage(event.groupId!!, msg)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun onBeKicked(groupId: Long, operator: Long, time: Long) {
|
||||
blackListManager.insertGroup(groupId, operator, time)
|
||||
this.sendPrivateMessage(
|
||||
instance.action.sendPrivateMessage(
|
||||
configManager.noticeUser,
|
||||
"被: ${groupId}踢出! 操作人: $operator 时间: ${time.convertToDate()} 已将其拉入黑名单!"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun main() {
|
||||
val fancyBot = FancyBot()
|
||||
val workType = configManager.wsType
|
||||
val accessToken = configManager.accessToken
|
||||
val rob = if (workType == WSType.Client) {
|
||||
val fancyBot = FancyBot()
|
||||
val workType = configManager.wsType
|
||||
val accessToken = configManager.accessToken
|
||||
val instance = if (workType == WSType.Client) {
|
||||
val address = configManager.wsAddress
|
||||
ROneBotFactory.createClient(address, accessToken, fancyBot)
|
||||
.also { it.addListeningGroups(*configManager.listeningGroups.toLongArray()) }
|
||||
} else {
|
||||
} else {
|
||||
val port = configManager.wsPort
|
||||
ROneBotFactory.createServer(port, accessToken, fancyBot)
|
||||
.also { it.addListeningGroups(*configManager.listeningGroups.toLongArray()) }
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun main() {
|
||||
initDatabase()
|
||||
initFilesDir()
|
||||
initCommand(rob)
|
||||
initCommand()
|
||||
initSetuIndex()
|
||||
initItems()
|
||||
initBackgroundTasks(rob)
|
||||
initBackgroundTasks(instance)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,11 @@ import cn.rtast.fancybot.configManager
|
||||
import cn.rtast.fancybot.entity.github.UploadContentPayload
|
||||
import cn.rtast.fancybot.entity.github.UploadContentResponse
|
||||
import cn.rtast.fancybot.enums.ImageBedType
|
||||
import cn.rtast.fancybot.instance
|
||||
import cn.rtast.fancybot.util.Http
|
||||
import cn.rtast.fancybot.util.str.encodeToBase64
|
||||
import cn.rtast.fancybot.util.str.proxy
|
||||
import cn.rtast.fancybot.util.str.toJson
|
||||
import cn.rtast.rob.ROneBotFactory
|
||||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
|
||||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
|
||||
import software.amazon.awssdk.core.sync.RequestBody
|
||||
@@ -68,7 +68,7 @@ object ImageBed {
|
||||
return "${configManager.cloudflareR2PublicUrl}/$key".proxy
|
||||
}
|
||||
|
||||
ImageBedType.QQ -> ROneBotFactory.action.uploadImage(file.encodeToBase64(), true)
|
||||
ImageBedType.QQ -> instance.action.uploadImage(file.encodeToBase64(), true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ package cn.rtast.fancybot.util.misc
|
||||
|
||||
import cn.rtast.fancybot.*
|
||||
import cn.rtast.fancybot.util.Http
|
||||
import cn.rtast.rob.BotInstance
|
||||
import cn.rtast.rob.ROneBotFactory
|
||||
import cn.rtast.rob.util.ob.OneBotListener
|
||||
import java.io.File
|
||||
@@ -20,13 +21,12 @@ fun randomBooleanWithProbability(probability: Double): Boolean {
|
||||
}
|
||||
|
||||
suspend fun OneBotListener.getUserName(groupId: Long, userId: Long): String {
|
||||
val info = this.getGroupMemberInfo(groupId, userId)
|
||||
val info = instance.action.getGroupMemberInfo(groupId, userId)
|
||||
return info.card ?: info.nickname
|
||||
}
|
||||
|
||||
fun initCommand(rob: ROneBotFactory) {
|
||||
val commandManager = rob.commandManager
|
||||
commands.forEach { commandManager.register(it) }
|
||||
fun initCommand() {
|
||||
commands.forEach { ROneBotFactory.commandManager.register(it) }
|
||||
}
|
||||
|
||||
fun initFilesDir() {
|
||||
@@ -47,6 +47,6 @@ fun initItems() {
|
||||
items.forEach { itemManager.register(it) }
|
||||
}
|
||||
|
||||
fun initBackgroundTasks(rob: ROneBotFactory) {
|
||||
tasks.forEach { rob.scheduler.scheduleTask(it.value, 1000L, it.key) }
|
||||
fun initBackgroundTasks(instance: BotInstance) {
|
||||
tasks.forEach { instance.scheduler.scheduleTask(it.value, 1000L, it.key) }
|
||||
}
|
||||
Reference in New Issue
Block a user