BehaviourContextWithFSM

interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T>

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

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun <I : T> add(    kClass: KClass<I>,     strict: Boolean = false,     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 abstract fun close()
Link copied to clipboard
abstract override fun copy(    bot: TelegramBot,     scope: CoroutineScope,     broadcastChannelsSize: Int,     onBufferOverflow: BufferOverflow,     upstreamUpdatesFlow: Flow<Update>?,     triggersHolder: TriggersHolder): BehaviourContextWithFSM<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()): BehaviourContextWithFSM<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
abstract suspend 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
abstract suspend fun StatesMachine<in T>.handleState(state: T): T?
Link copied to clipboard
open suspend 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
open suspend fun start(): Job
abstract fun start(scope: CoroutineScope): Job
Link copied to clipboard
abstract suspend fun startChain(state: T)

Properties

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

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

Link copied to clipboard
abstract val inlineQueriesFlow: Flow<InlineQueryUpdate>
Link copied to clipboard
abstract val messageMediaGroupsFlow: Flow<MessageMediaGroupUpdate>
Link copied to clipboard
abstract val messagesFlow: Flow<MessageUpdate>
Link copied to clipboard
abstract val myChatMemberUpdatesFlow: Flow<MyChatMemberUpdatedUpdate>
Link copied to clipboard
abstract val pollAnswersFlow: Flow<PollAnswerUpdate>
Link copied to clipboard
abstract val pollsFlow: Flow<PollUpdate>
Link copied to clipboard
abstract val preCheckoutQueriesFlow: Flow<PreCheckoutQueryUpdate>
Link copied to clipboard
open 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
abstract val shippingQueriesFlow: Flow<ShippingQueryUpdate>
Link copied to clipboard
abstract val triggersHolder: TriggersHolder
Link copied to clipboard
abstract val unknownUpdatesFlow: Flow<UnknownUpdate>

Inheritors

Link copied to clipboard

Extensions

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

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
inline fun <I : O, O : State> BehaviourContextWithFSM<O>.strictlyOn(handler: BehaviourWithFSMStateHandler<I, O>)

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