Package dev. inmo. tgbotapi. extensions. behaviour_builder
Types
This class contains all necessary tools for work with bots and especially buildBehaviour
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
Special holder for BehaviourContextWithFSM. This holder helps BehaviourContextWithFSM to understand whether it can handle input State with delegateTo or not
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
Functions
Use this method in case you wish to make some additional actions with flowUpdatesFilter.
Creates BehaviourContextWithFSM via creating of DefaultBehaviourContext with this as TelegramBot, scope as target scope for that DefaultBehaviourContext and FlowsUpdatesFilter.allUpdatesFlow of flowUpdatesFilter as DefaultBehaviourContext.upstreamUpdatesFlow. Pass statesManager to customize some internal logic of states changes. Pass presetHandlers in case you have some list of BehaviourWithFSMStateHandlerHolder with presets. Use this method in case you wish to make some additional actions with flowUpdatesFilter.
Creates BehaviourContextWithFSM via creating of DefaultBehaviourContext with this as TelegramBot, scope as target scope for that DefaultBehaviourContext and upstreamUpdatesFlow. Pass statesManager to customize some internal logic of states changes. Pass presetHandlers in case you have some list of BehaviourWithFSMStateHandlerHolder with presets.
Use buildBehaviourWithFSM to create BehaviourContextWithFSM and launch getting of updates using longPolling. For longPolling will be used result BehaviourContextWithFSM for both parameters flowsUpdatesFilter and scope
Use this method to build bot behaviour and run it via long polling. In case you wish to get FlowsUpdatesFilter for additional manipulations, you must provide external FlowsUpdatesFilter in other buildBehaviour function.
Creates new one BehaviourContext using createSubContext and launches behaviourContextReceiver in a new context using doInContext
Launch behaviourContextReceiver in context of this as BehaviourContext and as kotlin.coroutines.CoroutineContext
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
This method will cancel ALL subsequent contexts, expectations and waiters
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
Create bot using telegramBot and start listening for updates using buildBehaviour. Use this method in case you wish to make some additional actions with flowsUpdatesFilter.
Create bot using telegramBot and start listening for updates using buildBehaviourWithFSM. Use this method in case you wish to make some additional actions with flowsUpdatesFilter.
Create bot using telegramBot and start listening for updates using buildBehaviourWithFSMAndStartLongPolling. This method will launch updates retrieving via long polling inside of buildBehaviourWithFSMAndStartLongPolling
Create bot using telegramBot and start listening for updates using buildBehaviourWithLongPolling. Use this method in case you wish to make some additional actions with flowsUpdatesFilter.
Properties
This function is used in buildBehaviour extensions to provide default CoroutineScope and allow to avoid all unnecessary parameters except of block