From df952c69b23b40c859398f2fc1afe2a8b3d5ec34 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 10 Nov 2022 18:28:56 +0000 Subject: [PATCH 1/2] Update telegram_bot_api_version to v4.1.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0defaa2..3466a22 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx768m kotlin_version=1.7.21 -telegram_bot_api_version=4.0.0 +telegram_bot_api_version=4.1.0 micro_utils_version=0.14.1 serialization_version=1.4.1 ktor_version=2.1.3 From 5aa69d7990812a977fe26187d0ea654e0b479410 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 11 Nov 2022 00:35:16 +0600 Subject: [PATCH 2/2] Update SimpleFSMBot.kt --- FSMBot/src/main/kotlin/SimpleFSMBot.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/FSMBot/src/main/kotlin/SimpleFSMBot.kt b/FSMBot/src/main/kotlin/SimpleFSMBot.kt index 707cf17..9d9a7f0 100644 --- a/FSMBot/src/main/kotlin/SimpleFSMBot.kt +++ b/FSMBot/src/main/kotlin/SimpleFSMBot.kt @@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams import dev.inmo.tgbotapi.extensions.utils.extensions.sameThread import dev.inmo.tgbotapi.extensions.utils.formatting.* -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.TextContent @@ -19,8 +19,8 @@ import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first sealed interface BotState : State -data class ExpectContentOrStopState(override val context: Pair, val sourceMessage: CommonMessage) : BotState -data class StopState(override val context: Pair) : BotState +data class ExpectContentOrStopState(override val context: IdChatIdentifier, val sourceMessage: CommonMessage) : BotState +data class StopState(override val context: IdChatIdentifier) : BotState suspend fun main(args: Array) { val botToken = args.first() @@ -43,8 +43,7 @@ suspend fun main(args: Array) { ) { strictlyOn { send( - it.context.first, - threadId = it.context.second + it.context, ) { +"Send me some content or " + botCommand("stop") + " if you want to stop sending" } @@ -57,13 +56,13 @@ suspend fun main(args: Array) { when { content is TextContent && content.parseCommandsWithParams().keys.contains("stop") -> StopState(it.context) else -> { - execute(content.createResend(it.context.first, messageThreadId = it.context.second)) + execute(content.createResend(it.context)) it } } } strictlyOn { - send(it.context.first, threadId = it.context.second) { +"You have stopped sending of content" } + send(it.context) { +"You have stopped sending of content" } null } @@ -71,7 +70,7 @@ suspend fun main(args: Array) { command( "start" ) { - startChain(ExpectContentOrStopState(it.chat.id to it.threadIdOrNull, it)) + startChain(ExpectContentOrStopState(it.chat.id, it)) } }.second.join() }