docs

# BehaviourContextWithFSM

interface BehaviourContextWithFSM < T : State> : BehaviourContext, StatesMachine< T >
Content copied to clipboard

Interface which combine BehaviourContext and StatesMachine. Subcontext of triggers and states contexts must have one common flow of updates and must not lose updates between updates

## See also

dev.inmo.tgbotapi.extensions.behaviour_builder.DefaultBehaviourContextWithFSM
buildBehaviourWithFSM

## Types

Companion
Link copied to clipboard
object Companion
Content copied to clipboard

## Functions

add
Link copied to clipboard
abstract fun < I : T > add ( kClass: KClass < I >, strict: Boolean = false, handler: BehaviourWithFSMStateHandler < I , T >)
Content copied to clipboard

Add NON STRICT handler to list of available in future BehaviourContextWithFSM. Non strict means that for input State will be used KClass.isInstance and any inheritor of kClass will pass this requirement

addStrict
Link copied to clipboard
open fun < I : T > addStrict (kClass: KClass < I >, handler: BehaviourWithFSMStateHandler < I , T >)
Content copied to clipboard

Add STRICT handler to list of available in future BehaviourContextWithFSM. Strict means that for input State will be used State::class == kClass and any State with exactly the same type will pass requirements

close
Link copied to clipboard
expect abstract fun close ()
Content copied to clipboard
copy
Link copied to clipboard
abstract override fun copy ( bot: TelegramBot , scope: CoroutineScope, broadcastChannelsSize: Int , onBufferOverflow: BufferOverflow, upstreamUpdatesFlow: Flow< Update >?, triggersHolder: TriggersHolder , updatesFilter: BehaviourContextAndTypeReceiver < Boolean , Update >?): BehaviourContextWithFSM < T >
Content copied to clipboard
open fun copy ( bot: TelegramBot = this.bot, scope: CoroutineScope = this.scope, broadcastChannelsSize: Int = 100, onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, upstreamUpdatesFlow: Flow< Update >? = null, triggersHolder: TriggersHolder = this.triggersHolder, onStateHandlingErrorHandler: StateHandlingErrorHandler< T > = defaultStateHandlingErrorHandler(), updatesFilter: BehaviourContextAndTypeReceiver < Boolean , Update >? = null): BehaviourContextWithFSM < T >
Content copied to clipboard
execute
Link copied to clipboard
abstract suspend fun < T : Any > execute (request: Request < T >): T
Content copied to clipboard

Unsafe execution of incoming request. Can throw almost any exception. So, it is better to use something like dev.inmo.tgbotapi.extensions.utils.shortcuts.executeAsync or dev.inmo.tgbotapi.extensions.utils.shortcuts.executeUnsafe

handleState
Link copied to clipboard
abstract suspend fun StatesMachine<in T >. handleState (state: T ): T ?
Content copied to clipboard
launchStateHandling
Link copied to clipboard
open suspend fun launchStateHandling (state: T , handlers: List <CheckableHandlerHolder<in T , T >>): T ?
Content copied to clipboard
open suspend fun launchStateHandling ( state: T , handlers: List <CheckableHandlerHolder<in T , T >>, onStateHandlingErrorHandler: suspend ( T , Throwable ) -> T ?): T ?
Content copied to clipboard
start
Link copied to clipboard
open suspend fun start (): Job
Content copied to clipboard
abstract fun start (scope: CoroutineScope): Job
Content copied to clipboard
startChain
Link copied to clipboard
abstract suspend fun startChain (state: T )
Content copied to clipboard

## Properties

allowedUpdates
Link copied to clipboard
open override val allowedUpdates : List < String >
Content copied to clipboard
allUpdatesFlow
Link copied to clipboard
abstract val allUpdatesFlow : Flow< Update >
Content copied to clipboard
allUpdatesWithoutMediaGroupsGroupingFlow
Link copied to clipboard
abstract val allUpdatesWithoutMediaGroupsGroupingFlow : Flow< Update >
Content copied to clipboard
asUpdateReceiver
Link copied to clipboard
abstract val asUpdateReceiver : UpdateReceiver < Update >
Content copied to clipboard
bot
Link copied to clipboard
open val bot : TelegramBot
Content copied to clipboard
callbackQueriesFlow
Link copied to clipboard
abstract val callbackQueriesFlow : Flow< CallbackQueryUpdate >
Content copied to clipboard
channelPostMediaGroupsFlow
Link copied to clipboard
abstract val channelPostMediaGroupsFlow : Flow< ChannelPostMediaGroupUpdate >
Content copied to clipboard
channelPostsFlow
Link copied to clipboard
abstract val channelPostsFlow : Flow< ChannelPostUpdate >
Content copied to clipboard
chatJoinRequestUpdateFlow
Link copied to clipboard
abstract val chatJoinRequestUpdateFlow : Flow< ChatJoinRequestUpdate >
Content copied to clipboard
chatMemberUpdatesFlow
Link copied to clipboard
abstract val chatMemberUpdatesFlow : Flow< CommonChatMemberUpdatedUpdate >
Content copied to clipboard
chosenInlineResultsFlow
Link copied to clipboard
abstract val chosenInlineResultsFlow : Flow< ChosenInlineResultUpdate >
Content copied to clipboard
coroutineContext
Link copied to clipboard
abstract val coroutineContext : CoroutineContext
Content copied to clipboard
editedChannelPostMediaGroupsFlow
Link copied to clipboard
abstract val editedChannelPostMediaGroupsFlow : Flow< EditChannelPostMediaGroupUpdate >
Content copied to clipboard
editedChannelPostsFlow
Link copied to clipboard
abstract val editedChannelPostsFlow : Flow< EditChannelPostUpdate >
Content copied to clipboard
editedMessageMediaGroupsFlow
Link copied to clipboard
abstract val editedMessageMediaGroupsFlow : Flow< EditMessageMediaGroupUpdate >
Content copied to clipboard
editedMessagesFlow
Link copied to clipboard
abstract val editedMessagesFlow : Flow< EditMessageUpdate >
Content copied to clipboard
flowsUpdatesFilter
Link copied to clipboard
open val flowsUpdatesFilter : FlowsUpdatesFilter
Content copied to clipboard

This parameter will be used to subscribe on different types of update

inlineQueriesFlow
Link copied to clipboard
abstract val inlineQueriesFlow : Flow< InlineQueryUpdate >
Content copied to clipboard
messageMediaGroupsFlow
Link copied to clipboard
abstract val messageMediaGroupsFlow : Flow< MessageMediaGroupUpdate >
Content copied to clipboard
messagesFlow
Link copied to clipboard
abstract val messagesFlow : Flow< MessageUpdate >
Content copied to clipboard
myChatMemberUpdatesFlow
Link copied to clipboard
abstract val myChatMemberUpdatesFlow : Flow< MyChatMemberUpdatedUpdate >
Content copied to clipboard
pollAnswersFlow
Link copied to clipboard
abstract val pollAnswersFlow : Flow< PollAnswerUpdate >
Content copied to clipboard
pollsFlow
Link copied to clipboard
abstract val pollsFlow : Flow< PollUpdate >
Content copied to clipboard
preCheckoutQueriesFlow
Link copied to clipboard
abstract val preCheckoutQueriesFlow : Flow< PreCheckoutQueryUpdate >
Content copied to clipboard
scope
Link copied to clipboard
open val scope : CoroutineScope
Content copied to clipboard

Will be used for creating of some subscriptions inside of methods, updates listening and different other things in context of working with CoroutineScope and coroutines.

shippingQueriesFlow
Link copied to clipboard
abstract val shippingQueriesFlow : Flow< ShippingQueryUpdate >
Content copied to clipboard
triggersHolder
Link copied to clipboard
abstract val triggersHolder : TriggersHolder
Content copied to clipboard
unknownUpdatesFlow
Link copied to clipboard
abstract val unknownUpdatesFlow : Flow< UnknownUpdate >
Content copied to clipboard

## Inheritors

DefaultBehaviourContextWithFSM
Link copied to clipboard

## Extensions

onStateOrSubstate
Link copied to clipboard
inline fun < I : O , O : State> BehaviourContextWithFSM < O >. onStateOrSubstate (handler: BehaviourWithFSMStateHandler < I , O >)
Content copied to clipboard

Add NON STRICT handler to list of available in future BehaviourContextWithFSM. Non strict means that for input State will be used KClass.isInstance and any inheritor of kClass will pass this requirement

strictlyOn
Link copied to clipboard
inline fun < I : O , O : State> BehaviourContextWithFSM < O >. strictlyOn (handler: BehaviourWithFSMStateHandler < I , O >)
Content copied to clipboard

Add STRICT handler to list of available in future BehaviourContextWithFSM. Strict means that for input State will be used State::class == kClass and any State with exactly the same type will pass requirements