From 7724a975955e1b0f84c4bd3c8d8404edb64f435d Mon Sep 17 00:00:00 2001 From: alazeprt Date: Tue, 17 Sep 2024 16:37:18 +0800 Subject: [PATCH] Change config options & Add game listener and handler --- .../kotlin/me/regadpole/plumbot/PlumBot.kt | 12 +- .../me/regadpole/plumbot/bot/KookBot.kt | 4 +- .../kotlin/me/regadpole/plumbot/bot/QQBot.kt | 10 +- .../regadpole/plumbot/config/ConfigLoader.kt | 117 +++++++++++------ .../plumbot/config/ConfigResolver.kt | 6 +- .../me/regadpole/plumbot/database/SQLite.kt | 2 +- .../me/regadpole/plumbot/event/GDeathEvent.kt | 5 + .../me/regadpole/plumbot/event/GJoinEvent.kt | 7 + .../plumbot/event/GPlayerChatEvent.kt | 5 + .../me/regadpole/plumbot/event/GQuitEvent.kt | 5 + .../plumbot/listener/game/GameListener.kt | 70 ++++++++++ .../me/regadpole/plumbot/util/GPlayer.kt | 6 + .../me/regadpole/plumbot/util/GPosition.kt | 7 + common/src/main/resources/commands.yml | 2 +- common/src/main/resources/config.yml | 123 +++++++++++------- common/src/main/resources/returns.yml | 2 +- 16 files changed, 277 insertions(+), 106 deletions(-) create mode 100644 common/src/main/kotlin/me/regadpole/plumbot/event/GDeathEvent.kt create mode 100644 common/src/main/kotlin/me/regadpole/plumbot/event/GJoinEvent.kt create mode 100644 common/src/main/kotlin/me/regadpole/plumbot/event/GPlayerChatEvent.kt create mode 100644 common/src/main/kotlin/me/regadpole/plumbot/event/GQuitEvent.kt create mode 100644 common/src/main/kotlin/me/regadpole/plumbot/listener/game/GameListener.kt create mode 100644 common/src/main/kotlin/me/regadpole/plumbot/util/GPlayer.kt create mode 100644 common/src/main/kotlin/me/regadpole/plumbot/util/GPosition.kt diff --git a/common/src/main/kotlin/me/regadpole/plumbot/PlumBot.kt b/common/src/main/kotlin/me/regadpole/plumbot/PlumBot.kt index 52251ef..9d4f5b8 100644 --- a/common/src/main/kotlin/me/regadpole/plumbot/PlumBot.kt +++ b/common/src/main/kotlin/me/regadpole/plumbot/PlumBot.kt @@ -30,7 +30,7 @@ object PlumBot : Plugin() { ConfigResolver.loadConfig() config = ConfigResolver.getConfigLoader() lang =ConfigResolver.getLangConf() - info("Successfully load config") + info("成功加载配置文件!") } // 项目使用TabooLib Start Jar 创建! @@ -41,14 +41,13 @@ object PlumBot : Plugin() { else -> error("Unknown database type.") } database.initialize() - info("Loaded database") - info("Successfully running PlumBot!") + info("成功连接到数据库!") } override fun onActive() { submitAsync(now = true) { when (config.getConfig().bot.mode) { - "go-cqhttp" -> { + "onebot" -> { bot = QQBot(this@PlumBot) bot.start() } @@ -63,11 +62,14 @@ object PlumBot : Plugin() { } } } + info("成功启用机器人服务!") } override fun onDisable() { bot.shutdown() + info("成功关闭机器人服务") database.close() + info("成功关闭数据库链接!") } fun reloadConfig() { @@ -86,7 +88,9 @@ object PlumBot : Plugin() { fun getLangConfig(): LangConfig { return lang } + fun getDatabase(): Database { return database } + } \ No newline at end of file diff --git a/common/src/main/kotlin/me/regadpole/plumbot/bot/KookBot.kt b/common/src/main/kotlin/me/regadpole/plumbot/bot/KookBot.kt index bbfeaf3..e5978ed 100644 --- a/common/src/main/kotlin/me/regadpole/plumbot/bot/KookBot.kt +++ b/common/src/main/kotlin/me/regadpole/plumbot/bot/KookBot.kt @@ -57,7 +57,7 @@ class KookBot(private val plugin: PlumBot): Bot { kookClient = kook kookBot = this kook.core.eventManager.registerHandlers(kook.internalPlugin, KookListener()) - val groups: List = plugin.getConfig().getConfig().enableGroups + val groups: List = plugin.getConfig().getConfig().groups.enableGroups for (groupID in groups) { PlumBot.getBot().sendMsg(true, "PlumBot已启动", groupID) } @@ -69,7 +69,7 @@ class KookBot(private val plugin: PlumBot): Bot { * Stop a bot */ override fun shutdown() { - val groups: List = plugin.getConfig().getConfig().enableGroups + val groups: List = plugin.getConfig().getConfig().groups.enableGroups for (groupID in groups) { sendMsg(true, "PlumBot已关闭", groupID) } diff --git a/common/src/main/kotlin/me/regadpole/plumbot/bot/QQBot.kt b/common/src/main/kotlin/me/regadpole/plumbot/bot/QQBot.kt index 72f2326..6b8d494 100644 --- a/common/src/main/kotlin/me/regadpole/plumbot/bot/QQBot.kt +++ b/common/src/main/kotlin/me/regadpole/plumbot/bot/QQBot.kt @@ -17,16 +17,16 @@ class QQBot(private val plugin: PlumBot): Bot { * Start a bot */ override fun start(): Bot { - onebot = if (plugin.getConfig().getConfig().bot.gocqhttp.hasAccessToken) { - OneBotClient.create(BotConfig(plugin.getConfig().getConfig().bot.gocqhttp.ws, plugin.getConfig().getConfig().bot.gocqhttp.token)) //创建websocket客户端 + onebot = if (plugin.getConfig().getConfig().bot.onebot.token.enable) { + OneBotClient.create(BotConfig(plugin.getConfig().getConfig().bot.onebot.ws, plugin.getConfig().getConfig().bot.onebot.token.token)) //创建websocket客户端 .open() //连接onebot服务端 .registerEvents(QQListener()) //注册事件监听器 } else { - OneBotClient.create(BotConfig(plugin.getConfig().getConfig().bot.gocqhttp.ws)) //创建websocket客户端 + OneBotClient.create(BotConfig(plugin.getConfig().getConfig().bot.onebot.ws)) //创建websocket客户端 .open() //连接onebot服务端 .registerEvents(QQListener()) //注册事件监听器 } - val groups: List = plugin.getConfig().getConfig().enableGroups + val groups: List = plugin.getConfig().getConfig().groups.enableGroups for (groupID in groups) { sendMsg(true, groupID, "PlumBot已启动") } @@ -38,7 +38,7 @@ class QQBot(private val plugin: PlumBot): Bot { * Stop a bot */ override fun shutdown() { - val groups: List = plugin.getConfig().getConfig().enableGroups + val groups: List = plugin.getConfig().getConfig().groups.enableGroups for (groupID in groups) { sendMsg(true, groupID, "PlumBot已关闭") } diff --git a/common/src/main/kotlin/me/regadpole/plumbot/config/ConfigLoader.kt b/common/src/main/kotlin/me/regadpole/plumbot/config/ConfigLoader.kt index 079bdd2..52c869e 100644 --- a/common/src/main/kotlin/me/regadpole/plumbot/config/ConfigLoader.kt +++ b/common/src/main/kotlin/me/regadpole/plumbot/config/ConfigLoader.kt @@ -1,6 +1,5 @@ package me.regadpole.plumbot.config -import taboolib.common.io.newFile import taboolib.common.platform.function.getDataFolder import taboolib.module.configuration.Configuration import taboolib.module.configuration.util.getMap @@ -13,61 +12,101 @@ class ConfigLoader(config: Configuration, commandsConfig: Configuration, returns class Config(config: Configuration){ - val ver = config.getString("Ver") + val version = config.getString("version") val lang = config.getString("lang") - val prefix = config.getString("commandPrefix") - val forwarding = Forwarding(config) - val dieReport = config.getBoolean("dieReport") - val whiteList = WhiteList(config) - val cmd = config.getBoolean("cmd") - val joinAndLeave = config.getBoolean("joinAndLeave") - val online = config.getBoolean("online") - val tps = config.getBoolean("tps") - val sdc = config.getBoolean("SDC") - val sdr = config.getBoolean("SDR") - val database = DataBase(config) - val enableGroups = config.getStringList("enableGroups") - val botAdmins = config.getStringList("botAdmins") - val bot = Bot(config) + class Groups(config: Configuration) { + val enableGroups = config.getStringList("groups.enableGroups") + val botAdmins = config.getStringList("groups.botAdmins") + val prefix = config.getString("groups.commandPrefix") + val forwarding = Forwarding(config) + class Forwarding(config: Configuration) { + val message = Message(config) + class Message(config: Configuration) { + val enable = config.getBoolean("groups.forwarding.message.enable") + val mode = config.getInt("groups.forwarding.message.mode") + val prefix = config.getString("groups.forwarding.message.prefix") + } + val dieMessage = config.getBoolean("groups.forwarding.dieMessage") + val whitelist = Whitelist(config) + class Whitelist(config: Configuration) { + val enable = config.getBoolean("groups.forwarding.whitelist.enable") + val maxCount = config.getInt("maxCount") + } + val cmd = config.getBoolean("groups.forwarding.cmd") + val joinAndLeave = config.getBoolean("gorups.forwarding.joinAndLeave") + val online = config.getBoolean("groups.forwarding.online") + val tps = config.getBoolean("groups.forwarding.tps") + val sdc = config.getBoolean("groups.forwarding.SDC") + val sdr = config.getBoolean("groups.forwarding.SDR") + } + } + class DataBase(config: Configuration) { + val type = config.getString("database.type") + val settings = Settings(config) + class Settings(config: Configuration) { + val sqlite = SQLite(config) + val mysql = MySQL(config) + val pool = Pool(config) + class SQLite(config: Configuration) { + val path = config.getString("database.setting.sqlite.path")?.replace("%plugin_folder%", getDataFolder().path) + } + class MySQL(config: Configuration) { + val host = config.getHost("database.settings.mysql.host") + val port = config.getInt("database.settings.mysql.port") + val database = config.getString("database.settings.mysql.database") + val username = config.getString("database.settings.mysql.username") + val password = config.getString("database.settings.mysql.password") + val flagsURL = config.getString("database.settings.mysql.flagsURL") + } + class Pool(config: Configuration) { + val connectionTimeout = config.getInt("database.settings.pool.connectionTimeout") + val idleTimeout = config.getInt("database.settings.pool.idleTimeout") + val maxLifetime = config.getInt("database.settings.pool.maxLifetime") + val maximumPoolSize = config.getInt("database.settings.pool.maximumPoolSize") + val keepaliveTime = config.getInt("database.settings.pool.keepaliveTime") + val minimumIdle = config.getInt("database.settings.pool.minimumIdle") + } + } + val enable = config.getBoolean("enable") + val host = config.getHost("host") + val port = config.getInt("port") + val database = config.getString("database") + val username = config.getString("username") + val password = config.getString("password") + val table = config.getString("table") + val columns = config.getMap("columns") + val prefix = config.getString("prefix") + val suffix = config.getString("suffix") + } class Bot(config: Configuration){ val mode = config.getString("bot.mode") - val gocqhttp = Gocqhttp(config) + val onebot = Onebot(config) val kook = Kook(config) - class Gocqhttp(config: Configuration){ - val ws = config.getString("bot.go-cqhttp.ws") - val token = config.getString("bot.go-cqhttp.token") - val hasAccessToken = config.getBoolean("bot.go-cqhttp.hasAccessToken") + class Onebot(config: Configuration){ + val ws = config.getString("bot.onebot.ws") + val token = Token(config) + class Token(config: Configuration) { + val enable = config.getBoolean("bot.onebot.token.enable") + val token = config.getString("bot.onebot.token.token") + } } class Kook(config: Configuration) { val token = config.getString("bot.kook.token") } } - class Forwarding(config: Configuration) { - val enable = config.getBoolean("forwarding.enable") - val mode = config.getInt("forwarding.mode") - val prefix = config.getString("forwarding.prefix") - } - class WhiteList(config: Configuration) { - val enable = config.getBoolean("whiteList.enable") - val maxCount = config.getInt("whitelist.maxCount") - } - class DataBase(config: Configuration) { - val type = config.getString("database.type") - private val sqlitePath = - config.getString("database.setting.sqlite.path")?.replace("%plugin_folder%", getDataFolder().path) - val sqliteHost = newFile(sqlitePath!!, create = true, folder = false).getHost() - val host = config.getHost("database.settings.mysql") - } + val groups = Groups(config) + val database = DataBase(config) + val bot = Bot(config) } class Commands(config: Configuration) { - val ver = config.getString("ver") + val version = config.getString("version") val adminCommand = config.getMap("admin") val userCommand = config.getMap("user") } class Returns(config: Configuration) { - val ver = config.getString("ver") + val version = config.getString("version") val adminReturn = config.getMap("admin") val userReturn = config.getMap("user") } diff --git a/common/src/main/kotlin/me/regadpole/plumbot/config/ConfigResolver.kt b/common/src/main/kotlin/me/regadpole/plumbot/config/ConfigResolver.kt index 8911e6a..ff4df21 100644 --- a/common/src/main/kotlin/me/regadpole/plumbot/config/ConfigResolver.kt +++ b/common/src/main/kotlin/me/regadpole/plumbot/config/ConfigResolver.kt @@ -68,7 +68,7 @@ object ConfigResolver { config = ConfigLoader(Configuration.loadFromFile(configFile, Type.YAML), Configuration.loadFromFile(commandsFile, Type.YAML), Configuration.loadFromFile(returnsFile, Type.YAML)) - if ("2.0.0" != config.getConfig().ver) { + if ("2.0.0" != config.getConfig().version) { plugin.javaClass.getResourceAsStream("/" + configFile.getName()).use { inputStream -> checkNotNull(inputStream) Files.copy(inputStream, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING) @@ -76,7 +76,7 @@ object ConfigResolver { return this } } - if ("2.0.0" != config.getCommands().ver) { + if ("2.0.0" != config.getCommands().version) { plugin.javaClass.getResourceAsStream("/" + commandsFile.getName()).use { inputStream -> checkNotNull(inputStream) Files.copy(inputStream, commandsFile.toPath(), StandardCopyOption.REPLACE_EXISTING) @@ -84,7 +84,7 @@ object ConfigResolver { return this } } - if ("2.0.0" != config.getReturns().ver) { + if ("2.0.0" != config.getReturns().version) { plugin.javaClass.getResourceAsStream("/" + returnsFile.getName()).use { inputStream -> checkNotNull(inputStream) Files.copy(inputStream, returnsFile.toPath(), StandardCopyOption.REPLACE_EXISTING) diff --git a/common/src/main/kotlin/me/regadpole/plumbot/database/SQLite.kt b/common/src/main/kotlin/me/regadpole/plumbot/database/SQLite.kt index 15d1870..0a778ed 100644 --- a/common/src/main/kotlin/me/regadpole/plumbot/database/SQLite.kt +++ b/common/src/main/kotlin/me/regadpole/plumbot/database/SQLite.kt @@ -8,7 +8,7 @@ import javax.sql.DataSource class SQLite: Database { - private val host = PlumBot.getConfig().getConfig().database.sqliteHost + private val host = PlumBot.getConfig().getConfig().database.host private val dataSource by lazy { host.createDataSource() } private val table = Table("whitelist", host) { diff --git a/common/src/main/kotlin/me/regadpole/plumbot/event/GDeathEvent.kt b/common/src/main/kotlin/me/regadpole/plumbot/event/GDeathEvent.kt new file mode 100644 index 0000000..2540f1f --- /dev/null +++ b/common/src/main/kotlin/me/regadpole/plumbot/event/GDeathEvent.kt @@ -0,0 +1,5 @@ +package me.regadpole.plumbot.event + +import me.regadpole.plumbot.util.GPlayer + +class GDeathEvent(val player: GPlayer) \ No newline at end of file diff --git a/common/src/main/kotlin/me/regadpole/plumbot/event/GJoinEvent.kt b/common/src/main/kotlin/me/regadpole/plumbot/event/GJoinEvent.kt new file mode 100644 index 0000000..43268a0 --- /dev/null +++ b/common/src/main/kotlin/me/regadpole/plumbot/event/GJoinEvent.kt @@ -0,0 +1,7 @@ +package me.regadpole.plumbot.event + +import me.regadpole.plumbot.util.GPlayer + +abstract class GJoinEvent(val player: GPlayer) { + abstract fun kick(message: String) +} \ No newline at end of file diff --git a/common/src/main/kotlin/me/regadpole/plumbot/event/GPlayerChatEvent.kt b/common/src/main/kotlin/me/regadpole/plumbot/event/GPlayerChatEvent.kt new file mode 100644 index 0000000..94687ef --- /dev/null +++ b/common/src/main/kotlin/me/regadpole/plumbot/event/GPlayerChatEvent.kt @@ -0,0 +1,5 @@ +package me.regadpole.plumbot.event + +import me.regadpole.plumbot.util.GPlayer + +class GPlayerChatEvent(val message: String, val player: GPlayer) \ No newline at end of file diff --git a/common/src/main/kotlin/me/regadpole/plumbot/event/GQuitEvent.kt b/common/src/main/kotlin/me/regadpole/plumbot/event/GQuitEvent.kt new file mode 100644 index 0000000..0453168 --- /dev/null +++ b/common/src/main/kotlin/me/regadpole/plumbot/event/GQuitEvent.kt @@ -0,0 +1,5 @@ +package me.regadpole.plumbot.event + +import me.regadpole.plumbot.util.GPlayer + +class GQuitEvent(val player: GPlayer) \ No newline at end of file diff --git a/common/src/main/kotlin/me/regadpole/plumbot/listener/game/GameListener.kt b/common/src/main/kotlin/me/regadpole/plumbot/listener/game/GameListener.kt new file mode 100644 index 0000000..0e74f46 --- /dev/null +++ b/common/src/main/kotlin/me/regadpole/plumbot/listener/game/GameListener.kt @@ -0,0 +1,70 @@ +package me.regadpole.plumbot.listener.game + +import me.regadpole.plumbot.PlumBot +import me.regadpole.plumbot.event.GDeathEvent +import me.regadpole.plumbot.event.GJoinEvent +import me.regadpole.plumbot.event.GPlayerChatEvent +import me.regadpole.plumbot.event.GQuitEvent +import taboolib.common5.util.replace + +class GameListener { + fun onChat(event: GPlayerChatEvent) { + if (PlumBot.getConfig().getConfig().groups.forwarding.message.enable) { + if (PlumBot.getConfig().getConfig().groups.forwarding.message.mode == 1 && !event.message.startsWith( + PlumBot.getConfig().getConfig().groups.forwarding.message.prefix?: "")) { + return + } + var message: String = PlumBot.getLangConfig().getLangConf().forwarding.toPlatform?: return + message = message.replace("%server_name%", event.player.server) + .replace("%world_name%", event.player.position.world) + .replace("%message%", event.message) + PlumBot.getConfig().getConfig().groups.enableGroups.forEach { + PlumBot.getBot().sendGroupMsg(it, message) + } + } + } + + fun onDie(event: GDeathEvent) { + if (PlumBot.getConfig().getConfig().groups.forwarding.dieMessage) { + var message: String = PlumBot.getLangConfig().getLangConf().messageOnDie?: return + message = message.replace("%player_name%", event.player.name) + .replace("%world_name%", event.player.position.world) + .replace("%pos%", event.player.position.toXYZ("/")) + PlumBot.getConfig().getConfig().groups.enableGroups.forEach { + PlumBot.getBot().sendGroupMsg(it, message) + } + } + } + + fun onJoin(event: GJoinEvent) { + if (PlumBot.getDatabase().getBindByName(event.player.name) == null) { + var message: String = PlumBot.getLangConfig().getLangConf().whitelist.kickServer?: return + message = message.replace("%enable_groups%", PlumBot.getConfig().getConfig().groups.enableGroups.joinToString("/")) + event.kick(message) + message = PlumBot.getLangConfig().getLangConf().whitelist.kickPlatform?: return + message = message.replace("%player_name%", event.player.name) + .replace("%server_name%", event.player.server) + PlumBot.getConfig().getConfig().groups.enableGroups.forEach { + PlumBot.getBot().sendGroupMsg(it, message) + } + } else if (PlumBot.getConfig().getConfig().groups.forwarding.joinAndLeave) { + var message: String = PlumBot.getLangConfig().getLangConf().playerJoinMsg?: return + message = message.replace("%player_name%", event.player.name) + .replace("%server_name%", event.player.server) + PlumBot.getConfig().getConfig().groups.enableGroups.forEach { + PlumBot.getBot().sendGroupMsg(it, message) + } + } + } + + fun onQuit(event: GQuitEvent) { + if (PlumBot.getConfig().getConfig().groups.forwarding.joinAndLeave) { + var message: String = PlumBot.getLangConfig().getLangConf().playerLeaveMsg?: return + message = message.replace("%player_name%", event.player.name) + .replace("%server_name%", event.player.server) + PlumBot.getConfig().getConfig().groups.enableGroups.forEach { + PlumBot.getBot().sendGroupMsg(it, message) + } + } + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/me/regadpole/plumbot/util/GPlayer.kt b/common/src/main/kotlin/me/regadpole/plumbot/util/GPlayer.kt new file mode 100644 index 0000000..0e05639 --- /dev/null +++ b/common/src/main/kotlin/me/regadpole/plumbot/util/GPlayer.kt @@ -0,0 +1,6 @@ +package me.regadpole.plumbot.util + +abstract class GPlayer(val name: String, var position: GPosition, val server: String, val isAdmin: Boolean) { + abstract fun teleport() + abstract fun sendMessage(message: String) +} \ No newline at end of file diff --git a/common/src/main/kotlin/me/regadpole/plumbot/util/GPosition.kt b/common/src/main/kotlin/me/regadpole/plumbot/util/GPosition.kt new file mode 100644 index 0000000..6fc243e --- /dev/null +++ b/common/src/main/kotlin/me/regadpole/plumbot/util/GPosition.kt @@ -0,0 +1,7 @@ +package me.regadpole.plumbot.util + +class GPosition(var world: String, var x: Double, var y: Double, var z: Double, var yaw: Float, var pitch: Float) { + fun toXYZ(split: String): String { + return "$x$split$y$split$z" + } +} \ No newline at end of file diff --git a/common/src/main/resources/commands.yml b/common/src/main/resources/commands.yml index dd63320..6cdad4e 100644 --- a/common/src/main/resources/commands.yml +++ b/common/src/main/resources/commands.yml @@ -1,5 +1,5 @@ #自定义命令配置 -ver: '2.0.0' +version: "2.0.0" #Admin中的命令只能管理员使用 admin: diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index b44c757..30b02ca 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -1,46 +1,75 @@ #机器人功能设置 -Ver: "2.0.0" -#语言文件在lang文件夹里 +# 版本号, 请勿修改! +version: "2.0.0" + +# 语言文件, 在lang文件夹里 lang: "zh_CN" -#群聊命令前缀 -commandPrefix: "/" -#消息转发 -forwarding: - enable: true - mode: 0 #mode设为0即无条件转发消息,设为1则消息前有前缀才会转发消息 - prefix: "#" -#死亡报告 -dieReport: false -#白名单 -whiteList: - enable: false - maxCount: 1 -#执行命令功能 -cmd: true -#进出提示 -joinAndLeave: true -#在线玩家查询 -online: true -#tps查询 -tps: true -#自定义命令 -SDC: true -#自定义回复 -SDR: true +# 群聊设置 +groups: + # 在哪些群聊(组号)启用 + enableGroups: + - 111 + + # 管理员的userId + botAdmins: + - 111 + + #群聊命令前缀 + commandPrefix: "/" + + #消息转发 + forwarding: + # 群聊消息 / 游戏内消息 双向转发 + message: + enable: true + mode: 0 #mode设为0即无条件转发消息,设为1则消息前有前缀才会转发消息 + prefix: "#" + + # 转发死亡信息 + dieMessage: false + + # 白名单功能 + whitelist: + enable: false + # 一个用户最多可以加多少个Minecraft账号 + maxCount: 1 + + # 群聊内执行命令功能 + cmd: true + + # 玩家进出提示 + joinAndLeave: true + + # 服务器在线玩家查询 + online: true + + # 服务器TPS查询 + tps: true + + # 自定义命令功能 + SDC: true + + # 自定义回复功能 + SDR: true + +# 数据库功能 database: + # 数据库类型, 可选sqlite, mysql type: sqlite settings: sqlite: + # 数据库保存路径 path: "%plugin_folder%/database.db" mysql: host: localhost port: 3306 database: plumbot - user: plumbot + username: plumbot password: plumbot flagsURL: "?useSSL=false" + # 连接池设置 pool: connectionTimeout: 30000 idleTimeout: 600000 @@ -48,32 +77,26 @@ database: maximumPoolSize: 15 keepaliveTime: 0 minimumIdle: 5 - #当服务端出现类似 - #“Receiver class org.sqlite.Conn does not define or + # 当服务端出现类似 + # “Receiver class org.sqlite.Conn does not define or # inherit an implementation of the resolved method 'abstract boolean isValid(int)' # of interface java.sql.Connection.” - #报错时,将下面配置取消注释 - #connectionTestQuery: "SELECT 1" - -enableGroups: - - 111 - #启用消息转发功能的群聊Id - -botAdmins: - - 111 - #管理员的userId + # 的报错时, 取消下面的注释项 + # connectionTestQuery: "SELECT 1" bot: + # 机器人模式, 可选onebot, kook mode: "kook" - #机器人模式,可选go-cqhttp、kook - go-cqhttp: + onebot: + # onebot协议端的正向ws模式的对应地址 ws: "ws://127.0.0.1:3001" - #go-cqhttp的config文件中正向ws模式 - token: "" - #go-cqhttp是否开启了access-token模式,如是,请填写,如否,则该项无效 - hasAccessToken: false - #go-cqhttp是否开启了access-token模式 + token: + # 是否需要token验证 + enable: true + + # 协议端token + accessToken: "" + # kook机器人,只支持websocket kook: - #kook机器人,只支持websocket - token: "" - #kook机器人Token \ No newline at end of file + # kook机器人token + token: "" \ No newline at end of file diff --git a/common/src/main/resources/returns.yml b/common/src/main/resources/returns.yml index a0f3b26..80f195e 100644 --- a/common/src/main/resources/returns.yml +++ b/common/src/main/resources/returns.yml @@ -1,5 +1,5 @@ #自定义回复配置 -ver: '2.0.0' +version: "2.0.0" admin: 自定义回复的关键词: 自定义回复的内容