Package dev.inmo.tgbotapi.extensions.behaviour_builder

Types

BehaviourContext
Link copied to clipboard
common
data class BehaviourContext(bot: TelegramBot, scope: CoroutineScope, flowsUpdatesFilter: FlowsUpdatesFilter) : FlowsUpdatesFilter, RequestsExecutor, CoroutineScope
This class contains all necessary tools for work with bots and especially for buildBehaviour
BehaviourContextAndTypeReceiver
Link copied to clipboard
common
typealias BehaviourContextAndTypeReceiver<T, I> = suspend BehaviourContext.(I) -> T
BehaviourContextReceiver
Link copied to clipboard
common
typealias BehaviourContextReceiver<T> = suspend BehaviourContext.() -> T

Functions

asAction
Link copied to clipboard
common
inline fun <T> Deferred<T>.asAction(): DeferredAction<T, T>
buildBehaviour
Link copied to clipboard
common
suspend fun TelegramBot.buildBehaviour(scope: CoroutineScope, block: BehaviourContextReceiver<Unit>): Job
Use this method to build bot behaviour and run it via long polling.
suspend fun TelegramBot.buildBehaviour(scope: CoroutineScope, flowUpdatesFilter: FlowsUpdatesFilter, block: BehaviourContextReceiver<Unit>)
Use this method in case you wish to make some additional actions with flowUpdatesFilter.
doInSubContext
Link copied to clipboard
common
suspend fun <T> BehaviourContext.doInSubContext(stopOnCompletion: Boolean = true, behaviourContextReceiver: BehaviourContextReceiver<T>): T
common
suspend fun <T> BehaviourContext.doInSubContextWithFlowsUpdatesFilterSetup(newFlowsUpdatesFilterSetUp: BehaviourContextAndTypeReceiver<Unit, FlowsUpdatesFilter>?, stopOnCompletion: Boolean = true, behaviourContextReceiver: BehaviourContextReceiver<T>): T
Creates new one BehaviourContext, adding subsequent FlowsUpdatesFilter in case newFlowsUpdatesFilterSetUp is provided and CoroutineScope as new BehaviourContext.scope.
doInSubContextWithUpdatesFilter
Link copied to clipboard
common
suspend fun <T> BehaviourContext.doInSubContextWithUpdatesFilter(updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?, stopOnCompletion: Boolean = true, behaviourContextReceiver: BehaviourContextReceiver<T>): T
Creates new one BehaviourContext, adding subsequent FlowsUpdatesFilter in case updatesFilter is provided and CoroutineScope as new BehaviourContext.scope
oneOf
Link copied to clipboard
common
suspend fun <O> BehaviourContext.oneOf(vararg deferredActions: Deferred<O>): O
suspend fun <O> BehaviourContext.oneOf(deferredActions: Iterable<Deferred<O>>): O
oneOfActions
Link copied to clipboard
common
suspend fun <O> BehaviourContext.oneOfActions(vararg deferredActions: DeferredAction<*, O>): O
suspend fun <O> BehaviourContext.oneOfActions(deferredActions: Iterable<DeferredAction<*, O>>): O
parallel
Link copied to clipboard
common
suspend fun <T> BehaviourContext.parallel(action: BehaviourContextReceiver<T>): Deferred<T>
stop
Link copied to clipboard
common
fun BehaviourContext.stop()
This method will cancel ALL subsequent contexts, expectations and waiters
withAction
Link copied to clipboard
common
infix inline fun <T, O> Deferred<T>.withAction(noinline callback: suspend (T) -> O): DeferredAction<T, O>