mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-07-03 05:47:24 +00:00
feat(meta): 新增 meta 模块.
将与配置相关的内容迁移到 scalabot-meta 模块. 其他项目可以使用 meta 模块来生成 ScalaBot 的配置文件, 通过配置文件管理 ScalaBot 的运行. BREAKING CHANGE: 与配置有关的类迁移到了 scalabot-meta 模块. 目前仅所有配置类 (以 `Config` 结尾的 Class) 和相应的序列化类 (以 `Serializer` 结尾的) 都迁移到了 meta 模块, 但其工具方法则作为扩展函数保留在 app 模块中. 这么做的好处是为了方便其他应用 (例如 ScalaBot 外部管理程序) 根据需要生成配置文件. scalabot-meta 将会作为依赖项发布, 可根据需要获取 ScalaBot-meta 生成 ScalaBot 的配置. + 此次改动普通用户无需迁移。
This commit is contained in:
@ -3,6 +3,10 @@ package net.lamgc.scalabot
|
||||
import io.prometheus.client.exporter.HTTPServer
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import mu.KotlinLogging
|
||||
import net.lamgc.scalabot.config.AppConfig
|
||||
import net.lamgc.scalabot.config.BotConfig
|
||||
import net.lamgc.scalabot.config.MetricsConfig
|
||||
import net.lamgc.scalabot.config.ProxyType
|
||||
import net.lamgc.scalabot.util.registerShutdownHook
|
||||
import org.eclipse.aether.repository.LocalRepository
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions
|
||||
@ -71,9 +75,9 @@ internal class Launcher(private val config: AppConfig = Const.config) : AutoClos
|
||||
|
||||
private fun getMavenLocalRepository(): LocalRepository {
|
||||
val localPath =
|
||||
if (config.mavenLocalRepository != null && config.mavenLocalRepository.isNotEmpty()) {
|
||||
if (config.mavenLocalRepository != null && config.mavenLocalRepository!!.isNotEmpty()) {
|
||||
val repoPath = AppPaths.DATA_ROOT.file.toPath()
|
||||
.resolve(config.mavenLocalRepository)
|
||||
.resolve(config.mavenLocalRepository!!)
|
||||
.apply {
|
||||
if (!exists()) {
|
||||
if (!parent.isWritable() || !parent.isReadable()) {
|
||||
@ -133,23 +137,21 @@ internal class Launcher(private val config: AppConfig = Const.config) : AutoClos
|
||||
log.info { "正在启动机器人 `${botConfig.account.name}`..." }
|
||||
val botOption = DefaultBotOptions().apply {
|
||||
val proxyConfig =
|
||||
if (botConfig.proxy != null && botConfig.proxy.type != DefaultBotOptions.ProxyType.NO_PROXY) {
|
||||
if (botConfig.proxy.type != ProxyType.NO_PROXY) {
|
||||
botConfig.proxy
|
||||
} else if (config.proxy.type != DefaultBotOptions.ProxyType.NO_PROXY) {
|
||||
} else if (config.proxy.type != ProxyType.NO_PROXY) {
|
||||
config.proxy
|
||||
} else {
|
||||
null
|
||||
}
|
||||
if (proxyConfig != null) {
|
||||
proxyType = proxyConfig.type
|
||||
proxyType = proxyConfig.type.toTelegramBotsType()
|
||||
proxyHost = config.proxy.host
|
||||
proxyPort = config.proxy.port
|
||||
log.debug { "机器人 `${botConfig.account.name}` 已启用代理配置: $proxyConfig" }
|
||||
}
|
||||
|
||||
if (botConfig.baseApiUrl != null) {
|
||||
baseUrl = botConfig.baseApiUrl
|
||||
}
|
||||
baseUrl = botConfig.baseApiUrl
|
||||
}
|
||||
val account = botConfig.account
|
||||
|
||||
|
Reference in New Issue
Block a user