mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-23 02:28:45 +00:00
include media groups
This commit is contained in:
parent
633239961a
commit
ce0fceb240
@ -34,11 +34,11 @@ suspend fun <T> FlowsUpdatesFilter.expectFlow(
|
|||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
||||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
||||||
filter: suspend (Update) -> T?
|
filter: suspend (Update) -> List<T>
|
||||||
): Flow<T> {
|
): Flow<T> {
|
||||||
val flow = allUpdatesFlow.mapNotNull {
|
val flow = allUpdatesFlow.flatMapConcat {
|
||||||
val result = safelyWithoutExceptions { filter(it) }
|
val result = safelyWithoutExceptions { filter(it) }
|
||||||
if (result == null) {
|
(if (result == null || result.isEmpty()) {
|
||||||
if (cancelTrigger(it)) {
|
if (cancelTrigger(it)) {
|
||||||
cancelRequestFactory(it) ?.also {
|
cancelRequestFactory(it) ?.also {
|
||||||
safelyWithoutExceptions { bot.execute(it) }
|
safelyWithoutExceptions { bot.execute(it) }
|
||||||
@ -48,10 +48,10 @@ suspend fun <T> FlowsUpdatesFilter.expectFlow(
|
|||||||
errorFactory(it) ?.also { errorRequest ->
|
errorFactory(it) ?.also { errorRequest ->
|
||||||
safelyWithoutExceptions { bot.execute(errorRequest) }
|
safelyWithoutExceptions { bot.execute(errorRequest) }
|
||||||
}
|
}
|
||||||
null
|
emptyList()
|
||||||
} else {
|
} else {
|
||||||
result
|
result
|
||||||
}
|
}).asFlow()
|
||||||
}
|
}
|
||||||
val result = if (count == null) {
|
val result = if (count == null) {
|
||||||
flow
|
flow
|
||||||
@ -79,7 +79,7 @@ suspend fun <T> BehaviourContext.expectFlow(
|
|||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
||||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
||||||
filter: suspend (Update) -> T?
|
filter: suspend (Update) -> List<T>
|
||||||
) = flowsUpdatesFilter.expectFlow(bot, initRequest, count, errorFactory, cancelRequestFactory, cancelTrigger, filter)
|
) = flowsUpdatesFilter.expectFlow(bot, initRequest, count, errorFactory, cancelRequestFactory, cancelTrigger, filter)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,8 +99,10 @@ suspend fun <T> FlowsUpdatesFilter.expectOne(
|
|||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
||||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
||||||
filter: suspend (Update) -> T?,
|
filter: suspend (Update) -> T?
|
||||||
): T = expectFlow(bot, initRequest, 1, errorFactory, cancelRequestFactory, cancelTrigger, filter).first()
|
): T = expectFlow(bot, initRequest, 1, errorFactory, cancelRequestFactory, cancelTrigger) {
|
||||||
|
listOfNotNull(filter.invoke(it))
|
||||||
|
}.first()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
||||||
|
@ -20,7 +20,7 @@ private suspend fun <O> BehaviourContext.waitCallbackQueries(
|
|||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
it.asCallbackQueryUpdate() ?.data ?.mapper()
|
it.asCallbackQueryUpdate() ?.data ?.mapper().let(::listOfNotNull)
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asContentMessage
|
import dev.inmo.tgbotapi.extensions.utils.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.media.*
|
||||||
@ -18,6 +18,7 @@ typealias ContentMessageToContentMapper<T> = suspend ContentMessage<T>.() -> T?
|
|||||||
private suspend fun <O> BehaviourContext.waitContentMessage(
|
private suspend fun <O> BehaviourContext.waitContentMessage(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
includeMediaGroups: Boolean = true,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
mapper: suspend ContentMessage<MessageContent>.() -> O?
|
mapper: suspend ContentMessage<MessageContent>.() -> O?
|
||||||
): List<O> = expectFlow(
|
): List<O> = expectFlow(
|
||||||
@ -25,17 +26,24 @@ private suspend fun <O> BehaviourContext.waitContentMessage(
|
|||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
it.asMessageUpdate() ?.data ?.asContentMessage() ?.mapper()
|
if (includeMediaGroups) {
|
||||||
|
it.asSentMediaGroupUpdate() ?.data ?.mapNotNull {
|
||||||
|
(it as ContentMessage<MessageContent>).mapper()
|
||||||
|
} ?.let { return@expectFlow it }
|
||||||
|
}
|
||||||
|
it.asMessageUpdate() ?.data ?.asContentMessage() ?.mapper().let(::listOfNotNull)
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitContent(
|
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitContent(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
includeMediaGroups: Boolean = true,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: ContentMessageToContentMapper<T>? = null
|
noinline filter: ContentMessageToContentMapper<T>? = null
|
||||||
) : List<T> = waitContentMessage<T>(
|
) : List<T> = waitContentMessage<T>(
|
||||||
count,
|
count,
|
||||||
initRequest,
|
initRequest,
|
||||||
|
includeMediaGroups,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
if (content is T) {
|
if (content is T) {
|
||||||
@ -56,124 +64,124 @@ suspend fun BehaviourContext.waitContact(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<ContactContent>? = null
|
filter: ContentMessageToContentMapper<ContactContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitDice(
|
suspend fun BehaviourContext.waitDice(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<DiceContent>? = null
|
filter: ContentMessageToContentMapper<DiceContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitGame(
|
suspend fun BehaviourContext.waitGame(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<GameContent>? = null
|
filter: ContentMessageToContentMapper<GameContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitLocation(
|
suspend fun BehaviourContext.waitLocation(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<LocationContent>? = null
|
filter: ContentMessageToContentMapper<LocationContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitPoll(
|
suspend fun BehaviourContext.waitPoll(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<PollContent>? = null
|
filter: ContentMessageToContentMapper<PollContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitText(
|
suspend fun BehaviourContext.waitText(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<TextContent>? = null
|
filter: ContentMessageToContentMapper<TextContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitVenue(
|
suspend fun BehaviourContext.waitVenue(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<VenueContent>? = null
|
filter: ContentMessageToContentMapper<VenueContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroup(
|
suspend fun BehaviourContext.waitAudioMediaGroup(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<AudioMediaGroupContent>? = null
|
filter: ContentMessageToContentMapper<AudioMediaGroupContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroup(
|
suspend fun BehaviourContext.waitDocumentMediaGroup(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<DocumentMediaGroupContent>? = null
|
filter: ContentMessageToContentMapper<DocumentMediaGroupContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitMedia(
|
suspend fun BehaviourContext.waitMedia(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<MediaContent>? = null
|
filter: ContentMessageToContentMapper<MediaContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitMediaGroup(
|
suspend fun BehaviourContext.waitMediaGroup(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<MediaGroupContent>? = null
|
filter: ContentMessageToContentMapper<MediaGroupContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroup(
|
suspend fun BehaviourContext.waitVisualMediaGroup(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<VisualMediaGroupContent>? = null
|
filter: ContentMessageToContentMapper<VisualMediaGroupContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitAnimation(
|
suspend fun BehaviourContext.waitAnimation(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<AnimationContent>? = null
|
filter: ContentMessageToContentMapper<AnimationContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitAudio(
|
suspend fun BehaviourContext.waitAudio(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<AudioContent>? = null
|
filter: ContentMessageToContentMapper<AudioContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitDocument(
|
suspend fun BehaviourContext.waitDocument(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<DocumentContent>? = null
|
filter: ContentMessageToContentMapper<DocumentContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitPhoto(
|
suspend fun BehaviourContext.waitPhoto(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<PhotoContent>? = null
|
filter: ContentMessageToContentMapper<PhotoContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitSticker(
|
suspend fun BehaviourContext.waitSticker(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<StickerContent>? = null
|
filter: ContentMessageToContentMapper<StickerContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitVideo(
|
suspend fun BehaviourContext.waitVideo(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<VideoContent>? = null
|
filter: ContentMessageToContentMapper<VideoContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitVideoNote(
|
suspend fun BehaviourContext.waitVideoNote(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<VideoNoteContent>? = null
|
filter: ContentMessageToContentMapper<VideoNoteContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitVoice(
|
suspend fun BehaviourContext.waitVoice(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<VoiceContent>? = null
|
filter: ContentMessageToContentMapper<VoiceContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, true, errorFactory, filter)
|
||||||
suspend fun BehaviourContext.waitInvoice(
|
suspend fun BehaviourContext.waitInvoice(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
filter: ContentMessageToContentMapper<InvoiceContent>? = null
|
filter: ContentMessageToContentMapper<InvoiceContent>? = null
|
||||||
) = waitContent(count, initRequest, errorFactory, filter)
|
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||||
|
@ -23,7 +23,7 @@ private suspend fun <O> BehaviourContext.waitEventMessages(
|
|||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
it.asMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper()
|
it.asMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull)
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ internal suspend inline fun <reified T : CallbackQuery> BehaviourContext.onCallb
|
|||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}.let(::listOfNotNull)
|
||||||
}.subscribeSafelyWithoutExceptions(scope) { triggerQuery ->
|
}.subscribeSafelyWithoutExceptions(scope) { triggerQuery ->
|
||||||
val (jobToCancel, scenario) = if (includeFilterByChatInBehaviourSubContext) {
|
val (jobToCancel, scenario) = if (includeFilterByChatInBehaviourSubContext) {
|
||||||
val subFilter = FlowsUpdatesFilter()
|
val subFilter = FlowsUpdatesFilter()
|
||||||
|
@ -6,8 +6,7 @@ import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTypeReceiver
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTypeReceiver
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asContentMessage
|
import dev.inmo.tgbotapi.extensions.utils.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
||||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
@ -21,9 +20,22 @@ import kotlinx.coroutines.flow.filter
|
|||||||
|
|
||||||
internal suspend inline fun <reified T : MessageContent> BehaviourContext.onContent(
|
internal suspend inline fun <reified T : MessageContent> BehaviourContext.onContent(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
|
includeMediaGroups: Boolean = true,
|
||||||
noinline additionalFilter: (suspend (ContentMessage<T>) -> Boolean)? = null,
|
noinline additionalFilter: (suspend (ContentMessage<T>) -> Boolean)? = null,
|
||||||
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<T>>
|
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<T>>
|
||||||
) = flowsUpdatesFilter.expectFlow(bot) {
|
) = flowsUpdatesFilter.expectFlow(bot) {
|
||||||
|
if (includeMediaGroups) {
|
||||||
|
it.asSentMediaGroupUpdate() ?.data ?.mapNotNull {
|
||||||
|
if (it.content is T) {
|
||||||
|
val adaptedMessage = it as ContentMessage<T>
|
||||||
|
if (additionalFilter == null || additionalFilter(adaptedMessage)) adaptedMessage else null
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
} ?.let {
|
||||||
|
return@expectFlow it
|
||||||
|
}
|
||||||
|
}
|
||||||
it.asMessageUpdate() ?.data ?.asContentMessage() ?.let { message ->
|
it.asMessageUpdate() ?.data ?.asContentMessage() ?.let { message ->
|
||||||
if (message.content is T) {
|
if (message.content is T) {
|
||||||
val adaptedMessage = message as ContentMessage<T>
|
val adaptedMessage = message as ContentMessage<T>
|
||||||
@ -31,7 +43,7 @@ internal suspend inline fun <reified T : MessageContent> BehaviourContext.onCont
|
|||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}.let(::listOfNotNull)
|
||||||
}.subscribeSafelyWithoutExceptions(scope) { triggerMessage ->
|
}.subscribeSafelyWithoutExceptions(scope) { triggerMessage ->
|
||||||
val (jobToCancel, scenario) = if (includeFilterByChatInBehaviourSubContext) {
|
val (jobToCancel, scenario) = if (includeFilterByChatInBehaviourSubContext) {
|
||||||
val subFilter = FlowsUpdatesFilter()
|
val subFilter = FlowsUpdatesFilter()
|
||||||
@ -52,109 +64,109 @@ suspend fun BehaviourContext.onContact(
|
|||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<ContactContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<ContactContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<ContactContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<ContactContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onDice(
|
suspend fun BehaviourContext.onDice(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<DiceContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<DiceContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<DiceContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<DiceContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onGame(
|
suspend fun BehaviourContext.onGame(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<GameContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<GameContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<GameContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<GameContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onLocation(
|
suspend fun BehaviourContext.onLocation(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<LocationContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<LocationContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<LocationContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<LocationContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onPoll(
|
suspend fun BehaviourContext.onPoll(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<PollContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<PollContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<PollContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<PollContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onText(
|
suspend fun BehaviourContext.onText(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<TextContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<TextContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<TextContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<TextContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onVenue(
|
suspend fun BehaviourContext.onVenue(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<VenueContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<VenueContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VenueContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VenueContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onAudioMediaGroup(
|
suspend fun BehaviourContext.onAudioMediaGroup(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<AudioMediaGroupContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<AudioMediaGroupContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<AudioMediaGroupContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<AudioMediaGroupContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onDocumentMediaGroup(
|
suspend fun BehaviourContext.onDocumentMediaGroup(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<DocumentMediaGroupContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<DocumentMediaGroupContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<DocumentMediaGroupContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<DocumentMediaGroupContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onMediaCollection(
|
suspend fun BehaviourContext.onMediaCollection(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<MediaCollectionContent<TelegramMediaFile>>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<MediaCollectionContent<TelegramMediaFile>>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<MediaCollectionContent<TelegramMediaFile>>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<MediaCollectionContent<TelegramMediaFile>>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onMedia(
|
suspend fun BehaviourContext.onMedia(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<MediaContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<MediaContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<MediaContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<MediaContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onMediaGroup(
|
suspend fun BehaviourContext.onMediaGroup(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<MediaGroupContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<MediaGroupContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<MediaGroupContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<MediaGroupContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onVisualMediaGroup(
|
suspend fun BehaviourContext.onVisualMediaGroup(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<VisualMediaGroupContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<VisualMediaGroupContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VisualMediaGroupContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VisualMediaGroupContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onAnimation(
|
suspend fun BehaviourContext.onAnimation(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<AnimationContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<AnimationContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<AnimationContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<AnimationContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onAudio(
|
suspend fun BehaviourContext.onAudio(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<AudioContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<AudioContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<AudioContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<AudioContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onDocument(
|
suspend fun BehaviourContext.onDocument(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<DocumentContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<DocumentContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<DocumentContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<DocumentContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onPhoto(
|
suspend fun BehaviourContext.onPhoto(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<PhotoContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<PhotoContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<PhotoContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<PhotoContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onSticker(
|
suspend fun BehaviourContext.onSticker(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<StickerContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<StickerContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<StickerContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<StickerContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onVideo(
|
suspend fun BehaviourContext.onVideo(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<VideoContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<VideoContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VideoContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VideoContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, true, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onVideoNote(
|
suspend fun BehaviourContext.onVideoNote(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<VideoNoteContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<VideoNoteContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VideoNoteContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VideoNoteContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onVoice(
|
suspend fun BehaviourContext.onVoice(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<VoiceContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<VoiceContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VoiceContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<VoiceContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onInvoice(
|
suspend fun BehaviourContext.onInvoice(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ContentMessage<InvoiceContent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ContentMessage<InvoiceContent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<InvoiceContent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ContentMessage<InvoiceContent>>
|
||||||
) = onContent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onContent(includeFilterByChatInBehaviourSubContext, false, additionalFilter, scenarioReceiver)
|
||||||
|
@ -29,7 +29,7 @@ internal suspend inline fun <reified T : ChatEvent> BehaviourContext.onEvent(
|
|||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}.let(::listOfNotNull)
|
||||||
}.subscribeSafelyWithoutExceptions(scope) { triggerMessage ->
|
}.subscribeSafelyWithoutExceptions(scope) { triggerMessage ->
|
||||||
val (jobToCancel, scenario) = if (includeFilterByChatInBehaviourSubContext) {
|
val (jobToCancel, scenario) = if (includeFilterByChatInBehaviourSubContext) {
|
||||||
val subFilter = FlowsUpdatesFilter()
|
val subFilter = FlowsUpdatesFilter()
|
||||||
|
Loading…
Reference in New Issue
Block a user