mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-23 02:28:45 +00:00
UpdatesFilter#unknownUpdateTypeCallback
This commit is contained in:
parent
c006b47429
commit
ca24416934
@ -85,6 +85,8 @@ while they can work incorrectly
|
|||||||
* `UnknownMessageType`
|
* `UnknownMessageType`
|
||||||
* `UnknownChatType`
|
* `UnknownChatType`
|
||||||
* `UnknownCallbackQueryType`
|
* `UnknownCallbackQueryType`
|
||||||
|
* `UpdatesFilter` now have one additional income callback: `unknownUpdateTypeCallback`
|
||||||
|
* `createSimpleUpdateFilter` can receive one more callback: `unknownCallback` (for `unknownUpdateTypeCallback`)
|
||||||
|
|
||||||
## 0.21.0 TelegramBotAPI 4.5
|
## 0.21.0 TelegramBotAPI 4.5
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
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.types.update.abstracts.Update
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver
|
||||||
|
|
||||||
@ -20,7 +21,8 @@ data class UpdatesFilter(
|
|||||||
private val callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
private val callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
||||||
private val shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
private val shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||||
private val preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
private val preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||||
private val pollUpdateCallback: UpdateReceiver<PollUpdate>? = null
|
private val pollUpdateCallback: UpdateReceiver<PollUpdate>? = null,
|
||||||
|
private val unknownUpdateTypeCallback: UpdateReceiver<UnknownUpdateType>? = null
|
||||||
) {
|
) {
|
||||||
val asUpdateReceiver: UpdateReceiver<Update> = this::invoke
|
val asUpdateReceiver: UpdateReceiver<Update> = this::invoke
|
||||||
val allowedUpdates = listOfNotNull(
|
val allowedUpdates = listOfNotNull(
|
||||||
@ -72,6 +74,7 @@ data class UpdatesFilter(
|
|||||||
is ShippingQueryUpdate -> shippingQueryCallback ?.invoke(update)
|
is ShippingQueryUpdate -> shippingQueryCallback ?.invoke(update)
|
||||||
is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update)
|
is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update)
|
||||||
is PollUpdate -> pollUpdateCallback ?.invoke(update)
|
is PollUpdate -> pollUpdateCallback ?.invoke(update)
|
||||||
|
is UnknownUpdateType -> unknownUpdateTypeCallback ?.invoke(update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +90,8 @@ fun createSimpleUpdateFilter(
|
|||||||
callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
||||||
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||||
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||||
pollCallback: UpdateReceiver<PollUpdate>? = null
|
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
||||||
|
unknownCallback: UpdateReceiver<UnknownUpdateType>? = null
|
||||||
): UpdatesFilter = UpdatesFilter(
|
): UpdatesFilter = UpdatesFilter(
|
||||||
messageCallback = messageCallback,
|
messageCallback = messageCallback,
|
||||||
messageMediaGroupCallback = mediaGroupCallback,
|
messageMediaGroupCallback = mediaGroupCallback,
|
||||||
@ -102,5 +106,6 @@ fun createSimpleUpdateFilter(
|
|||||||
callbackQueryCallback = callbackQueryCallback,
|
callbackQueryCallback = callbackQueryCallback,
|
||||||
shippingQueryCallback = shippingQueryCallback,
|
shippingQueryCallback = shippingQueryCallback,
|
||||||
preCheckoutQueryCallback = preCheckoutQueryCallback,
|
preCheckoutQueryCallback = preCheckoutQueryCallback,
|
||||||
pollUpdateCallback = pollCallback
|
pollUpdateCallback = pollCallback,
|
||||||
|
unknownUpdateTypeCallback = unknownCallback
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user