DefaultBehaviourContextWithFSM

class DefaultBehaviourContextWithFSM<T : State>(    behaviourContext: BehaviourContext,     statesManager: StatesManager<T>,     handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,     onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()) : BehaviourContext, BehaviourContextWithFSM<T>

Default realization of BehaviourContextWithFSM. It uses behaviourContext as a base for this object as BehaviourContext, but managing substates contexts updates for avoiding of updates lost between states

Parameters

onStateHandlingErrorHandler

Will be used in case if state handling has not been successfully completed in launchStateHandling

Constructors

Link copied to clipboard
fun <T : State> DefaultBehaviourContextWithFSM(    behaviourContext: BehaviourContext,     statesManager: StatesManager<T>,     handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,     onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler())

Functions

Link copied to clipboard
open override fun <I : T> add(    kClass: KClass<I>,     strict: Boolean,     handler: BehaviourWithFSMStateHandler<I, T>)

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

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

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

Link copied to clipboard
expect open override fun close()
Link copied to clipboard
open override fun copy(    bot: TelegramBot,     scope: CoroutineScope,     broadcastChannelsSize: Int,     onBufferOverflow: BufferOverflow,     upstreamUpdatesFlow: Flow<Update>?,     triggersHolder: TriggersHolder): DefaultBehaviourContextWithFSM<T>
open override fun copy(    bot: TelegramBot,     scope: CoroutineScope,     broadcastChannelsSize: Int,     onBufferOverflow: BufferOverflow,     upstreamUpdatesFlow: Flow<Update>?,     triggersHolder: TriggersHolder,     onStateHandlingErrorHandler: StateHandlingErrorHandler<T>): DefaultBehaviourContextWithFSM<T>
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>
Link copied to clipboard
open suspend override fun <T : Any> execute(request: Request<T>): T

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

Link copied to clipboard
open suspend override fun StatesMachine<in T>.handleState(state: T): T?
Link copied to clipboard
open suspend override fun launchStateHandling(state: T, handlers: List<CheckableHandlerHolder<in T, T>>): T?
open suspend fun launchStateHandling(    state: T,     handlers: List<CheckableHandlerHolder<in T, T>>,     onStateHandlingErrorHandler: suspend (T, Throwable) -> T?): T?
Link copied to clipboard
inline fun <I : T> onStateOrSubstate(handler: BehaviourWithFSMStateHandler<I, T>)

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

Link copied to clipboard
open suspend fun start(): Job
open override fun start(scope: CoroutineScope): Job
Link copied to clipboard
open suspend override fun startChain(state: T)
Link copied to clipboard
inline fun <I : T> strictlyOn(handler: BehaviourWithFSMStateHandler<I, T>)

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

Properties

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

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

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

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.

Link copied to clipboard
open override val shippingQueriesFlow: Flow<ShippingQueryUpdate>
Link copied to clipboard
open override val triggersHolder: TriggersHolder
Link copied to clipboard
open override val unknownUpdatesFlow: Flow<UnknownUpdate>