mirror of
				https://github.com/InsanusMokrassar/TelegramBotAPI.git
				synced 2025-11-03 21:50:13 +00:00 
			
		
		
		
	now setWebhook supports setting up of path for listening
This commit is contained in:
		@@ -34,6 +34,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### 0.20.4
 | 
					### 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:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,6 @@ 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.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -36,6 +35,7 @@ import java.util.concurrent.TimeUnit
 | 
				
			|||||||
suspend fun RequestsExecutor.setWebhook(
 | 
					suspend fun RequestsExecutor.setWebhook(
 | 
				
			||||||
    url: String,
 | 
					    url: String,
 | 
				
			||||||
    port: Int,
 | 
					    port: Int,
 | 
				
			||||||
 | 
					    listenAddress: String,
 | 
				
			||||||
    engineFactory: ApplicationEngineFactory<*, *>,
 | 
					    engineFactory: ApplicationEngineFactory<*, *>,
 | 
				
			||||||
    certificate: InputFile? = null,
 | 
					    certificate: InputFile? = null,
 | 
				
			||||||
    privateKeyConfig: WebhookPrivateKeyConfig? = null,
 | 
					    privateKeyConfig: WebhookPrivateKeyConfig? = null,
 | 
				
			||||||
@@ -70,7 +70,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 +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<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,10 +167,12 @@ 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,
 | 
				
			||||||
 | 
					    listenAddress,
 | 
				
			||||||
    engineFactory,
 | 
					    engineFactory,
 | 
				
			||||||
    certificate,
 | 
					    certificate,
 | 
				
			||||||
    privateKeyConfig,
 | 
					    privateKeyConfig,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user