From 27aba72a5a24db2eb613f58d5ccbc7959cad59b8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 1 Jan 2020 14:06:03 +0600 Subject: [PATCH 1/3] started 0.20.4 --- CHANGELOG.md | 2 ++ build.gradle | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c76d1b5cd..3f3fe93210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ * Now `LeftChatMamber` is a `CommonEvent` +### 0.20.4 + ## 0.19.0 ImplicitReflection removing * Total rework of serialization for requests. Now all `SimpleRequest` children have: diff --git a/build.gradle b/build.gradle index 64462c4baa..d15f48af65 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" } -project.version = "0.20.3" +project.version = "0.20.4" project.group = "com.github.insanusmokrassar" apply from: "publish.gradle" From ef7e94ba681a26c3cf62651726b588dfcf3b1606 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 1 Jan 2020 14:07:17 +0600 Subject: [PATCH 2/3] now setWebhook supports setting up of path for listening --- CHANGELOG.md | 2 ++ .../utils/extensions/Webhooks.kt | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) 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, From 0066e814b3c34fa3e32f2f9d594b92ccdd867640 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 1 Jan 2020 14:12:37 +0600 Subject: [PATCH 3/3] a little reorder of arguments in setWebhook --- .../TelegramBotAPI/utils/extensions/Webhooks.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 03b54947ad..6d985c0558 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 @@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit * * @param url URL of webhook WITHOUT including of [port] * @param port port which will be listen by bot + * @param listenAddress address to listen by bot * @param certificate [com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile] or [com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId] * which will be used by telegram to send encrypted messages * @param scope Scope which will be used for @@ -35,8 +36,8 @@ import java.util.concurrent.TimeUnit suspend fun RequestsExecutor.setWebhook( url: String, port: Int, - listenAddress: String, engineFactory: ApplicationEngineFactory<*, *>, + listenAddress: String = "/", certificate: InputFile? = null, privateKeyConfig: WebhookPrivateKeyConfig? = null, scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), @@ -149,8 +150,8 @@ suspend fun RequestsExecutor.setWebhook( ) = setWebhook( url, port, - "/", engineFactory, + "/", certificate, privateKeyConfig, scope, @@ -168,12 +169,12 @@ suspend fun RequestsExecutor.setWebhook( privateKeyConfig: WebhookPrivateKeyConfig? = null, scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), maxAllowedConnections: Int? = null, - listenAddress: String = "" + listenAddress: String = "/" ): Job = setWebhook( url, port, - listenAddress, engineFactory, + listenAddress, certificate, privateKeyConfig, scope,