1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 00:03:48 +00:00

add backward compatibility change

This commit is contained in:
InsanusMokrassar 2023-06-29 14:03:13 +06:00
parent 67b7472868
commit 8247e7c69c

View File

@ -25,11 +25,11 @@ fun CallbackQuery.sourceChat() = when (this) {
}
@PreviewFeature
fun Update.sourceChat(
fun Update.sourceChatWithConverters(
baseMessageUpdateConverter: (BaseMessageUpdate) -> Chat? = { it.data.chat },
chatJoinRequestUpdateConverter: (ChatJoinRequestUpdate) -> Chat? = { it.data.chat },
shippingQueryUpdateConverter: (ShippingQueryUpdate) -> Chat? = { it.data.from },
pollAnswerUpdateConverter: (PollAnswerUpdate) -> Chat? = { it.data.from },
shippingQueryUpdateConverter: (ShippingQueryUpdate) -> Chat? = { null },
pollAnswerUpdateConverter: (PollAnswerUpdate) -> Chat? = { null },
preCheckoutQueryUpdateConverter: (PreCheckoutQueryUpdate) -> Chat? = { it.data.from },
callbackQueryUpdateConverter: (CallbackQueryUpdate) -> Chat? = { it.data.sourceChat() },
chosenInlineResultUpdateConverter: (ChosenInlineResultUpdate) -> Chat? = { null },
@ -66,6 +66,9 @@ fun Update.sourceChat(
}
}
@PreviewFeature
fun Update.sourceChat(): Chat? = sourceChatWithConverters()
@PreviewFeature
fun Update.sourceUser(): User? = when (val data = data) {
is FromUser -> data.from