mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
SetWebhook updates
This commit is contained in:
parent
6d6c544aaf
commit
86a472e814
@ -5,6 +5,14 @@
|
|||||||
* `Core`:
|
* `Core`:
|
||||||
* Support of `logOut` method (`LogOut` object as a `Request`)
|
* Support of `logOut` method (`LogOut` object as a `Request`)
|
||||||
* Support of `close` method (`Close` object as a `Request`)
|
* Support of `close` method (`Close` object as a `Request`)
|
||||||
|
* `SetWebhook` updates:
|
||||||
|
* Function `SetWebhook` with `inputFile` has changed this param nullability - `inputFile` now is nullable
|
||||||
|
* Function `SetWebhook` without `certificate` param now is unavailable. You can use `SetWebhook` with nullable
|
||||||
|
`inputFile`
|
||||||
|
* New field `ipAddress`. It works the same as `ip_address` in [setWebhook](https://core.telegram.org/bots/api#setwebhook)
|
||||||
|
section
|
||||||
|
* New field `dropPendingUpdates`. It works the same as `drop_pending_updates` in [setWebhook](https://core.telegram.org/bots/api#setwebhook)
|
||||||
|
section
|
||||||
|
|
||||||
## 0.29.4
|
## 0.29.4
|
||||||
|
|
||||||
|
@ -16,14 +16,18 @@ private fun correctWebhookUrl(sourceUrl: String) = if (sourceUrl.contains("://")
|
|||||||
fun SetWebhook(
|
fun SetWebhook(
|
||||||
url: String,
|
url: String,
|
||||||
certificate: MultipartFile,
|
certificate: MultipartFile,
|
||||||
|
ipAddress: String? = null,
|
||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null
|
allowedUpdates: List<String>? = null,
|
||||||
|
dropPendingUpdates: Boolean? = null
|
||||||
): MultipartRequestImpl<SetWebhook, Map<String, MultipartFile>, Boolean> = MultipartRequestImpl(
|
): MultipartRequestImpl<SetWebhook, Map<String, MultipartFile>, Boolean> = MultipartRequestImpl(
|
||||||
SetWebhook(
|
SetWebhook(
|
||||||
correctWebhookUrl(url),
|
correctWebhookUrl(url),
|
||||||
null,
|
null as String?,
|
||||||
|
ipAddress,
|
||||||
maxAllowedConnections,
|
maxAllowedConnections,
|
||||||
allowedUpdates
|
allowedUpdates,
|
||||||
|
dropPendingUpdates
|
||||||
),
|
),
|
||||||
mapOf(certificateField to certificate)
|
mapOf(certificateField to certificate)
|
||||||
)
|
)
|
||||||
@ -31,47 +35,61 @@ fun SetWebhook(
|
|||||||
fun SetWebhook(
|
fun SetWebhook(
|
||||||
url: String,
|
url: String,
|
||||||
certificate: FileId,
|
certificate: FileId,
|
||||||
|
ipAddress: String? = null,
|
||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null
|
allowedUpdates: List<String>? = null,
|
||||||
|
dropPendingUpdates: Boolean? = null
|
||||||
): SetWebhook = SetWebhook(
|
): SetWebhook = SetWebhook(
|
||||||
correctWebhookUrl(url),
|
correctWebhookUrl(url),
|
||||||
certificate.fileId,
|
certificate.fileId,
|
||||||
|
ipAddress,
|
||||||
maxAllowedConnections,
|
maxAllowedConnections,
|
||||||
allowedUpdates
|
allowedUpdates,
|
||||||
|
dropPendingUpdates
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update
|
||||||
|
* for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update.
|
||||||
|
*
|
||||||
|
* If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the [url],
|
||||||
|
* e.g. https://www.example.com/<token>. Since nobody else knows your bot's token, you can be pretty sure it's us.
|
||||||
|
*/
|
||||||
@Suppress("USELESS_CAST")
|
@Suppress("USELESS_CAST")
|
||||||
fun SetWebhook(
|
fun SetWebhook(
|
||||||
url: String,
|
url: String,
|
||||||
certificate: InputFile,
|
certificate: InputFile? = null,
|
||||||
|
ipAddress: String? = null,
|
||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null
|
allowedUpdates: List<String>? = null,
|
||||||
|
dropPendingUpdates: Boolean? = null
|
||||||
): Request<Boolean> = when (certificate) {
|
): Request<Boolean> = when (certificate) {
|
||||||
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, maxAllowedConnections, allowedUpdates)
|
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
||||||
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, maxAllowedConnections, allowedUpdates)
|
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
||||||
|
null -> SetWebhook(correctWebhookUrl(url), null as String?, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SetWebhook(
|
/**
|
||||||
url: String,
|
* Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update
|
||||||
maxAllowedConnections: Int? = null,
|
* for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update.
|
||||||
allowedUpdates: List<String>? = null
|
*
|
||||||
) = SetWebhook(
|
* If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the [url],
|
||||||
correctWebhookUrl(url),
|
* e.g. https://www.example.com/<token>. Since nobody else knows your bot's token, you can be pretty sure it's us.
|
||||||
null,
|
*/
|
||||||
maxAllowedConnections,
|
|
||||||
allowedUpdates
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetWebhook internal constructor(
|
data class SetWebhook internal constructor(
|
||||||
@SerialName(urlField)
|
@SerialName(urlField)
|
||||||
val url: String,
|
val url: String,
|
||||||
@SerialName(certificateField)
|
@SerialName(certificateField)
|
||||||
val certificateFile: String? = null,
|
val certificateFile: String? = null,
|
||||||
|
@SerialName(ipAddressField)
|
||||||
|
val ipAddress: String? = null,
|
||||||
@SerialName(maxAllowedConnectionsField)
|
@SerialName(maxAllowedConnectionsField)
|
||||||
val maxAllowedConnections: Int? = null,
|
val maxAllowedConnections: Int? = null,
|
||||||
@SerialName(allowedUpdatesField)
|
@SerialName(allowedUpdatesField)
|
||||||
val allowedUpdates: List<String>? = null
|
val allowedUpdates: List<String>? = null,
|
||||||
|
@SerialName(dropPendingUpdatesField)
|
||||||
|
val dropPendingUpdates: Boolean? = null
|
||||||
) : DataRequest<Boolean> {
|
) : DataRequest<Boolean> {
|
||||||
override fun method(): String = "setWebhook"
|
override fun method(): String = "setWebhook"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
@ -123,6 +123,7 @@ const val switchPmTextField = "switch_pm_text"
|
|||||||
const val switchPmParameterField = "switch_pm_parameter"
|
const val switchPmParameterField = "switch_pm_parameter"
|
||||||
const val maxAllowedConnectionsField = "max_connections"
|
const val maxAllowedConnectionsField = "max_connections"
|
||||||
const val allowedUpdatesField = "allowed_updates"
|
const val allowedUpdatesField = "allowed_updates"
|
||||||
|
const val dropPendingUpdatesField = "drop_pending_updates"
|
||||||
const val hasCustomCertificateField = "has_custom_certificate"
|
const val hasCustomCertificateField = "has_custom_certificate"
|
||||||
const val pendingUpdateCountField = "pending_update_count"
|
const val pendingUpdateCountField = "pending_update_count"
|
||||||
const val lastErrorDateField = "last_error_date"
|
const val lastErrorDateField = "last_error_date"
|
||||||
@ -143,6 +144,7 @@ const val inviteLinkField = "invite_link"
|
|||||||
const val pinnedMessageField = "pinned_message"
|
const val pinnedMessageField = "pinned_message"
|
||||||
const val customTitleField = "custom_title"
|
const val customTitleField = "custom_title"
|
||||||
const val optionIdsField = "option_ids"
|
const val optionIdsField = "option_ids"
|
||||||
|
const val ipAddressField = "ip_address"
|
||||||
|
|
||||||
const val requestContactField = "request_contact"
|
const val requestContactField = "request_contact"
|
||||||
const val requestLocationField = "request_location"
|
const val requestLocationField = "request_location"
|
||||||
|
Loading…
Reference in New Issue
Block a user