mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2024-11-17 13:33:47 +00:00
fixes
This commit is contained in:
parent
e8637a2de6
commit
96d3e52c5f
@ -31,7 +31,8 @@ object Plugin : Plugin {
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class Config(
|
data class Config(
|
||||||
val chats: ChatConfig,
|
val chats: ChatConfig,
|
||||||
val autoRemoveMessages: Boolean = true
|
val autoRemoveMessages: Boolean = true,
|
||||||
|
val deleteAfterPublishing: Boolean = true
|
||||||
)
|
)
|
||||||
override fun Module.setupDI(database: Database, params: JsonObject) {
|
override fun Module.setupDI(database: Database, params: JsonObject) {
|
||||||
val configJson = params["posts"] ?: this@Plugin.let {
|
val configJson = params["posts"] ?: this@Plugin.let {
|
||||||
@ -48,8 +49,8 @@ object Plugin : Plugin {
|
|||||||
WritePostsRepo::class,
|
WritePostsRepo::class,
|
||||||
)
|
)
|
||||||
single {
|
single {
|
||||||
val config = get<ChatConfig>()
|
val config = get<Config>()
|
||||||
PostPublisher(get(), get(), config.cacheChatId, config.targetChatId)
|
PostPublisher(get(), get(), config.chats.cacheChatId, config.chats.targetChatId, config.deleteAfterPublishing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@ package dev.inmo.plaguposter.triggers.command
|
|||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||||
import dev.inmo.micro_utils.fsm.common.State
|
import dev.inmo.micro_utils.fsm.common.State
|
||||||
import dev.inmo.plagubot.Plugin
|
import dev.inmo.plagubot.Plugin
|
||||||
|
import dev.inmo.plaguposter.common.SuccessfulSymbol
|
||||||
import dev.inmo.plaguposter.posts.repo.PostsRepo
|
import dev.inmo.plaguposter.posts.repo.PostsRepo
|
||||||
import dev.inmo.plaguposter.posts.sending.PostPublisher
|
import dev.inmo.plaguposter.posts.sending.PostPublisher
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.edit
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.send
|
import dev.inmo.tgbotapi.extensions.api.send.send
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextWithFSM
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextWithFSM
|
||||||
@ -15,6 +17,7 @@ import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
|
|||||||
import dev.inmo.tgbotapi.extensions.utils.contentMessageOrNull
|
import dev.inmo.tgbotapi.extensions.utils.contentMessageOrNull
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.ChatId
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.regular
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
@ -57,9 +60,10 @@ object Plugin : Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
publisher.publish(postId)
|
publisher.publish(postId)
|
||||||
reply(
|
|
||||||
|
edit(
|
||||||
it,
|
it,
|
||||||
"Successfully triggered publishing"
|
it.content.textSources + regular(SuccessfulSymbol)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user