1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00

includeWebhookHandlingInRouteWithFlows

This commit is contained in:
InsanusMokrassar 2020-08-10 10:46:18 +06:00
parent 1cff6f616f
commit e3bfc4472a
3 changed files with 17 additions and 2 deletions

View File

@ -51,6 +51,9 @@
### 0.27.10
* `TelegramBotAPI-extensions-utils`:
* Extension `Route#includeWebhookHandlingInRouteWithFlows` was added
### 0.27.9
* `Common`

View File

@ -159,6 +159,8 @@ Besides, there are two additional opportunities:
* Extension `Route#includeWebhookHandlingInRoute`, which allow you to include webhook processing inside your ktor
application without creating of new one server (as it is happening in `startListenWebhooks`)
* Also, you can use `Route#includeWebhookHandlingInRouteWithFlows` to use it like `flowUpdatesFilter` fun, but apply
`FlowsUpdatesFilter` to the block
* Extension `RequestsExecutor#setWebhookInfoAndStartListenWebhooks`. It is allow to set up full server (in fact, with
`startListenWebhooks`), but also send `SetWebhook` request before and check that it was successful

View File

@ -2,14 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.retr
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.nonstrictJsonFormat
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.flowsUpdatesFilter
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.SetWebhook
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdatesFilter
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.*
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.webhook.WebhookPrivateKeyConfig
import com.github.insanusmokrassar.TelegramBotAPI.utils.ExceptionHandler
import com.github.insanusmokrassar.TelegramBotAPI.utils.handleSafely
@ -56,6 +56,16 @@ fun Route.includeWebhookHandlingInRoute(
}
}
fun Route.includeWebhookHandlingInRouteWithFlows(
scope: CoroutineScope,
exceptionsHandler: ExceptionHandler<Unit>? = null,
block: FlowsUpdatesFilter.() -> Unit
) = includeWebhookHandlingInRoute(
scope,
exceptionsHandler,
flowsUpdatesFilter(block = block).asUpdateReceiver
)
/**
* Setting up ktor server, set webhook info via [SetWebhook] request.
*