diff --git a/CHANGELOG.md b/CHANGELOG.md index 72947daca2..f5b994a848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ * `Versions`: * `Serialization`: `1.4.0-RC` -> `1.4.0` * `MicroUtils`: `0.12.1` -> `0.12.3` +* `Core`: + * `SetWebhook#allowedUpdates` now is `ALL_UPDATES_LIST` by default instead of `null` +* `API`: + * Extension `TelegramBot#setWebhook` parameter `allowedUpdates` now is `ALL_UPDATES_LIST` by default instead of `null` +* `Utils`: + * All related to long polling extensions parameters `allowedUpdates` now are `ALL_UPDATES_LIST` by default instead of `null` ## 3.1.1 diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt index a0e9dcb195..d2a986c5c2 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.requests.abstracts.MultipartFile import dev.inmo.tgbotapi.requests.webhook.SetWebhook +import dev.inmo.tgbotapi.types.ALL_UPDATES_LIST /** * Use this method to send information about webhook (like [url]) @@ -12,7 +13,7 @@ suspend fun TelegramBot.setWebhookInfo( url: String, ipAddress: String? = null, maxAllowedConnections: Int? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, dropPendingUpdates: Boolean? = null, secretToken: String? = null ) = execute( @@ -29,7 +30,7 @@ suspend fun TelegramBot.setWebhookInfo( certificate: FileId, ipAddress: String? = null, maxAllowedConnections: Int? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, dropPendingUpdates: Boolean? = null, secretToken: String? = null ) = execute( @@ -46,7 +47,7 @@ suspend fun TelegramBot.setWebhookInfo( certificate: MultipartFile, ipAddress: String? = null, maxAllowedConnections: Int? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, dropPendingUpdates: Boolean? = null, secretToken: String? = null ) = execute( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt index 39482247c5..774e7ae80f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt @@ -19,7 +19,7 @@ class MultipartSetWebhookRequest( certificate: MultipartFile, ipAddress: String? = null, maxAllowedConnections: Int? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, dropPendingUpdates: Boolean? = null, secretToken: String? = null ) : SetWebhookRequest(), MultipartRequest by MultipartRequestImpl( @@ -40,7 +40,7 @@ fun SetWebhook( certificate: MultipartFile, ipAddress: String? = null, maxAllowedConnections: Int? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, dropPendingUpdates: Boolean? = null, secretToken: String? = null ): MultipartSetWebhookRequest = MultipartSetWebhookRequest( @@ -58,7 +58,7 @@ fun SetWebhook( certificate: FileId, ipAddress: String? = null, maxAllowedConnections: Int? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, dropPendingUpdates: Boolean? = null, secretToken: String? = null ): SetWebhook = SetWebhook( @@ -84,7 +84,7 @@ fun SetWebhook( certificate: InputFile, ipAddress: String? = null, maxAllowedConnections: Int? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, dropPendingUpdates: Boolean? = null, secretToken: String? = null ) = when (certificate) { @@ -104,7 +104,7 @@ fun SetWebhook( url: String, ipAddress: String? = null, maxAllowedConnections: Int? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, dropPendingUpdates: Boolean? = null, secretToken: String? = null ) = SetWebhook( @@ -135,7 +135,7 @@ data class SetWebhook internal constructor( @SerialName(maxAllowedConnectionsField) val maxAllowedConnections: Int? = null, @SerialName(allowedUpdatesField) - val allowedUpdates: List? = null, + val allowedUpdates: List? = ALL_UPDATES_LIST, @SerialName(dropPendingUpdatesField) val dropPendingUpdates: Boolean? = null, @SerialName(secretTokenField) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt index 421427e2ac..830f37f0c3 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt @@ -21,7 +21,7 @@ import kotlinx.coroutines.flow.* fun TelegramBot.longPollingFlow( timeoutSeconds: Seconds = 30, exceptionsHandler: (ExceptionHandler)? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, ): Flow = channelFlow { var lastUpdateIdentifier: UpdateIdentifier? = null @@ -81,7 +81,7 @@ fun TelegramBot.startGettingOfUpdatesByLongPolling( timeoutSeconds: Seconds = 30, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: (ExceptionHandler)? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, updatesReceiver: UpdateReceiver ): Job = longPollingFlow(timeoutSeconds, exceptionsHandler, allowedUpdates).subscribeSafely( scope, @@ -97,7 +97,7 @@ fun TelegramBot.createAccumulatedUpdatesRetrieverFlow( avoidInlineQueries: Boolean = false, avoidCallbackQueries: Boolean = false, exceptionsHandler: ExceptionHandler? = null, - allowedUpdates: List? = null + allowedUpdates: List? = ALL_UPDATES_LIST ): Flow = longPollingFlow( timeoutSeconds = 0, exceptionsHandler = { @@ -117,7 +117,7 @@ fun TelegramBot.retrieveAccumulatedUpdates( avoidCallbackQueries: Boolean = false, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: (ExceptionHandler)? = null, - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, updatesReceiver: UpdateReceiver ): Job = createAccumulatedUpdatesRetrieverFlow( avoidInlineQueries, @@ -149,7 +149,7 @@ suspend fun TelegramBot.flushAccumulatedUpdates( avoidInlineQueries: Boolean = false, avoidCallbackQueries: Boolean = false, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), - allowedUpdates: List? = null, + allowedUpdates: List? = ALL_UPDATES_LIST, exceptionsHandler: ExceptionHandler? = null, updatesReceiver: UpdateReceiver = {} ) = retrieveAccumulatedUpdates(