diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt index 4c7911fe71..b3de4b565f 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt @@ -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