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

Functions

includeWebhookHandlingInRoute
Link copied to clipboard

Allows to include webhook in custom route everywhere in your server

fun Route.includeWebhookHandlingInRoute(scope: CoroutineScope, exceptionsHandler: SuspendFunction1<Throwable, Unit>?, block: SuspendFunction1<Update, Unit>)
includeWebhookHandlingInRouteWithFlows
Link copied to clipboard
fun Route.includeWebhookHandlingInRouteWithFlows(scope: CoroutineScope, exceptionsHandler: SuspendFunction1<Throwable, Unit>?, block: FlowsUpdatesFilter.() -> Unit)
setWebhookInfoAndStartListenWebhooks
Link copied to clipboard

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

suspend fun RequestsExecutor.setWebhookInfoAndStartListenWebhooks(listenPort: Int, engineFactory: ApplicationEngineFactory<*, *>, setWebhookRequest: SetWebhookRequest, exceptionsHandler: SuspendFunction1<Throwable, Unit>, listenHost: String, listenRoute: String, privateKeyConfig: WebhookPrivateKeyConfig?, scope: CoroutineScope, block: SuspendFunction1<Update, Unit>): ApplicationEngine
startGettingFlowsUpdatesByLongPolling
Link copied to clipboard

This method will create a new one FlowsUpdatesFilter. This method could be unsafe due to the fact that it will start getting updates IMMEDIATELY. That means that your bot will be able to skip some of them until you will call kotlinx.coroutines.flow.Flow.collect on one of FlowsUpdatesFilter flows. To avoid it, you can pass flowUpdatesPreset lambda - it will be called BEFORE starting updates getting

common
@FlowPreview()
fun RequestsExecutor.startGettingFlowsUpdatesByLongPolling(timeoutSeconds: Int, scope: CoroutineScope, exceptionsHandler: SuspendFunction1<Throwable, Unit>?, flowsUpdatesFilterUpdatesKeeperCount: Int, flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit): FlowsUpdatesFilter
startGettingOfUpdatesByLongPolling
Link copied to clipboard
common
fun RequestsExecutor.startGettingOfUpdatesByLongPolling(updatesFilter: UpdatesFilter, timeoutSeconds: Int, exceptionsHandler: SuspendFunction1<Throwable, Unit>?, scope: CoroutineScope): Job
fun RequestsExecutor.startGettingOfUpdatesByLongPolling(timeoutSeconds: Int, scope: CoroutineScope, exceptionsHandler: SuspendFunction1<Throwable, Unit>?, allowedUpdates: List<String>?, updatesReceiver: SuspendFunction1<Update, Unit>): Job
fun RequestsExecutor.startGettingOfUpdatesByLongPolling(messageCallback: SuspendFunction1<MessageUpdate, Unit>?, mediaGroupCallback: SuspendFunction1<MediaGroupUpdate, Unit>?, editedMessageCallback: SuspendFunction1<EditMessageUpdate, Unit>?, channelPostCallback: SuspendFunction1<ChannelPostUpdate, Unit>?, editedChannelPostCallback: SuspendFunction1<EditChannelPostUpdate, Unit>?, chosenInlineResultCallback: SuspendFunction1<ChosenInlineResultUpdate, Unit>?, inlineQueryCallback: SuspendFunction1<InlineQueryUpdate, Unit>?, callbackQueryCallback: SuspendFunction1<CallbackQueryUpdate, Unit>?, shippingQueryCallback: SuspendFunction1<ShippingQueryUpdate, Unit>?, preCheckoutQueryCallback: SuspendFunction1<PreCheckoutQueryUpdate, Unit>?, pollCallback: SuspendFunction1<PollUpdate, Unit>?, pollAnswerCallback: SuspendFunction1<PollAnswerUpdate, Unit>?, timeoutSeconds: Int, exceptionsHandler: SuspendFunction1<Throwable, Unit>?, scope: CoroutineScope): Job
fun RequestsExecutor.startGettingOfUpdatesByLongPolling(messageCallback: SuspendFunction1<MessageUpdate, Unit>?, messageMediaGroupCallback: SuspendFunction1<MessageMediaGroupUpdate, Unit>?, editedMessageCallback: SuspendFunction1<EditMessageUpdate, Unit>?, editedMessageMediaGroupCallback: SuspendFunction1<EditMessageMediaGroupUpdate, Unit>?, channelPostCallback: SuspendFunction1<ChannelPostUpdate, Unit>?, channelPostMediaGroupCallback: SuspendFunction1<ChannelPostMediaGroupUpdate, Unit>?, editedChannelPostCallback: SuspendFunction1<EditChannelPostUpdate, Unit>?, editedChannelPostMediaGroupCallback: SuspendFunction1<EditChannelPostMediaGroupUpdate, Unit>?, chosenInlineResultCallback: SuspendFunction1<ChosenInlineResultUpdate, Unit>?, inlineQueryCallback: SuspendFunction1<InlineQueryUpdate, Unit>?, callbackQueryCallback: SuspendFunction1<CallbackQueryUpdate, Unit>?, shippingQueryCallback: SuspendFunction1<ShippingQueryUpdate, Unit>?, preCheckoutQueryCallback: SuspendFunction1<PreCheckoutQueryUpdate, Unit>?, pollCallback: SuspendFunction1<PollUpdate, Unit>?, pollAnswerCallback: SuspendFunction1<PollAnswerUpdate, Unit>?, timeoutSeconds: Int, exceptionsHandler: SuspendFunction1<Throwable, Unit>?, scope: CoroutineScope): Job
startListenWebhooks
Link copied to clipboard

Setting up ktor server

fun startListenWebhooks(listenPort: Int, engineFactory: ApplicationEngineFactory<*, *>, exceptionsHandler: SuspendFunction1<Throwable, Unit>, listenHost: String, listenRoute: String?, privateKeyConfig: WebhookPrivateKeyConfig?, scope: CoroutineScope, block: SuspendFunction1<Update, Unit>): ApplicationEngine
updateHandlerWithMediaGroupsAdaptation
Link copied to clipboard

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

common
fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(output: SuspendFunction1<Update, Unit>): SuspendFunction1<Update, Unit>
fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(output: SuspendFunction1<Update, Unit>, debounceTimeMillis: Long): SuspendFunction1<Update, Unit>