diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f3fe93210..2ec8782ae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ ### 0.20.4 +* Now `setWebhook` supports setting up of path for listening + ## 0.19.0 ImplicitReflection removing * Total rework of serialization for requests. Now all `SimpleRequest` children have: diff --git a/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt b/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt index e10e4c9347..03b54947ad 100644 --- a/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt +++ b/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt @@ -23,7 +23,6 @@ import kotlinx.serialization.json.Json import java.util.concurrent.Executors import java.util.concurrent.TimeUnit - /** * Reverse proxy webhook. * @@ -36,6 +35,7 @@ import java.util.concurrent.TimeUnit suspend fun RequestsExecutor.setWebhook( url: String, port: Int, + listenAddress: String, engineFactory: ApplicationEngineFactory<*, *>, certificate: InputFile? = null, privateKeyConfig: WebhookPrivateKeyConfig? = null, @@ -70,7 +70,7 @@ suspend fun RequestsExecutor.setWebhook( module { routing { - post { + post(listenAddress) { val deserialized = call.receiveText() val update = Json.nonstrict.parse( RawUpdate.serializer(), @@ -136,6 +136,29 @@ suspend fun RequestsExecutor.setWebhook( } } +suspend fun RequestsExecutor.setWebhook( + url: String, + port: Int, + engineFactory: ApplicationEngineFactory<*, *>, + certificate: InputFile? = null, + privateKeyConfig: WebhookPrivateKeyConfig? = null, + scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), + allowedUpdates: List? = null, + maxAllowedConnections: Int? = null, + block: UpdateReceiver +) = setWebhook( + url, + port, + "/", + engineFactory, + certificate, + privateKeyConfig, + scope, + allowedUpdates, + maxAllowedConnections, + block +) + suspend fun RequestsExecutor.setWebhook( url: String, port: Int, @@ -144,10 +167,12 @@ suspend fun RequestsExecutor.setWebhook( certificate: InputFile? = null, privateKeyConfig: WebhookPrivateKeyConfig? = null, scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), - maxAllowedConnections: Int? = null + maxAllowedConnections: Int? = null, + listenAddress: String = "" ): Job = setWebhook( url, port, + listenAddress, engineFactory, certificate, privateKeyConfig,