diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/SetWebhook.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/SetWebhook.kt index e7e8500499..7649006554 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/SetWebhook.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/SetWebhook.kt @@ -14,7 +14,7 @@ fun SetWebhook( ) : Request { val data = SetWebhook( url, - certificate.fileId, + (certificate as? FileId) ?.fileId, maxAllowedConnections, allowedUpdates ) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt index 7e54d4f084..2b4338dedf 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt @@ -32,17 +32,25 @@ import java.util.concurrent.TimeUnit suspend fun RequestsExecutor.setWebhook( url: String, port: Int, - certificate: InputFile, + certificate: InputFile? = null, scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), allowedUpdates: List? = null, maxAllowedConnections: Int? = null, engineFactory: ApplicationEngineFactory<*, *> = Netty, block: UpdateReceiver ): Job { - val executeDeferred = executeAsync( + val executeDeferred = certificate ?.let { + executeAsync( + SetWebhook( + url, + certificate, + maxAllowedConnections, + allowedUpdates + ) + ) + } ?: executeAsync( SetWebhook( url, - certificate, maxAllowedConnections, allowedUpdates ) @@ -57,7 +65,7 @@ suspend fun RequestsExecutor.setWebhook( module { fun Application.main() { routing { - post("/") { + post { val deserialized = call.receiveText() val update = Json.nonstrict.parse( RawUpdate.serializer(), @@ -71,7 +79,7 @@ suspend fun RequestsExecutor.setWebhook( main() } connector { - host = "0.0.0.0" + host = "localhost" this.port = port } }