1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-23 10:38:43 +00:00
tgbotapi/docs/dev.inmo.tgbotapi.extensions.behaviour_builder.expectations/expect-flow.md
2021-03-17 15:18:37 +00:00

22 KiB

//docs/dev.inmo.tgbotapi.extensions.behaviour_builder.expectations/expectFlow

expectFlow

[common]
Content
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>): <T>
More info

Parameters

common

initRequest

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

count

If set, result will return count elements on each

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

[common]
Content
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>): <T>
More info

Parameters

common

initRequest

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

count

If set, result will return count elements on each

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