mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2024-11-25 08:58:45 +00:00
several small updates
This commit is contained in:
parent
4ef28a072a
commit
18b2e7b3c4
@ -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"
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user