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
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user