expectFlow

suspend fun <T> FlowsUpdatesFilter.expectFlow(    bot: TelegramBot,     initRequest: Request<*>? = null,     count: Int? = null,     errorFactory: NullableRequestBuilder<*> = { null },     cancelRequestFactory: NullableRequestBuilder<*> = { null },     cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },     filter: suspend (Update) -> List<T>): Flow<T>

Parameters

initRequest

If not null, this request will be sent by bot before returning value

count

If set, result Flow will return count elements on each Flow.collect

errorFactory

If set, this factory will be used to produce requests in case when user have sent incorrect data

cancelRequestFactory

If set, this factory will be used to produce requests in case when it is required to say user that chain of scenario has been cancelled

cancelTrigger

When this trigger returns true, chain is cancelled

filter

It is main param, which will be called on each update. When it return not null, result will be returned as is, but when it returns null, then will be called cancelTrigger (if it will return true - cancelRequestFactory will be called too), errorFactory and then will be returned null


suspend fun <T> BehaviourContext.expectFlow(    initRequest: Request<*>? = null,     count: Int? = null,     errorFactory: NullableRequestBuilder<*> = { null },     cancelRequestFactory: NullableRequestBuilder<*> = { null },     cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },     filter: suspend (Update) -> List<T>): Flow<T>

Parameters

initRequest

If not null, this request will be sent by bot before returning value

count

If set, result Flow will return count elements on each Flow.collect

errorFactory

If set, this factory will be used to produce requests in case when user have sent incorrect data

cancelRequestFactory

If set, this factory will be used to produce requests in case when it is required to say user that chain of scenario has been cancelled

cancelTrigger

When this trigger returns true, chain is cancelled

filter

It is main param, which will be called on each update. When it return not null, result will be returned as is, but when it returns null, then will be called cancelTrigger (if it will return true - cancelRequestFactory will be called too), errorFactory and then will be returned null