From a19b3d26df3dcfd1741af568390ca46f8c54fd5d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 22:14:16 +0600 Subject: [PATCH] fixes in events builder behaviours --- .../behaviour_builder/expectations/WaitEventAction.kt | 5 ++--- .../behaviour_builder/triggers_handling/EventTriggers.kt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index e792af6007..308c5dbd39 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -3,8 +3,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage -import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate +import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -24,7 +23,7 @@ private suspend fun BehaviourContext.waitEventMessages( count, errorFactory ) { - it.asMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull) + it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull) }.toList().toList() diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 7e7a8b8a27..fdea3f9a0a 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -16,7 +16,7 @@ internal suspend inline fun BehaviourContext.onEvent( noinline additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, noinline scenarioReceiver: BehaviourContextAndTypeReceiver> ) = flowsUpdatesFilter.expectFlow(bot) { - it.asMessageUpdate() ?.data ?.asChatEventMessage() ?.let { message -> + it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.let { message -> if (message.chatEvent is T) { val adaptedMessage = message as ChatEventMessage if (additionalFilter == null || additionalFilter(adaptedMessage)) adaptedMessage else null