SetWebhook#secretToken

This commit is contained in:
InsanusMokrassar 2022-06-21 17:55:21 +06:00
parent 8dfaca7648
commit 1df653f428
4 changed files with 34 additions and 18 deletions

View File

@ -5,6 +5,7 @@
* Add support of functionality for `WebApp`s from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
* Add support of functionality for premium feature from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
* Add support of `addedToAttachmentMenu` in `CommonUser` from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
* Add support of `secret_token` in `SetWebhook` request from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
## 2.0.3

View File

@ -13,10 +13,11 @@ suspend fun TelegramBot.setWebhookInfo(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = execute(
SetWebhook(
url, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
url, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
)
)
@ -29,10 +30,11 @@ suspend fun TelegramBot.setWebhookInfo(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = execute(
SetWebhook(
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
)
)
@ -45,9 +47,10 @@ suspend fun TelegramBot.setWebhookInfo(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = execute(
SetWebhook(
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
)
)

View File

@ -20,7 +20,8 @@ class MultipartSetWebhookRequest(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) : SetWebhookRequest(), MultipartRequest<Boolean> by MultipartRequestImpl(
SetWebhook(
correctWebhookUrl(url),
@ -28,7 +29,8 @@ class MultipartSetWebhookRequest(
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
dropPendingUpdates,
secretToken
),
mapOf(certificateField to certificate)
)
@ -39,14 +41,16 @@ fun SetWebhook(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
): MultipartSetWebhookRequest = MultipartSetWebhookRequest(
correctWebhookUrl(url),
certificate,
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
dropPendingUpdates,
secretToken
)
fun SetWebhook(
@ -55,14 +59,16 @@ fun SetWebhook(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
): SetWebhook = SetWebhook(
correctWebhookUrl(url),
certificate.fileId,
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
dropPendingUpdates,
secretToken
)
/**
@ -79,10 +85,11 @@ fun SetWebhook(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = when (certificate) {
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken)
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken)
}
/**
@ -98,14 +105,16 @@ fun SetWebhook(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = SetWebhook(
correctWebhookUrl(url),
null,
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
dropPendingUpdates,
secretToken
)
/**
@ -128,7 +137,9 @@ data class SetWebhook internal constructor(
@SerialName(allowedUpdatesField)
val allowedUpdates: List<String>? = null,
@SerialName(dropPendingUpdatesField)
val dropPendingUpdates: Boolean? = null
val dropPendingUpdates: Boolean? = null,
@SerialName(secretTokenField)
val secretToken: String? = null
) : SetWebhookRequest(), DataRequest<Boolean> {
override fun method(): String = "setWebhook"
override val resultDeserializer: DeserializationStrategy<Boolean>

View File

@ -158,6 +158,7 @@ const val switchPmParameterField = "switch_pm_parameter"
const val maxAllowedConnectionsField = "max_connections"
const val allowedUpdatesField = "allowed_updates"
const val dropPendingUpdatesField = "drop_pending_updates"
const val secretTokenField = "secret_token"
const val hasCustomCertificateField = "has_custom_certificate"
const val pendingUpdateCountField = "pending_update_count"
const val lastErrorDateField = "last_error_date"