mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-16 13:23:47 +00:00
fixes for webhooks
This commit is contained in:
parent
057d902883
commit
a393382a7c
@ -14,7 +14,7 @@ fun SetWebhook(
|
|||||||
) : Request<Boolean> {
|
) : Request<Boolean> {
|
||||||
val data = SetWebhook(
|
val data = SetWebhook(
|
||||||
url,
|
url,
|
||||||
certificate.fileId,
|
(certificate as? FileId) ?.fileId,
|
||||||
maxAllowedConnections,
|
maxAllowedConnections,
|
||||||
allowedUpdates
|
allowedUpdates
|
||||||
)
|
)
|
||||||
|
@ -32,14 +32,15 @@ import java.util.concurrent.TimeUnit
|
|||||||
suspend fun RequestsExecutor.setWebhook(
|
suspend fun RequestsExecutor.setWebhook(
|
||||||
url: String,
|
url: String,
|
||||||
port: Int,
|
port: Int,
|
||||||
certificate: InputFile,
|
certificate: InputFile? = null,
|
||||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||||
allowedUpdates: List<String>? = null,
|
allowedUpdates: List<String>? = null,
|
||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
engineFactory: ApplicationEngineFactory<*, *> = Netty,
|
engineFactory: ApplicationEngineFactory<*, *> = Netty,
|
||||||
block: UpdateReceiver<Any>
|
block: UpdateReceiver<Any>
|
||||||
): Job {
|
): Job {
|
||||||
val executeDeferred = executeAsync(
|
val executeDeferred = certificate ?.let {
|
||||||
|
executeAsync(
|
||||||
SetWebhook(
|
SetWebhook(
|
||||||
url,
|
url,
|
||||||
certificate,
|
certificate,
|
||||||
@ -47,6 +48,13 @@ suspend fun RequestsExecutor.setWebhook(
|
|||||||
allowedUpdates
|
allowedUpdates
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
} ?: executeAsync(
|
||||||
|
SetWebhook(
|
||||||
|
url,
|
||||||
|
maxAllowedConnections,
|
||||||
|
allowedUpdates
|
||||||
|
)
|
||||||
|
)
|
||||||
val updatesChannel = Channel<Update>(Channel.UNLIMITED)
|
val updatesChannel = Channel<Update>(Channel.UNLIMITED)
|
||||||
val mediaGroupChannel = Channel<Pair<MediaGroupIdentifier, Update>>(Channel.UNLIMITED)
|
val mediaGroupChannel = Channel<Pair<MediaGroupIdentifier, Update>>(Channel.UNLIMITED)
|
||||||
val mediaGroupAccumulatedChannel = mediaGroupChannel.accumulateByKey(
|
val mediaGroupAccumulatedChannel = mediaGroupChannel.accumulateByKey(
|
||||||
@ -57,7 +65,7 @@ suspend fun RequestsExecutor.setWebhook(
|
|||||||
module {
|
module {
|
||||||
fun Application.main() {
|
fun Application.main() {
|
||||||
routing {
|
routing {
|
||||||
post("/") {
|
post {
|
||||||
val deserialized = call.receiveText()
|
val deserialized = call.receiveText()
|
||||||
val update = Json.nonstrict.parse(
|
val update = Json.nonstrict.parse(
|
||||||
RawUpdate.serializer(),
|
RawUpdate.serializer(),
|
||||||
@ -71,7 +79,7 @@ suspend fun RequestsExecutor.setWebhook(
|
|||||||
main()
|
main()
|
||||||
}
|
}
|
||||||
connector {
|
connector {
|
||||||
host = "0.0.0.0"
|
host = "localhost"
|
||||||
this.port = port
|
this.port = port
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user