mirror of
				https://github.com/InsanusMokrassar/TelegramBotAPI.git
				synced 2025-10-30 19:50:12 +00:00 
			
		
		
		
	| @@ -32,6 +32,10 @@ | |||||||
|  |  | ||||||
| * Now `LeftChatMamber` is a `CommonEvent` | * Now `LeftChatMamber` is a `CommonEvent` | ||||||
|  |  | ||||||
|  | ### 0.20.4 | ||||||
|  |  | ||||||
|  | * Now `setWebhook` supports setting up of path for listening | ||||||
|  |  | ||||||
| ## 0.19.0 ImplicitReflection removing | ## 0.19.0 ImplicitReflection removing | ||||||
|  |  | ||||||
| * Total rework of serialization for requests. Now all `SimpleRequest` children have: | * Total rework of serialization for requests. Now all `SimpleRequest` children have: | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ plugins { | |||||||
|     id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" |     id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" | ||||||
| } | } | ||||||
|  |  | ||||||
| project.version = "0.20.3" | project.version = "0.20.4" | ||||||
| project.group = "com.github.insanusmokrassar" | project.group = "com.github.insanusmokrassar" | ||||||
|  |  | ||||||
| apply from: "publish.gradle" | apply from: "publish.gradle" | ||||||
|   | |||||||
| @@ -23,12 +23,12 @@ import kotlinx.serialization.json.Json | |||||||
| import java.util.concurrent.Executors | import java.util.concurrent.Executors | ||||||
| import java.util.concurrent.TimeUnit | import java.util.concurrent.TimeUnit | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Reverse proxy webhook. |  * Reverse proxy webhook. | ||||||
|  * |  * | ||||||
|  * @param url URL of webhook WITHOUT including of [port] |  * @param url URL of webhook WITHOUT including of [port] | ||||||
|  * @param port port which will be listen by bot |  * @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] |  * @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 |  * which will be used by telegram to send encrypted messages | ||||||
|  * @param scope Scope which will be used for |  * @param scope Scope which will be used for | ||||||
| @@ -37,6 +37,7 @@ suspend fun RequestsExecutor.setWebhook( | |||||||
|     url: String, |     url: String, | ||||||
|     port: Int, |     port: Int, | ||||||
|     engineFactory: ApplicationEngineFactory<*, *>, |     engineFactory: ApplicationEngineFactory<*, *>, | ||||||
|  |     listenAddress: String = "/", | ||||||
|     certificate: InputFile? = null, |     certificate: InputFile? = null, | ||||||
|     privateKeyConfig: WebhookPrivateKeyConfig? = null, |     privateKeyConfig: WebhookPrivateKeyConfig? = null, | ||||||
|     scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), |     scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), | ||||||
| @@ -70,7 +71,7 @@ suspend fun RequestsExecutor.setWebhook( | |||||||
|  |  | ||||||
|         module { |         module { | ||||||
|             routing { |             routing { | ||||||
|                 post { |                 post(listenAddress) { | ||||||
|                     val deserialized = call.receiveText() |                     val deserialized = call.receiveText() | ||||||
|                     val update = Json.nonstrict.parse( |                     val update = Json.nonstrict.parse( | ||||||
|                         RawUpdate.serializer(), |                         RawUpdate.serializer(), | ||||||
| @@ -136,6 +137,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<String>? = null, | ||||||
|  |     maxAllowedConnections: Int? = null, | ||||||
|  |     block: UpdateReceiver<Update> | ||||||
|  | ) = setWebhook( | ||||||
|  |     url, | ||||||
|  |     port, | ||||||
|  |     engineFactory, | ||||||
|  |     "/", | ||||||
|  |     certificate, | ||||||
|  |     privateKeyConfig, | ||||||
|  |     scope, | ||||||
|  |     allowedUpdates, | ||||||
|  |     maxAllowedConnections, | ||||||
|  |     block | ||||||
|  | ) | ||||||
|  |  | ||||||
| suspend fun RequestsExecutor.setWebhook( | suspend fun RequestsExecutor.setWebhook( | ||||||
|     url: String, |     url: String, | ||||||
|     port: Int, |     port: Int, | ||||||
| @@ -144,11 +168,13 @@ suspend fun RequestsExecutor.setWebhook( | |||||||
|     certificate: InputFile? = null, |     certificate: InputFile? = null, | ||||||
|     privateKeyConfig: WebhookPrivateKeyConfig? = null, |     privateKeyConfig: WebhookPrivateKeyConfig? = null, | ||||||
|     scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), |     scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()), | ||||||
|     maxAllowedConnections: Int? = null |     maxAllowedConnections: Int? = null, | ||||||
|  |     listenAddress: String = "/" | ||||||
| ): Job = setWebhook( | ): Job = setWebhook( | ||||||
|     url, |     url, | ||||||
|     port, |     port, | ||||||
|     engineFactory, |     engineFactory, | ||||||
|  |     listenAddress, | ||||||
|     certificate, |     certificate, | ||||||
|     privateKeyConfig, |     privateKeyConfig, | ||||||
|     scope, |     scope, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user