docs

# expectOne

suspend fun < T > FlowsUpdatesFilter . expectOne ( bot: TelegramBot , initRequest: Request <*>? = null, errorFactory: NullableRequestBuilder <*> = { null }, cancelRequestFactory: NullableRequestBuilder <*> = { null }, cancelTrigger: suspend ( Update ) -> Boolean = { cancelRequestFactory(it) != null }, filter: suspend ( Update ) -> T ?): T
Content copied to clipboard

## Parameters

initRequest

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

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 . expectOne ( initRequest: Request <*>? = null, errorFactory: NullableRequestBuilder <*> = { null }, cancelRequestFactory: NullableRequestBuilder <*> = { null }, cancelTrigger: suspend ( Update ) -> Boolean = { cancelRequestFactory(it) != null }, filter: suspend ( Update ) -> T ?): T
Content copied to clipboard

## Parameters

initRequest

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

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