several small updates

This commit is contained in:
InsanusMokrassar 2022-09-01 00:03:26 +06:00
parent 4ef28a072a
commit 18b2e7b3c4
2 changed files with 4 additions and 11 deletions

View File

@ -5,7 +5,7 @@ kotlin-serialization = "1.4.0"
plagubot = "2.2.0"
tgbotapi = "3.2.0"
microutils = "0.12.4"
microutils = "0.12.6"
kslog = "0.5.1"
dexcount = "3.1.0"

View File

@ -4,6 +4,7 @@ import dev.inmo.kslog.common.logger
import dev.inmo.kslog.common.w
import dev.inmo.plagubot.Plugin
import dev.inmo.plaguposter.posts.exposed.ExposedPostsRepo
import dev.inmo.plaguposter.posts.models.ChatConfig
import dev.inmo.plaguposter.posts.repo.PostsRepo
import dev.inmo.plaguposter.posts.sending.PostPublisher
import dev.inmo.tgbotapi.types.ChatId
@ -14,14 +15,6 @@ import org.jetbrains.exposed.sql.Database
import org.koin.core.module.Module
object Plugin : Plugin {
@Serializable
private data class Config(
@SerialName("targetChat")
val targetChatId: ChatId,
@SerialName("cacheChat")
val cacheChatId: ChatId
)
override fun Module.setupDI(database: Database, params: JsonObject) {
val configJson = params["posts"] ?: this@Plugin.let {
it.logger.w {
@ -29,10 +22,10 @@ object Plugin : Plugin {
}
return
}
single { get<Json>().decodeFromJsonElement(Config.serializer(), configJson) }
single { get<Json>().decodeFromJsonElement(ChatConfig.serializer(), configJson) }
single<PostsRepo> { ExposedPostsRepo(database) }
single {
val config = get<Config>()
val config = get<ChatConfig>()
PostPublisher(get(), get(), config.cacheChatId, config.targetChatId)
}
}