Package dev.inmo.tgbotapi.extensions.behaviour_builder

Types

BehaviourContext
Link copied to clipboard
common
interface BehaviourContext : 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
DefaultBehaviourContext
Link copied to clipboard
common
class DefaultBehaviourContext(bot: TelegramBot, scope: CoroutineScope, flowsUpdatesFilter: FlowsUpdatesFilter) : FlowsUpdatesFilter, RequestsExecutor, CoroutineScope, BehaviourContext

Functions

asAction
Link copied to clipboard
common
inline fun <T> Deferred<T>.asAction(): DeferredAction<T, T>
BehaviourContext
Link copied to clipboard
common
fun BehaviourContext(bot: TelegramBot, scope: CoroutineScope, flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter()): DefaultBehaviourContext
buildBehaviour
Link copied to clipboard
common
suspend fun TelegramBot.buildBehaviour(scope: CoroutineScope, defaultExceptionsHandler: ExceptionHandler<Unit>? = null, 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, defaultExceptionsHandler: ExceptionHandler<Unit>? = null, 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
telegramBotWithBehaviour
Link copied to clipboard
common
suspend fun telegramBotWithBehaviour(token: String, scope: CoroutineScope? = null, apiUrl: String = telegramBotAPIDefaultUrl, builder: KtorRequestsExecutorBuilder.() -> Unit = {}, defaultExceptionsHandler: ExceptionHandler<Unit>? = null, block: BehaviourContextReceiver<Unit>): Pair<TelegramBot, Job>
Create bot using telegramBot and start listening for updates using buildBehaviour.
suspend fun telegramBotWithBehaviour(token: String, flowsUpdatesFilter: FlowsUpdatesFilter, scope: CoroutineScope? = null, apiUrl: String = telegramBotAPIDefaultUrl, builder: KtorRequestsExecutorBuilder.() -> Unit = {}, defaultExceptionsHandler: ExceptionHandler<Unit>? = null, block: BehaviourContextReceiver<Unit>): TelegramBot
Create bot using telegramBot and start listening for updates using buildBehaviour.
withAction
Link copied to clipboard
common
infix inline fun <T, O> Deferred<T>.withAction(noinline callback: suspend (T) -> O): DeferredAction<T, O>