From ca244169347901fc4cf055c9fb1916088d38f3e6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 23 Jan 2020 04:21:45 +0600 Subject: [PATCH] UpdatesFilter#unknownUpdateTypeCallback --- CHANGELOG.md | 2 ++ .../TelegramBotAPI/updateshandlers/UpdatesFilter.kt | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ba0d30ce3..1268a58871 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,8 @@ while they can work incorrectly * `UnknownMessageType` * `UnknownChatType` * `UnknownCallbackQueryType` +* `UpdatesFilter` now have one additional income callback: `unknownUpdateTypeCallback` + * `createSimpleUpdateFilter` can receive one more callback: `unknownCallback` (for `unknownUpdateTypeCallback`) ## 0.21.0 TelegramBotAPI 4.5 diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt index 9f3845f8f2..c1a765f9f7 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt @@ -3,6 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdateType import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver @@ -20,7 +21,8 @@ data class UpdatesFilter( private val callbackQueryCallback: UpdateReceiver? = null, private val shippingQueryCallback: UpdateReceiver? = null, private val preCheckoutQueryCallback: UpdateReceiver? = null, - private val pollUpdateCallback: UpdateReceiver? = null + private val pollUpdateCallback: UpdateReceiver? = null, + private val unknownUpdateTypeCallback: UpdateReceiver? = null ) { val asUpdateReceiver: UpdateReceiver = this::invoke val allowedUpdates = listOfNotNull( @@ -72,6 +74,7 @@ data class UpdatesFilter( is ShippingQueryUpdate -> shippingQueryCallback ?.invoke(update) is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update) is PollUpdate -> pollUpdateCallback ?.invoke(update) + is UnknownUpdateType -> unknownUpdateTypeCallback ?.invoke(update) } } } @@ -87,7 +90,8 @@ fun createSimpleUpdateFilter( callbackQueryCallback: UpdateReceiver? = null, shippingQueryCallback: UpdateReceiver? = null, preCheckoutQueryCallback: UpdateReceiver? = null, - pollCallback: UpdateReceiver? = null + pollCallback: UpdateReceiver? = null, + unknownCallback: UpdateReceiver? = null ): UpdatesFilter = UpdatesFilter( messageCallback = messageCallback, messageMediaGroupCallback = mediaGroupCallback, @@ -102,5 +106,6 @@ fun createSimpleUpdateFilter( callbackQueryCallback = callbackQueryCallback, shippingQueryCallback = shippingQueryCallback, preCheckoutQueryCallback = preCheckoutQueryCallback, - pollUpdateCallback = pollCallback + pollUpdateCallback = pollCallback, + unknownUpdateTypeCallback = unknownCallback )