mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-30 14:08:44 +00:00
fixes in events builder behaviours
This commit is contained in:
parent
f93d9938de
commit
a19b3d26df
@ -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 <O> BehaviourContext.waitEventMessages(
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
it.asMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull)
|
||||
it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull)
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ internal suspend inline fun <reified T : ChatEvent> BehaviourContext.onEvent(
|
||||
noinline additionalFilter: (suspend (ChatEventMessage<T>) -> Boolean)? = null,
|
||||
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<T>>
|
||||
) = 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<T>
|
||||
if (additionalFilter == null || additionalFilter(adaptedMessage)) adaptedMessage else null
|
||||
|
Loading…
Reference in New Issue
Block a user