chore: reduce jar file size and unsupport sqlite/postgresql/mysql
This commit is contained in:
8 files changed
+5
-66
No files matched your search
+1
-3
@@ -38,9 +38,7 @@ dependencies {
|
||||
implementation(libs.exposed.core)
|
||||
implementation(libs.exposed.jdbc)
|
||||
implementation(libs.exposed.dao)
|
||||
implementation(libs.sqlite.jdbc)
|
||||
implementation(libs.mysql.jdbc)
|
||||
implementation(libs.postgressql.jdbc)
|
||||
implementation(libs.h2.jdbc)
|
||||
implementation(libs.motd.pinger)
|
||||
implementation(libs.animated.gif.lib)
|
||||
implementation(libs.simple.java.mail)
|
||||
|
||||
@@ -4,7 +4,6 @@ ronebotVersion = "2.2.3"
|
||||
shadowVersion = "8.3.0"
|
||||
okhttpVersion = "5.0.0-alpha.14"
|
||||
exposedVersion = "0.53.0"
|
||||
sqliteJDBCVersion = "3.46.1.0"
|
||||
motdPingerVersion = "1.1.4"
|
||||
animatedGifLibVersion = "1.4"
|
||||
simpleJavaMailVersion = "8.12.2"
|
||||
@@ -15,9 +14,8 @@ logbackClassicVersion = "1.5.8"
|
||||
slf4jVersion = "2.0.16"
|
||||
awsS3SDKVersion = "2.28.18"
|
||||
rconLibVersion = "1.1.0"
|
||||
mysqlConnectorVersion = "9.1.0"
|
||||
postgresqlVersion = "42.7.4"
|
||||
mcprotolobVersion = "1.21-SNAPSHOT"
|
||||
h2Version = "2.3.232"
|
||||
|
||||
[libraries]
|
||||
ronebot = { group = "cn.rtast", name = "ROneBot", version.ref = "ronebotVersion" }
|
||||
@@ -26,9 +24,6 @@ okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhtt
|
||||
exposed-core = { group = "org.jetbrains.exposed", name = "exposed-core", version.ref = "exposedVersion" }
|
||||
exposed-jdbc = { group = "org.jetbrains.exposed", name = "exposed-jdbc", version.ref = "exposedVersion" }
|
||||
exposed-dao = { group = "org.jetbrains.exposed", name = "exposed-dao", version.ref = "exposedVersion" }
|
||||
sqlite-jdbc = { group = "org.xerial", name = "sqlite-jdbc", version.ref = "sqliteJDBCVersion" }
|
||||
mysql-jdbc = { group = "com.mysql", name = "mysql-connector-j", version.ref = "mysqlConnectorVersion" }
|
||||
postgressql-jdbc = { group = "org.postgresql", name = "postgresql", version.ref = "postgresqlVersion" }
|
||||
animated-gif-lib = { group = "com.madgag", name = "animated-gif-lib", version.ref = "animatedGifLibVersion" }
|
||||
simple-java-mail = { group = "org.simplejavamail", name = "simple-java-mail", version.ref = "simpleJavaMailVersion" }
|
||||
jsoup = { group = "org.jsoup", name = "jsoup", version.ref = "jsoupVersion" }
|
||||
@@ -40,6 +35,7 @@ slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4jVersi
|
||||
aws-s3-sdk = { group = "software.amazon.awssdk", name = "s3", version.ref = "awsS3SDKVersion" }
|
||||
rconlib = { group = "cn.rtast", name = "RCONLib", version.ref = "rconLibVersion" }
|
||||
mcprotocollib = { group = "org.geysermc.mcprotocollib", name = "protocol", version.ref = "mcprotolobVersion" }
|
||||
h2-jdbc = { group = "com.h2database", name = "h2", version.ref = "h2Version" }
|
||||
|
||||
[bundles]
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import cn.rtast.fancybot.commands.niuzi.NiuziRedeemCommand
|
||||
import cn.rtast.fancybot.commands.parse.AsciiArtCommand
|
||||
import cn.rtast.fancybot.commands.parse.ReverseGIFCommand
|
||||
import cn.rtast.fancybot.entity.Config
|
||||
import cn.rtast.fancybot.enums.DatabaseType
|
||||
import cn.rtast.fancybot.enums.ImageBedType
|
||||
import cn.rtast.fancybot.enums.ImageType
|
||||
import cn.rtast.fancybot.enums.WSType
|
||||
@@ -50,14 +49,6 @@ const val API_RTAST_URL = "https://api.rtast.cn"
|
||||
const val PBI_API_URL = "https://pbi.us.kg"
|
||||
|
||||
val DEFAULT_CONFIG = Config(
|
||||
database = Config.Database(
|
||||
DatabaseType.SQLite,
|
||||
"127.0.0.1",
|
||||
3306,
|
||||
"root",
|
||||
"114514",
|
||||
"fancybot"
|
||||
),
|
||||
ncmAPI = "https://ncm.rtast.cn",
|
||||
wsAddress = "ws://127.0.0.1",
|
||||
wsType = WSType.Client,
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
|
||||
package cn.rtast.fancybot.entity
|
||||
|
||||
import cn.rtast.fancybot.enums.DatabaseType
|
||||
import cn.rtast.fancybot.enums.ImageBedType
|
||||
import cn.rtast.fancybot.enums.ImageType
|
||||
import cn.rtast.fancybot.enums.WSType
|
||||
|
||||
data class Config(
|
||||
val database: Database,
|
||||
val ncmAPI: String,
|
||||
val wsType: WSType,
|
||||
val wsAddress: String,
|
||||
@@ -52,13 +50,4 @@ data class Config(
|
||||
val azureAppClientId: String,
|
||||
val youtubeDataApiKey: String,
|
||||
val naiLongApiUrl: String,
|
||||
) {
|
||||
data class Database(
|
||||
val type: DatabaseType,
|
||||
val host: String,
|
||||
val port: Int,
|
||||
val user: String,
|
||||
val password: String,
|
||||
val database: String,
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/10/17
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.enums
|
||||
|
||||
enum class DatabaseType {
|
||||
SQLite, MySQL, PostgreSQL
|
||||
}
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
package cn.rtast.fancybot.util
|
||||
|
||||
import cn.rtast.fancybot.ROOT_PATH
|
||||
import cn.rtast.fancybot.configManager
|
||||
import cn.rtast.fancybot.db.ActionTable
|
||||
import cn.rtast.fancybot.db.BlackListTable
|
||||
import cn.rtast.fancybot.db.JrrpTable
|
||||
@@ -16,25 +14,13 @@ import cn.rtast.fancybot.db.MinecraftAccessTokenTable
|
||||
import cn.rtast.fancybot.db.NiuziBankTable
|
||||
import cn.rtast.fancybot.db.NiuziTable
|
||||
import cn.rtast.fancybot.db.RCONTable
|
||||
import cn.rtast.fancybot.enums.DatabaseType
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.jetbrains.exposed.sql.SchemaUtils
|
||||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
||||
|
||||
suspend fun initDatabase() {
|
||||
val host = configManager.dbConfig.host
|
||||
val port = configManager.dbConfig.port
|
||||
val user = configManager.dbConfig.user
|
||||
val password = configManager.dbConfig.password
|
||||
val database = configManager.dbConfig.database
|
||||
if (configManager.dbConfig.type == DatabaseType.MySQL) {
|
||||
Database.connect("jdbc:mysql://${host}:${port}/$database", "com.mysql.cj.jdbc.Driver", user, password)
|
||||
} else if (configManager.dbConfig.type == DatabaseType.PostgreSQL) {
|
||||
Database.connect("jdbc:postgresql://$host:$port/$database", "org.postgresql.Driver", user, password)
|
||||
} else {
|
||||
Database.connect("jdbc:sqlite:file:$ROOT_PATH/data.sqlite", "org.sqlite.JDBC")
|
||||
}
|
||||
Database.connect("jdbc:h2:file:./data/data.h2;DB_CLOSE_DELAY=-1;", driver = "org.h2.Driver")
|
||||
suspendedTransaction {
|
||||
SchemaUtils.createMissingTablesAndColumns(JrrpTable)
|
||||
SchemaUtils.createMissingTablesAndColumns(NiuziBankTable)
|
||||
|
||||
@@ -49,6 +49,5 @@ class ConfigManager : JsonFileHandler<Config>("config.json") {
|
||||
val apiRtastKey = config.apiRtastKey
|
||||
val azureAppClientId = config.azureAppClientId
|
||||
val youtubeDataApiKey = config.youtubeDataApiKey
|
||||
val dbConfig = config.database
|
||||
val naiLongApiUrl = config.naiLongApiUrl
|
||||
}
|
||||
@@ -1,12 +1,4 @@
|
||||
{
|
||||
"database": {
|
||||
"type": "SQLite",
|
||||
"host": "127.0.0.1",
|
||||
"port": 3306,
|
||||
"user": "root",
|
||||
"password": "114514",
|
||||
"database": "fancybot"
|
||||
},
|
||||
"ncmAPI": "https://ncm.rtast.cn",
|
||||
"wsType": "Client",
|
||||
"wsAddress": "ws://127.0.0.1",
|
||||
|
||||
Reference in New Issue
Block a user