From 96d3e52c5f2627166bad2d88088561048a8a0ceb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 4 Sep 2022 15:48:45 +0600 Subject: [PATCH] fixes --- posts/src/jvmMain/kotlin/Plugin.kt | 7 ++++--- triggers/command/src/jvmMain/kotlin/Plugin.kt | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/posts/src/jvmMain/kotlin/Plugin.kt b/posts/src/jvmMain/kotlin/Plugin.kt index 41d8ea6..3025093 100644 --- a/posts/src/jvmMain/kotlin/Plugin.kt +++ b/posts/src/jvmMain/kotlin/Plugin.kt @@ -31,7 +31,8 @@ object Plugin : Plugin { @Serializable data class Config( val chats: ChatConfig, - val autoRemoveMessages: Boolean = true + val autoRemoveMessages: Boolean = true, + val deleteAfterPublishing: Boolean = true ) override fun Module.setupDI(database: Database, params: JsonObject) { val configJson = params["posts"] ?: this@Plugin.let { @@ -48,8 +49,8 @@ object Plugin : Plugin { WritePostsRepo::class, ) single { - val config = get() - PostPublisher(get(), get(), config.cacheChatId, config.targetChatId) + val config = get() + PostPublisher(get(), get(), config.chats.cacheChatId, config.chats.targetChatId, config.deleteAfterPublishing) } } diff --git a/triggers/command/src/jvmMain/kotlin/Plugin.kt b/triggers/command/src/jvmMain/kotlin/Plugin.kt index daa07e5..f37ffe1 100644 --- a/triggers/command/src/jvmMain/kotlin/Plugin.kt +++ b/triggers/command/src/jvmMain/kotlin/Plugin.kt @@ -3,8 +3,10 @@ package dev.inmo.plaguposter.triggers.command import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.micro_utils.fsm.common.State import dev.inmo.plagubot.Plugin +import dev.inmo.plaguposter.common.SuccessfulSymbol import dev.inmo.plaguposter.posts.repo.PostsRepo 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.send 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.types.ChatId import dev.inmo.tgbotapi.types.MessageIdentifier +import dev.inmo.tgbotapi.types.message.textsources.regular import kotlinx.coroutines.flow.filter import kotlinx.serialization.Serializable import kotlinx.serialization.json.* @@ -57,9 +60,10 @@ object Plugin : Plugin { } publisher.publish(postId) - reply( + + edit( it, - "Successfully triggered publishing" + it.content.textSources + regular(SuccessfulSymbol) ) } }