mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
fixes
This commit is contained in:
parent
85317a510e
commit
7008f312dc
@ -83,9 +83,7 @@ fun startListenWebhooks(
|
|||||||
module {
|
module {
|
||||||
routing {
|
routing {
|
||||||
listenRoute ?.also {
|
listenRoute ?.also {
|
||||||
route(it) {
|
createRouteFromPath(it).includeWebhookHandlingInRoute(scope, exceptionsHandler, block)
|
||||||
includeWebhookHandlingInRoute(scope, exceptionsHandler, block)
|
|
||||||
}
|
|
||||||
} ?: includeWebhookHandlingInRoute(scope, exceptionsHandler, block)
|
} ?: includeWebhookHandlingInRoute(scope, exceptionsHandler, block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,11 +95,11 @@ fun startListenWebhooks(
|
|||||||
privateKeyConfig::aliasPassword
|
privateKeyConfig::aliasPassword
|
||||||
) {
|
) {
|
||||||
host = listenHost
|
host = listenHost
|
||||||
this.port = listenPort
|
port = listenPort
|
||||||
}
|
}
|
||||||
} ?: connector {
|
} ?: connector {
|
||||||
host = listenHost
|
host = listenHost
|
||||||
this.port = listenPort
|
port = listenPort
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -117,7 +115,7 @@ internal suspend fun RequestsExecutor.internalSetWebhookInfoAndStartListenWebhoo
|
|||||||
setWebhookRequest: Request<Boolean>,
|
setWebhookRequest: Request<Boolean>,
|
||||||
exceptionsHandler: ExceptionHandler<Unit> = {},
|
exceptionsHandler: ExceptionHandler<Unit> = {},
|
||||||
listenHost: String = "0.0.0.0",
|
listenHost: String = "0.0.0.0",
|
||||||
listenRoute: String = "/",
|
listenRoute: String? = null,
|
||||||
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
||||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||||
block: UpdateReceiver<Update>
|
block: UpdateReceiver<Update>
|
||||||
@ -186,7 +184,7 @@ suspend fun RequestsExecutor.setWebhookInfoAndStartListenWebhooks(
|
|||||||
setWebhookRequest: MultipartRequestImpl<SetWebhook, Map<String, MultipartFile>, Boolean>,
|
setWebhookRequest: MultipartRequestImpl<SetWebhook, Map<String, MultipartFile>, Boolean>,
|
||||||
exceptionsHandler: ExceptionHandler<Unit> = {},
|
exceptionsHandler: ExceptionHandler<Unit> = {},
|
||||||
listenHost: String = "0.0.0.0",
|
listenHost: String = "0.0.0.0",
|
||||||
listenRoute: String = "/",
|
listenRoute: String? = null,
|
||||||
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
||||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||||
block: UpdateReceiver<Update>
|
block: UpdateReceiver<Update>
|
||||||
|
@ -7,6 +7,12 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
private fun correctWebhookUrl(sourceUrl: String) = if (sourceUrl.contains("://")) {
|
||||||
|
sourceUrl
|
||||||
|
} else {
|
||||||
|
"https://$sourceUrl"
|
||||||
|
}
|
||||||
|
|
||||||
fun SetWebhook(
|
fun SetWebhook(
|
||||||
url: String,
|
url: String,
|
||||||
certificate: MultipartFile,
|
certificate: MultipartFile,
|
||||||
@ -14,7 +20,7 @@ fun SetWebhook(
|
|||||||
allowedUpdates: List<String>? = null
|
allowedUpdates: List<String>? = null
|
||||||
): MultipartRequestImpl<SetWebhook, Map<String, MultipartFile>, Boolean> = MultipartRequestImpl(
|
): MultipartRequestImpl<SetWebhook, Map<String, MultipartFile>, Boolean> = MultipartRequestImpl(
|
||||||
SetWebhook(
|
SetWebhook(
|
||||||
url,
|
correctWebhookUrl(url),
|
||||||
null,
|
null,
|
||||||
maxAllowedConnections,
|
maxAllowedConnections,
|
||||||
allowedUpdates
|
allowedUpdates
|
||||||
@ -28,7 +34,7 @@ fun SetWebhook(
|
|||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null
|
allowedUpdates: List<String>? = null
|
||||||
): SetWebhook = SetWebhook(
|
): SetWebhook = SetWebhook(
|
||||||
url,
|
correctWebhookUrl(url),
|
||||||
certificate.fileId,
|
certificate.fileId,
|
||||||
maxAllowedConnections,
|
maxAllowedConnections,
|
||||||
allowedUpdates
|
allowedUpdates
|
||||||
@ -40,8 +46,8 @@ fun SetWebhook(
|
|||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null
|
allowedUpdates: List<String>? = null
|
||||||
): Request<Boolean> = when (certificate) {
|
): Request<Boolean> = when (certificate) {
|
||||||
is MultipartFile -> SetWebhook(url, certificate as MultipartFile, maxAllowedConnections, allowedUpdates)
|
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, maxAllowedConnections, allowedUpdates)
|
||||||
is FileId -> SetWebhook(url, certificate as FileId, maxAllowedConnections, allowedUpdates)
|
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, maxAllowedConnections, allowedUpdates)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SetWebhook(
|
fun SetWebhook(
|
||||||
@ -49,7 +55,7 @@ fun SetWebhook(
|
|||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null
|
allowedUpdates: List<String>? = null
|
||||||
) = SetWebhook(
|
) = SetWebhook(
|
||||||
url,
|
correctWebhookUrl(url),
|
||||||
null,
|
null,
|
||||||
maxAllowedConnections,
|
maxAllowedConnections,
|
||||||
allowedUpdates
|
allowedUpdates
|
||||||
|
Loading…
Reference in New Issue
Block a user