Package dev.inmo.tgbotapi.extensions.utils.updates.retrieving

Functions

createAccumulatedUpdatesRetrieverFlow
Link copied to clipboard
fun TelegramBot.createAccumulatedUpdatesRetrieverFlow(avoidInlineQueries: Boolean = false, avoidCallbackQueries: Boolean = false, exceptionsHandler: ExceptionHandler<Unit>? = null, allowedUpdates: List<String>? = null): Flow<Update>
includeWebhookHandlingInRoute
Link copied to clipboard
fun Route.includeWebhookHandlingInRoute(scope: CoroutineScope, exceptionsHandler: ExceptionHandler<Unit>? = null, mediaGroupsDebounceTimeMillis: Long = 1000, block: UpdateReceiver<Update>)

Allows to include webhook in custom route everywhere in your server

includeWebhookHandlingInRouteWithFlows
Link copied to clipboard
fun Route.includeWebhookHandlingInRouteWithFlows(scope: CoroutineScope, exceptionsHandler: ExceptionHandler<Unit>? = null, mediaGroupsDebounceTimeMillis: Long = 1000, block: FlowsUpdatesFilter.() -> Unit)
longPolling
Link copied to clipboard
fun TelegramBot.longPolling(flowsUpdatesFilter: FlowsUpdatesFilter, timeoutSeconds: Seconds = 30, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: ExceptionHandler<Unit>? = null): Job

Will startGettingOfUpdatesByLongPolling using incoming flowsUpdatesFilter. It is assumed that you ALREADY CONFIGURE all updates receivers, because this method will trigger getting of updates and.

fun TelegramBot.longPolling(timeoutSeconds: Seconds = 30, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: ExceptionHandler<Unit>? = null, flowsUpdatesFilterUpdatesKeeperCount: Int = 100, flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit): Job

Will enable longPolling by creating FlowsUpdatesFilter with flowsUpdatesFilterUpdatesKeeperCount as an argument and applied flowUpdatesPreset. It is assumed that you WILL CONFIGURE all updates receivers in flowUpdatesPreset, because of after flowUpdatesPreset method calling will be triggered getting of updates.

longPollingFlow
Link copied to clipboard
fun TelegramBot.longPollingFlow(timeoutSeconds: Seconds = 30, exceptionsHandler: ExceptionHandler<Unit>? = null, allowedUpdates: List<String>? = null): Flow<Update>
retrieveAccumulatedUpdates
Link copied to clipboard
fun TelegramBot.retrieveAccumulatedUpdates(flowsUpdatesFilter: FlowsUpdatesFilter, avoidInlineQueries: Boolean = false, avoidCallbackQueries: Boolean = false, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: ExceptionHandler<Unit>? = null): Job
fun TelegramBot.retrieveAccumulatedUpdates(avoidInlineQueries: Boolean = false, avoidCallbackQueries: Boolean = false, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: ExceptionHandler<Unit>? = null, allowedUpdates: List<String>? = null, updatesReceiver: UpdateReceiver<Update>): Job
setWebhookInfoAndStartListenWebhooks
Link copied to clipboard
suspend fun RequestsExecutor.setWebhookInfoAndStartListenWebhooks(listenPort: Int, engineFactory: ApplicationEngineFactory<*, *>, setWebhookRequest: SetWebhookRequest, exceptionsHandler: ExceptionHandler<Unit> = {}, listenHost: String = "0.0.0.0", listenRoute: String = "/", privateKeyConfig: WebhookPrivateKeyConfig? = null, scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), mediaGroupsDebounceTimeMillis: Long = 1000, block: UpdateReceiver<Update>): ApplicationEngine

Setting up ktor server, set webhook info via SetWebhookRequest request.

startGettingOfUpdatesByLongPolling
Link copied to clipboard
fun RequestsExecutor.startGettingOfUpdatesByLongPolling(updatesFilter: UpdatesFilter, timeoutSeconds: Seconds = 30, exceptionsHandler: ExceptionHandler<Unit>? = null, scope: CoroutineScope = CoroutineScope(Dispatchers.Default)): Job
fun TelegramBot.startGettingOfUpdatesByLongPolling(timeoutSeconds: Seconds = 30, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: ExceptionHandler<Unit>? = null, allowedUpdates: List<String>? = null, updatesReceiver: UpdateReceiver<Update>): Job
startListenWebhooks
Link copied to clipboard
fun startListenWebhooks(listenPort: Int, engineFactory: ApplicationEngineFactory<*, *>, exceptionsHandler: ExceptionHandler<Unit>, listenHost: String = "0.0.0.0", listenRoute: String? = null, privateKeyConfig: WebhookPrivateKeyConfig? = null, scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), mediaGroupsDebounceTimeMillis: Long = 1000, block: UpdateReceiver<Update>): ApplicationEngine

Setting up ktor server

updateHandlerWithMediaGroupsAdaptation
Link copied to clipboard
fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(output: UpdateReceiver<Update>): suspend (Update) -> Unit
fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(output: UpdateReceiver<Update>, debounceTimeMillis: Long = 1000): UpdateReceiver<Update>

Create UpdateReceiver object which will correctly accumulate updates and send into output updates which INCLUDE dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdates.