From a3949c752d98d942059b11e11b01625b7d2ac3f9 Mon Sep 17 00:00:00 2001 From: "bpavuk (aider)" <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 13:53:23 +0300 Subject: [PATCH 01/27] feat: Add UniqueGiftSymbol data type --- .gitignore | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 2 ++ .../inmo/tgbotapi/types/UniqueGiftSymbol.kt | 22 +++++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftSymbol.kt diff --git a/.gitignore b/.gitignore index d344e95940..72f7a6bb59 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ out/ local.properties kotlin-js-store/ secret.gradle +.aider* diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 32949f9ccb..e6045a9835 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index a91b4510fe..ca073999f0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.utils.BuiltinMimeTypes import kotlinx.serialization.Serializable import kotlin.jvm.JvmInline + typealias ForwardSignature = String typealias ForwardSenderName = String typealias AuthorSignature = ForwardSignature @@ -494,6 +495,7 @@ const val subscriptionPriceField = "subscription_price" const val copyTextField = "copy_text" const val giftField = "gift" const val giftsField = "gifts" +const val rarityPerMilleField = "rarity_per_mille" const val pointField = "point" const val xShiftField = "x_shift" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftSymbol.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftSymbol.kt new file mode 100644 index 0000000000..9f267ee1fb --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftSymbol.kt @@ -0,0 +1,22 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.types.files.Sticker +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * This object describes the symbol shown on the pattern of a unique gift. + * + * @param name Name of the symbol + * @param sticker The sticker that represents the unique gift + * @param rarityPerMille The number of unique gifts that receive this model for every 1000 gifts upgraded + */ +@Serializable +data class UniqueGiftSymbol( + @SerialName(nameField) + val name: String, + @SerialName(stickerField) + val sticker: Sticker, + @SerialName(rarityPerMilleField) + val rarityPerMille: Int +) From 99559f477e17fb4338fd130af66f61a29fed1435 Mon Sep 17 00:00:00 2001 From: "bpavuk (aider)" <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 14:25:02 +0300 Subject: [PATCH 02/27] feat: Add UniqueGiftModel type --- .../inmo/tgbotapi/types/UniqueGiftModel.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftModel.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftModel.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftModel.kt new file mode 100644 index 0000000000..ed0d9f26e0 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftModel.kt @@ -0,0 +1,22 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.types.files.Sticker +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * This object describes the model of a unique gift. + * + * @param name Name of the model + * @param sticker The sticker that represents the unique gift + * @param rarityPerMille The number of unique gifts that receive this model for every 1000 gifts upgraded + */ +@Serializable +data class UniqueGiftModel( + @SerialName(nameField) + val name: String, + @SerialName(stickerField) + val sticker: Sticker, + @SerialName(rarityPerMilleField) + val rarityPerMille: Int +) From cd3ba8f480c983286afe7e12356cf678bfc240fd Mon Sep 17 00:00:00 2001 From: "bpavuk (aider)" <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 14:26:55 +0300 Subject: [PATCH 03/27] feat: Add UniqueGiftBackdropColors data class --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 5 ++++ .../types/UniqueGiftBackdropColors.kt | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdropColors.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index ca073999f0..9b85df9481 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -666,6 +666,11 @@ const val upgradeStarCountField = "upgrade_star_count" const val payToUpgradeField = "pay_for_upgrade" const val paidMediaField = "paid_media" +const val centerColorField = "center_color" +const val edgeColorField = "edge_color" +const val symbolColorField = "symbol_color" +const val textColorField = "text_color" + const val businessConnectionIdField = "business_connection_id" const val businessIntroField = "business_intro" const val businessLocationField = "business_location" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdropColors.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdropColors.kt new file mode 100644 index 0000000000..49a30d98ad --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdropColors.kt @@ -0,0 +1,24 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * This object describes the colors of the backdrop of a unique gift. + * + * @param centerColor The color in the center of the backdrop in RGB format + * @param edgeColor The color on the edges of the backdrop in RGB format + * @param symbolColor The color to be applied to the symbol in RGB format + * @param textColor The color for the text on the backdrop in RGB format + */ +@Serializable +data class UniqueGiftBackdropColors( + @SerialName(centerColorField) + val centerColor: Int, + @SerialName(edgeColorField) + val edgeColor: Int, + @SerialName(symbolColorField) + val symbolColor: Int, + @SerialName(textColorField) + val textColor: Int +) From 4c9d888668f7057874fa8c9715a9e627afc0966d Mon Sep 17 00:00:00 2001 From: "bpavuk (aider)" <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 14:32:30 +0300 Subject: [PATCH 04/27] feat: Add UniqueGiftBackdrop type --- .../inmo/tgbotapi/types/UniqueGiftBackdrop.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdrop.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdrop.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdrop.kt new file mode 100644 index 0000000000..35259a1f45 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdrop.kt @@ -0,0 +1,21 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * This object describes the backdrop of a unique gift. + * + * @param name Name of the backdrop + * @param colors Colors of the backdrop + * @param rarityPerMille The number of unique gifts that receive this backdrop for every 1000 gifts upgraded + */ +@Serializable +data class UniqueGiftBackdrop( + @SerialName(nameField) + val name: String, + @SerialName(colorsField) + val colors: UniqueGiftBackdropColors, + @SerialName(rarityPerMilleField) + val rarityPerMille: Int +) From 2ac83156f6031fe54243feed5cb589d976d59800 Mon Sep 17 00:00:00 2001 From: "bpavuk (aider)" <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 14:35:37 +0300 Subject: [PATCH 05/27] feat: Add UniqueGift type with related fields and constants --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 6 ++++ .../dev/inmo/tgbotapi/types/UniqueGift.kt | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGift.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 9b85df9481..18fb2a67a7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -671,6 +671,12 @@ const val edgeColorField = "edge_color" const val symbolColorField = "symbol_color" const val textColorField = "text_color" +const val baseNameField = "base_name" +const val numberField = "number" +const val modelField = "model" +const val symbolField = "symbol" +const val backdropField = "backdrop" + const val businessConnectionIdField = "business_connection_id" const val businessIntroField = "business_intro" const val businessLocationField = "business_location" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGift.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGift.kt new file mode 100644 index 0000000000..1a65ff2813 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGift.kt @@ -0,0 +1,30 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * This object describes a unique gift that was upgraded from a regular gift. + * + * @param baseName Human-readable name of the regular gift from which this unique gift was upgraded + * @param name Unique name of the gift. This name can be used in `https://t.me/nft/...` links and story areas + * @param number Unique number of the upgraded gift among gifts upgraded from the same regular gift + * @param model Model of the gift + * @param symbol Symbol of the gift + * @param backdrop Backdrop of the gift + */ +@Serializable +data class UniqueGift( + @SerialName(baseNameField) + val baseName: String, + @SerialName(nameField) + val name: String, + @SerialName(numberField) + val number: Int, + @SerialName(modelField) + val model: UniqueGiftModel, + @SerialName(symbolField) + val symbol: UniqueGiftSymbol, + @SerialName(backdropField) + val backdrop: UniqueGiftBackdrop +) From ef60549e1c10d230b5657b229c6099e4912b3797 Mon Sep 17 00:00:00 2001 From: "bpavuk (aider)" <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 14:38:25 +0300 Subject: [PATCH 06/27] feat: Add AcceptedGiftTypes data class and related constants --- .../inmo/tgbotapi/types/AcceptedGiftTypes.kt | 24 +++++++++++++++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 5 ++++ 2 files changed, 29 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt new file mode 100644 index 0000000000..d2c94d67fe --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt @@ -0,0 +1,24 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * This object describes the types of gifts that can be gifted to a user or a chat. + * + * @param unlimitedGifts True, if unlimited regular gifts are accepted + * @param limitedGifts True, if limited regular gifts are accepted + * @param uniqueGifts True, if unique gifts or gifts that can be upgraded to unique for free are accepted + * @param premiumSubscription True, if a Telegram Premium subscription is accepted + */ +@Serializable +data class AcceptedGiftTypes( + @SerialName(unlimitedGiftsField) + val unlimitedGifts: Boolean, + @SerialName(limitedGiftsField) + val limitedGifts: Boolean, + @SerialName(uniqueGiftsField) + val uniqueGifts: Boolean, + @SerialName(premiumSubscriptionField) + val premiumSubscription: Boolean +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 18fb2a67a7..5f17610e37 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -677,6 +677,11 @@ const val modelField = "model" const val symbolField = "symbol" const val backdropField = "backdrop" +const val unlimitedGiftsField = "unlimited_gifts" +const val limitedGiftsField = "limited_gifts" +const val uniqueGiftsField = "unique_gifts" +const val premiumSubscriptionField = "premium_subscription" + const val businessConnectionIdField = "business_connection_id" const val businessIntroField = "business_intro" const val businessLocationField = "business_location" From 93d0e009bbf3c4090191d52f1366263e0429aa5c Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 15:49:05 +0300 Subject: [PATCH 07/27] feat: replaced `canReceiveGifts` with `acceptedGiftTypes` and `AcceptedGiftTypes` class --- .../dev/inmo/tgbotapi/types/chat/Extended.kt | 33 +++++++++++-------- .../tgbotapi/types/chat/ExtendedAbstracts.kt | 5 +-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index fe3e1e760e..723f6acb44 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -58,8 +58,8 @@ data class ExtendedChannelChatImpl( override val newMembersSeeHistory: Boolean = false, @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, - @SerialName(canSendGiftsField) - override val canReceiveGifts: Boolean = false, + @SerialName(acceptedGiftTypesField) + override val acceptedGiftTypes: AcceptedGiftTypes, ) : ExtendedChannelChat @Serializable @@ -100,8 +100,8 @@ data class ExtendedGroupChatImpl( override val newMembersSeeHistory: Boolean = false, @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, - @SerialName(canSendGiftsField) - override val canReceiveGifts: Boolean = false, + @SerialName(acceptedGiftTypesField) + override val acceptedGiftTypes: AcceptedGiftTypes, ) : ExtendedGroupChat @Serializable @@ -150,8 +150,8 @@ data class ExtendedPrivateChatImpl( override val personalChat: PreviewChannelChat? = null, @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, - @SerialName(canSendGiftsField) - override val canReceiveGifts: Boolean = false, + @SerialName(acceptedGiftTypesField) + override val acceptedGiftTypes: AcceptedGiftTypes, ) : ExtendedPrivateChat typealias ExtendedUser = ExtendedPrivateChatImpl @@ -218,8 +218,8 @@ data class ExtendedSupergroupChatImpl( override val customEmojiStickerSetName: StickerSetName? = null, @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, - @SerialName(canSendGiftsField) - override val canReceiveGifts: Boolean = false, + @SerialName(acceptedGiftTypesField) + override val acceptedGiftTypes: AcceptedGiftTypes, ) : ExtendedSupergroupChat @Serializable @@ -284,8 +284,8 @@ data class ExtendedForumChatImpl( override val customEmojiStickerSetName: StickerSetName? = null, @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, - @SerialName(canSendGiftsField) - override val canReceiveGifts: Boolean = false, + @SerialName(acceptedGiftTypesField) + override val acceptedGiftTypes: AcceptedGiftTypes, ) : ExtendedForumChat @Serializable @@ -320,8 +320,8 @@ data class ExtendedBot( override val maxReactionsCount: Int = 3, @SerialName(hasMainWebAppField) val hasMainWebApp: Boolean = false, - @SerialName(canSendGiftsField) - override val canReceiveGifts: Boolean = false, + @SerialName(acceptedGiftTypesField) + override val acceptedGiftTypes: AcceptedGiftTypes, ) : Bot(), ExtendedChat { @SerialName(isBotField) private val isBot = true @@ -351,6 +351,11 @@ data class UnknownExtendedChat( override val profileBackgroundCustomEmojiId: CustomEmojiId? = null @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3 - @SerialName(canSendGiftsField) - override val canReceiveGifts: Boolean = false + @SerialName(acceptedGiftTypesField) + override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes( + unlimitedGifts = false, + limitedGifts = false, + uniqueGifts = false, + premiumSubscription = false + ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index a66675f745..4b8374914c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -20,10 +20,7 @@ sealed interface ExtendedChat : Chat { val profileBackgroundCustomEmojiId: CustomEmojiId? val maxReactionsCount: Int - /** - * Represent `can_send_gifts` field - */ - val canReceiveGifts: Boolean + val acceptedGiftTypes: AcceptedGiftTypes } @Serializable(ExtendedChatSerializer.Companion::class) From 9f3024476cc5f44b0df37714908207e8c5173e5d Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 15:49:19 +0300 Subject: [PATCH 08/27] feat: implemented GiftInfo class --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 7 +++++ .../dev/inmo/tgbotapi/types/gifts/GiftInfo.kt | 26 +++++++++++++++++++ .../inmo/tgbotapi/types/message/RawMessage.kt | 4 +++ 3 files changed, 37 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 5f17610e37..71c89d90e6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -493,9 +493,16 @@ const val creatorField = "creator" const val subscriptionPeriodField = "subscription_period" const val subscriptionPriceField = "subscription_price" const val copyTextField = "copy_text" + const val giftField = "gift" const val giftsField = "gifts" const val rarityPerMilleField = "rarity_per_mille" +const val acceptedGiftTypesField = "accepted_gift_types" +const val ownedGiftIdField = "owned_gift_id" +const val convertStarCountField = "convert_star_count" +const val prepaidUpgradeStarCountField = "prepaid_upgrade_star_count" +const val canBeUpgradedField = "can_be_upgraded" +const val isPrivateField = "is_private" const val pointField = "point" const val xShiftField = "x_shift" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt new file mode 100644 index 0000000000..d85df96526 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt @@ -0,0 +1,26 @@ +package dev.inmo.tgbotapi.types.gifts + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.message.RawMessageEntities +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class GiftInfo private constructor( + @SerialName(giftField) + val gift: Gift, + @SerialName(ownedGiftIdField) + val ownedGiftId: GiftId? = null, + @SerialName(convertStarCountField) + val convertStarCount: Int? = null, + @SerialName(prepaidUpgradeStarCountField) + val prepaidUpgradeStarCount: Int? = null, + @SerialName(canBeUpgradedField) + val canBeUpgraded: Boolean = false, + @SerialName(textField) + val text: String? = null, + @SerialName(entitiesField) + val entities: RawMessageEntities, + @SerialName(isPrivateField) + val isPrivate: Boolean = false +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 2fa2995bc8..ec99fdcb25 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.types.dice.Dice import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.games.RawGame +import dev.inmo.tgbotapi.types.gifts.GiftInfo import dev.inmo.tgbotapi.types.giveaway.* import dev.inmo.tgbotapi.types.message.content.GiveawayContent import dev.inmo.tgbotapi.types.location.Location @@ -160,6 +161,9 @@ internal data class RawMessage( private val giveaway: Giveaway? = null, private val giveaway_winners: GiveawayPublicResults? = null, private val giveaway_completed: GiveawayPrivateResults? = null, + + // Gifts + private val gift: GiftInfo? = null ) { private val checkedFrom = from ?.takeIf { !it.isFakeTelegramUser() } private val content: MessageContent? by lazy { From 46a1ed27b7151dc2e278821ebdd133b507a17cff Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 15:58:36 +0300 Subject: [PATCH 09/27] feat: implemented UniqueGiftInfo class --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 71c89d90e6..029644ea93 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -503,6 +503,7 @@ const val convertStarCountField = "convert_star_count" const val prepaidUpgradeStarCountField = "prepaid_upgrade_star_count" const val canBeUpgradedField = "can_be_upgraded" const val isPrivateField = "is_private" +const val transferStarCountField = "transfer_star_count" const val pointField = "point" const val xShiftField = "x_shift" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt new file mode 100644 index 0000000000..c76918b0a5 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt @@ -0,0 +1,17 @@ +package dev.inmo.tgbotapi.types.gifts + +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class UniqueGiftInfo private constructor( + @SerialName(giftField) + val gift: UniqueGift, + @SerialName(originField) + val origin: String? = null, + @SerialName(ownedGiftIdField) + val ownedGiftId: GiftId? = null, + @SerialName(transferStarCountField) + val transferStarCount: Int? = null +) From 648535370429b0e04767b5f8d6da41e6e5d5ff41 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 15:58:36 +0300 Subject: [PATCH 10/27] fix: UniqueGiftInfo constructor is now public --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 71c89d90e6..029644ea93 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -503,6 +503,7 @@ const val convertStarCountField = "convert_star_count" const val prepaidUpgradeStarCountField = "prepaid_upgrade_star_count" const val canBeUpgradedField = "can_be_upgraded" const val isPrivateField = "is_private" +const val transferStarCountField = "transfer_star_count" const val pointField = "point" const val xShiftField = "x_shift" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt new file mode 100644 index 0000000000..ae68159dd5 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt @@ -0,0 +1,17 @@ +package dev.inmo.tgbotapi.types.gifts + +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class UniqueGiftInfo( + @SerialName(giftField) + val gift: UniqueGift, + @SerialName(originField) + val origin: String? = null, + @SerialName(ownedGiftIdField) + val ownedGiftId: GiftId? = null, + @SerialName(transferStarCountField) + val transferStarCount: Int? = null +) From 1bfe431393ca2be821bc79c745079c5de860ca0c Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:27:52 +0300 Subject: [PATCH 11/27] fix: added defaults to AcceptedGiftTypes --- .../kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt index d2c94d67fe..4fe17417d1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt @@ -14,11 +14,11 @@ import kotlinx.serialization.Serializable @Serializable data class AcceptedGiftTypes( @SerialName(unlimitedGiftsField) - val unlimitedGifts: Boolean, + val unlimitedGifts: Boolean = true, @SerialName(limitedGiftsField) - val limitedGifts: Boolean, + val limitedGifts: Boolean = true, @SerialName(uniqueGiftsField) - val uniqueGifts: Boolean, + val uniqueGifts: Boolean = true, @SerialName(premiumSubscriptionField) - val premiumSubscription: Boolean + val premiumSubscription: Boolean = true ) From 3312b64564021b364489afcdfd4890b5b26783c3 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:30:37 +0300 Subject: [PATCH 12/27] fix: added default AcceptedGiftTypes in Extended.kt --- .../dev/inmo/tgbotapi/types/chat/Extended.kt | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index 723f6acb44..fdbf125fba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -59,7 +59,7 @@ data class ExtendedChannelChatImpl( @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, @SerialName(acceptedGiftTypesField) - override val acceptedGiftTypes: AcceptedGiftTypes, + override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(), ) : ExtendedChannelChat @Serializable @@ -101,7 +101,7 @@ data class ExtendedGroupChatImpl( @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, @SerialName(acceptedGiftTypesField) - override val acceptedGiftTypes: AcceptedGiftTypes, + override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(), ) : ExtendedGroupChat @Serializable @@ -151,7 +151,7 @@ data class ExtendedPrivateChatImpl( @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, @SerialName(acceptedGiftTypesField) - override val acceptedGiftTypes: AcceptedGiftTypes, + override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(), ) : ExtendedPrivateChat typealias ExtendedUser = ExtendedPrivateChatImpl @@ -219,7 +219,7 @@ data class ExtendedSupergroupChatImpl( @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, @SerialName(acceptedGiftTypesField) - override val acceptedGiftTypes: AcceptedGiftTypes, + override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(), ) : ExtendedSupergroupChat @Serializable @@ -285,7 +285,7 @@ data class ExtendedForumChatImpl( @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3, @SerialName(acceptedGiftTypesField) - override val acceptedGiftTypes: AcceptedGiftTypes, + override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(), ) : ExtendedForumChat @Serializable @@ -321,7 +321,7 @@ data class ExtendedBot( @SerialName(hasMainWebAppField) val hasMainWebApp: Boolean = false, @SerialName(acceptedGiftTypesField) - override val acceptedGiftTypes: AcceptedGiftTypes, + override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(), ) : Bot(), ExtendedChat { @SerialName(isBotField) private val isBot = true @@ -352,10 +352,5 @@ data class UnknownExtendedChat( @SerialName(maxReactionCountField) override val maxReactionsCount: Int = 3 @SerialName(acceptedGiftTypesField) - override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes( - unlimitedGifts = false, - limitedGifts = false, - uniqueGifts = false, - premiumSubscription = false - ) + override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes() } From e720da708c819c6bc00fb35d36b3216fa0143baa Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:32:47 +0300 Subject: [PATCH 13/27] fix: moved AcceptedGiftTypes.kt to the appropriate package --- .../kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt | 2 +- .../dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt | 2 +- .../inmo/tgbotapi/types/{ => gifts}/AcceptedGiftTypes.kt | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/{ => gifts}/AcceptedGiftTypes.kt (78%) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index fdbf125fba..5278834c65 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -5,11 +5,11 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessIntro import dev.inmo.tgbotapi.types.business_connection.BusinessLocation import dev.inmo.tgbotapi.types.business_connection.BusinessOpeningHours import dev.inmo.tgbotapi.types.colors.ColorId +import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer import dev.inmo.tgbotapi.types.reactions.Reaction import dev.inmo.tgbotapi.utils.RiskFeature -import korlibs.time.DateTime import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonObject diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index 4b8374914c..3a362d8857 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessIntro import dev.inmo.tgbotapi.types.business_connection.BusinessLocation import dev.inmo.tgbotapi.types.business_connection.BusinessOpeningHours import dev.inmo.tgbotapi.types.colors.ColorId -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer import dev.inmo.tgbotapi.types.reactions.Reaction diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt similarity index 78% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt index 4fe17417d1..6fa54f4477 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/AcceptedGiftTypes.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt @@ -1,5 +1,9 @@ -package dev.inmo.tgbotapi.types +package dev.inmo.tgbotapi.types.gifts +import dev.inmo.tgbotapi.types.limitedGiftsField +import dev.inmo.tgbotapi.types.premiumSubscriptionField +import dev.inmo.tgbotapi.types.uniqueGiftsField +import dev.inmo.tgbotapi.types.unlimitedGiftsField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable From 6fceee4199d69e3d2580104878745247c8b20a63 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:33:31 +0300 Subject: [PATCH 14/27] fix: moved classes related to unique gifts to appropriate packages --- .../dev/inmo/tgbotapi/types/{ => gifts}/UniqueGift.kt | 3 ++- .../inmo/tgbotapi/types/{ => gifts}/UniqueGiftBackdrop.kt | 5 ++++- .../tgbotapi/types/{ => gifts}/UniqueGiftBackdropColors.kt | 6 +++++- .../dev/inmo/tgbotapi/types/{ => gifts}/UniqueGiftModel.kt | 5 ++++- .../dev/inmo/tgbotapi/types/{ => gifts}/UniqueGiftSymbol.kt | 5 ++++- 5 files changed, 19 insertions(+), 5 deletions(-) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/{ => gifts}/UniqueGift.kt (93%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/{ => gifts}/UniqueGiftBackdrop.kt (76%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/{ => gifts}/UniqueGiftBackdropColors.kt (76%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/{ => gifts}/UniqueGiftModel.kt (77%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/{ => gifts}/UniqueGiftSymbol.kt (78%) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGift.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt similarity index 93% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGift.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt index 1a65ff2813..cf2e0dcf61 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGift.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt @@ -1,5 +1,6 @@ -package dev.inmo.tgbotapi.types +package dev.inmo.tgbotapi.types.gifts +import dev.inmo.tgbotapi.types.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdrop.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt similarity index 76% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdrop.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt index 35259a1f45..bbe5d01aeb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdrop.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt @@ -1,5 +1,8 @@ -package dev.inmo.tgbotapi.types +package dev.inmo.tgbotapi.types.gifts +import dev.inmo.tgbotapi.types.colorsField +import dev.inmo.tgbotapi.types.nameField +import dev.inmo.tgbotapi.types.rarityPerMilleField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdropColors.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt similarity index 76% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdropColors.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt index 49a30d98ad..0b19dd1089 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftBackdropColors.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt @@ -1,5 +1,9 @@ -package dev.inmo.tgbotapi.types +package dev.inmo.tgbotapi.types.gifts +import dev.inmo.tgbotapi.types.centerColorField +import dev.inmo.tgbotapi.types.edgeColorField +import dev.inmo.tgbotapi.types.symbolColorField +import dev.inmo.tgbotapi.types.textColorField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftModel.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt similarity index 77% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftModel.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt index ed0d9f26e0..cc42a199c9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftModel.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt @@ -1,6 +1,9 @@ -package dev.inmo.tgbotapi.types +package dev.inmo.tgbotapi.types.gifts import dev.inmo.tgbotapi.types.files.Sticker +import dev.inmo.tgbotapi.types.nameField +import dev.inmo.tgbotapi.types.rarityPerMilleField +import dev.inmo.tgbotapi.types.stickerField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftSymbol.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt similarity index 78% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftSymbol.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt index 9f267ee1fb..ee6796424b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UniqueGiftSymbol.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt @@ -1,6 +1,9 @@ -package dev.inmo.tgbotapi.types +package dev.inmo.tgbotapi.types.gifts import dev.inmo.tgbotapi.types.files.Sticker +import dev.inmo.tgbotapi.types.nameField +import dev.inmo.tgbotapi.types.rarityPerMilleField +import dev.inmo.tgbotapi.types.stickerField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable From 314c8d9ad1415e9aecfca708eb6166ea9e895a8a Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:34:41 +0300 Subject: [PATCH 15/27] fix: using RGBColor abstractions instead of raw Int values now. --- .../tgbotapi/types/gifts/UniqueGiftBackdropColors.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt index 0b19dd1089..94bbc57e9a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.types.centerColorField import dev.inmo.tgbotapi.types.edgeColorField import dev.inmo.tgbotapi.types.symbolColorField import dev.inmo.tgbotapi.types.textColorField +import dev.inmo.tgbotapi.utils.RGBColor import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -18,11 +19,11 @@ import kotlinx.serialization.Serializable @Serializable data class UniqueGiftBackdropColors( @SerialName(centerColorField) - val centerColor: Int, + val centerColor: RGBColor, @SerialName(edgeColorField) - val edgeColor: Int, + val edgeColor: RGBColor, @SerialName(symbolColorField) - val symbolColor: Int, + val symbolColor: RGBColor, @SerialName(textColorField) - val textColor: Int + val textColor: RGBColor ) From 03ea8dfe7f209ee0bd183c91ab8a6d5308018cf0 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:37:07 +0300 Subject: [PATCH 16/27] fix: removed useless docs --- .../inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt | 9 +-------- .../dev/inmo/tgbotapi/types/gifts/UniqueGift.kt | 11 +---------- .../inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt | 8 +------- .../tgbotapi/types/gifts/UniqueGiftBackdropColors.kt | 9 +-------- .../dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt | 8 +------- .../dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt | 8 +------- 6 files changed, 6 insertions(+), 47 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt index 6fa54f4477..dbb9ebca5b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt @@ -7,14 +7,7 @@ import dev.inmo.tgbotapi.types.unlimitedGiftsField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -/** - * This object describes the types of gifts that can be gifted to a user or a chat. - * - * @param unlimitedGifts True, if unlimited regular gifts are accepted - * @param limitedGifts True, if limited regular gifts are accepted - * @param uniqueGifts True, if unique gifts or gifts that can be upgraded to unique for free are accepted - * @param premiumSubscription True, if a Telegram Premium subscription is accepted - */ + @Serializable data class AcceptedGiftTypes( @SerialName(unlimitedGiftsField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt index cf2e0dcf61..30f30c7e6e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt @@ -4,16 +4,7 @@ import dev.inmo.tgbotapi.types.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -/** - * This object describes a unique gift that was upgraded from a regular gift. - * - * @param baseName Human-readable name of the regular gift from which this unique gift was upgraded - * @param name Unique name of the gift. This name can be used in `https://t.me/nft/...` links and story areas - * @param number Unique number of the upgraded gift among gifts upgraded from the same regular gift - * @param model Model of the gift - * @param symbol Symbol of the gift - * @param backdrop Backdrop of the gift - */ + @Serializable data class UniqueGift( @SerialName(baseNameField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt index bbe5d01aeb..22bd75b826 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt @@ -6,13 +6,7 @@ import dev.inmo.tgbotapi.types.rarityPerMilleField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -/** - * This object describes the backdrop of a unique gift. - * - * @param name Name of the backdrop - * @param colors Colors of the backdrop - * @param rarityPerMille The number of unique gifts that receive this backdrop for every 1000 gifts upgraded - */ + @Serializable data class UniqueGiftBackdrop( @SerialName(nameField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt index 94bbc57e9a..fac98b28ed 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt @@ -8,14 +8,7 @@ import dev.inmo.tgbotapi.utils.RGBColor import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -/** - * This object describes the colors of the backdrop of a unique gift. - * - * @param centerColor The color in the center of the backdrop in RGB format - * @param edgeColor The color on the edges of the backdrop in RGB format - * @param symbolColor The color to be applied to the symbol in RGB format - * @param textColor The color for the text on the backdrop in RGB format - */ + @Serializable data class UniqueGiftBackdropColors( @SerialName(centerColorField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt index cc42a199c9..2f95e03a30 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt @@ -7,13 +7,7 @@ import dev.inmo.tgbotapi.types.stickerField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -/** - * This object describes the model of a unique gift. - * - * @param name Name of the model - * @param sticker The sticker that represents the unique gift - * @param rarityPerMille The number of unique gifts that receive this model for every 1000 gifts upgraded - */ + @Serializable data class UniqueGiftModel( @SerialName(nameField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt index ee6796424b..3ce903732c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt @@ -7,13 +7,7 @@ import dev.inmo.tgbotapi.types.stickerField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -/** - * This object describes the symbol shown on the pattern of a unique gift. - * - * @param name Name of the symbol - * @param sticker The sticker that represents the unique gift - * @param rarityPerMille The number of unique gifts that receive this model for every 1000 gifts upgraded - */ + @Serializable data class UniqueGiftSymbol( @SerialName(nameField) From b53fb8da36cc91c1aad83a6f7582ccea8b15c9be Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:42:28 +0300 Subject: [PATCH 17/27] feat: added constructor to GiftInfo --- .../dev/inmo/tgbotapi/types/gifts/GiftInfo.kt | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt index d85df96526..03f37347f4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt @@ -2,25 +2,45 @@ package dev.inmo.tgbotapi.types.gifts import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.RawMessageEntities +import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.message.toRawMessageEntities import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import kotlin.jvm.JvmName + @Serializable data class GiftInfo private constructor( - @SerialName(giftField) - val gift: Gift, - @SerialName(ownedGiftIdField) - val ownedGiftId: GiftId? = null, - @SerialName(convertStarCountField) - val convertStarCount: Int? = null, - @SerialName(prepaidUpgradeStarCountField) - val prepaidUpgradeStarCount: Int? = null, - @SerialName(canBeUpgradedField) - val canBeUpgraded: Boolean = false, - @SerialName(textField) - val text: String? = null, - @SerialName(entitiesField) - val entities: RawMessageEntities, - @SerialName(isPrivateField) - val isPrivate: Boolean = false -) + @SerialName(giftField) val gift: Gift, + @SerialName(ownedGiftIdField) val ownedGiftId: GiftId? = null, + @SerialName(convertStarCountField) val convertStarCount: Int? = null, + @SerialName(prepaidUpgradeStarCountField) val prepaidUpgradeStarCount: Int? = null, + @SerialName(canBeUpgradedField) val canBeUpgraded: Boolean = false, + @SerialName(textField) val text: String? = null, + @SerialName(entitiesField) val entities: RawMessageEntities, + @SerialName(isPrivateField) val isPrivate: Boolean = false +) { + companion object { + @JvmName("PublicConstructor") + operator fun invoke( + gift: Gift, + ownedGiftId: GiftId? = null, + convertStarCount: Int? = null, + prepaidUpgradeStarCount: Int? = null, + canBeUpgraded: Boolean = false, + text: String? = null, + textSources: TextSourcesList = emptyList(), + position: Int, + isPrivate: Boolean = false + ) = GiftInfo( + gift, + ownedGiftId, + convertStarCount, + prepaidUpgradeStarCount, + canBeUpgraded, + text, + textSources.toRawMessageEntities(position), + isPrivate + ) + } +} From 7cb576e6b1c0585b2991683fbf859649cdbdd1ad Mon Sep 17 00:00:00 2001 From: Bodya <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 17:10:10 +0300 Subject: [PATCH 18/27] fix: fixed defaults in AcceptedGiftTypes --- .../dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt index dbb9ebca5b..8d0b4cb92c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes.kt @@ -11,11 +11,11 @@ import kotlinx.serialization.Serializable @Serializable data class AcceptedGiftTypes( @SerialName(unlimitedGiftsField) - val unlimitedGifts: Boolean = true, + val unlimitedGifts: Boolean = false, @SerialName(limitedGiftsField) - val limitedGifts: Boolean = true, + val limitedGifts: Boolean = false, @SerialName(uniqueGiftsField) - val uniqueGifts: Boolean = true, + val uniqueGifts: Boolean = false, @SerialName(premiumSubscriptionField) - val premiumSubscription: Boolean = true + val premiumSubscription: Boolean = false ) From d40919f099658d8d176a52bca749a3538ea36f13 Mon Sep 17 00:00:00 2001 From: Bodya <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 17:11:31 +0300 Subject: [PATCH 19/27] style: separated annotations and values with line breaks in GiftInfo.kt --- .../dev/inmo/tgbotapi/types/gifts/GiftInfo.kt | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt index 03f37347f4..b0c77d8d38 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt @@ -11,14 +11,22 @@ import kotlin.jvm.JvmName @Serializable data class GiftInfo private constructor( - @SerialName(giftField) val gift: Gift, - @SerialName(ownedGiftIdField) val ownedGiftId: GiftId? = null, - @SerialName(convertStarCountField) val convertStarCount: Int? = null, - @SerialName(prepaidUpgradeStarCountField) val prepaidUpgradeStarCount: Int? = null, - @SerialName(canBeUpgradedField) val canBeUpgraded: Boolean = false, - @SerialName(textField) val text: String? = null, - @SerialName(entitiesField) val entities: RawMessageEntities, - @SerialName(isPrivateField) val isPrivate: Boolean = false + @SerialName(giftField) + val gift: Gift, + @SerialName(ownedGiftIdField) + val ownedGiftId: GiftId? = null, + @SerialName(convertStarCountField) + val convertStarCount: Int? = null, + @SerialName(prepaidUpgradeStarCountField) + val prepaidUpgradeStarCount: Int? = null, + @SerialName(canBeUpgradedField) + val canBeUpgraded: Boolean = false, + @SerialName(textField) + val text: String? = null, + @SerialName(entitiesField) + val entities: RawMessageEntities, + @SerialName(isPrivateField) + val isPrivate: Boolean = false ) { companion object { @JvmName("PublicConstructor") From cb6127bf91efef63099b893434f773438d06a775 Mon Sep 17 00:00:00 2001 From: Bodya <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 17:14:24 +0300 Subject: [PATCH 20/27] fix: `accepted_gift_types` field is not optional anymore --- .../kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index 5278834c65..a2b0dd6cda 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -21,6 +21,8 @@ data class ExtendedChannelChatImpl( override val id: ChatId, @SerialName(titleField) override val title: String, + @SerialName(acceptedGiftTypesField) + override val acceptedGiftTypes: AcceptedGiftTypes, @SerialName(usernameField) override val username: Username? = null, @SerialName(activeUsernamesField) @@ -57,9 +59,7 @@ data class ExtendedChannelChatImpl( @SerialName(hasVisibleHistoryField) override val newMembersSeeHistory: Boolean = false, @SerialName(maxReactionCountField) - override val maxReactionsCount: Int = 3, - @SerialName(acceptedGiftTypesField) - override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(), + override val maxReactionsCount: Int = 3 ) : ExtendedChannelChat @Serializable From 713130fd139cb63fb5481165158d8db743284c54 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Wed, 16 Apr 2025 16:34:33 +0300 Subject: [PATCH 21/27] fix: brought back the `canReceiveGifts` field, marked as deprecated --- .../inmo/tgbotapi/types/chat/ExtendedAbstracts.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index 3a362d8857..fc6bd47080 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -21,6 +21,17 @@ sealed interface ExtendedChat : Chat { val maxReactionsCount: Int val acceptedGiftTypes: AcceptedGiftTypes + + @Deprecated( + message = "Telegram Bot API v9.0 introduced the new field, `acceptedGiftTypes`, to allow granular" + + " control over which types of gifts user, bot, or chat can accept.", + replaceWith = ReplaceWith("acceptedGiftTypes.uniqueGifts || acceptedGiftTypes.unlimitedGifts || acceptedGiftTypes.limitedGifts || acceptedGiftTypes.premiumSubscription") + ) + val canReceiveGifts: Boolean + get() = acceptedGiftTypes.uniqueGifts || + acceptedGiftTypes.unlimitedGifts || + acceptedGiftTypes.limitedGifts || + acceptedGiftTypes.premiumSubscription } @Serializable(ExtendedChatSerializer.Companion::class) @@ -60,6 +71,7 @@ sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername, Ex sealed interface ExtendedPublicChat : ExtendedChat, PublicChat, ExtendedNonBotChat { val description: String val inviteLink: String? + @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) val pinnedMessage: Message? val membersHidden: Boolean From 7e80f4edacab13d2e801d1878b426d947319bb20 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Wed, 16 Apr 2025 17:57:27 +0300 Subject: [PATCH 22/27] fix: removed leftovers of merge conflict resolving on GitHub --- .../src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 692ad76685..9f2420a55c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -96,7 +96,7 @@ val openPeriodPollSecondsLimit = 5 .. 600 val membersLimit = 1 .. 99999 val suggestedTipAmountsLimit = 1 .. 4 -git + val inputFieldPlaceholderLimit = 1 .. 64 val emojisInStickerLimit = 1 .. 20 From 29c6bb5dac0ff2db8a81ce37c1feb8a859875b8a Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:27:34 +0300 Subject: [PATCH 23/27] fix: made entities field optional for GiftInfo --- .../commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt index b0c77d8d38..9f413c1bc8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt @@ -24,7 +24,7 @@ data class GiftInfo private constructor( @SerialName(textField) val text: String? = null, @SerialName(entitiesField) - val entities: RawMessageEntities, + val entities: RawMessageEntities = emptyList(), @SerialName(isPrivateField) val isPrivate: Boolean = false ) { From 09dee188d2b0bbbe625aff16654cbe0e009f091e Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:38:16 +0300 Subject: [PATCH 24/27] refactor: merged GiftInfo and UniqueGiftInfo into one sealed interface --- .../dev/inmo/tgbotapi/types/gifts/GiftInfo.kt | 97 +++++++++++-------- .../tgbotapi/types/gifts/UniqueGiftInfo.kt | 17 ---- 2 files changed, 57 insertions(+), 57 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt index 9f413c1bc8..64a3966406 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt @@ -10,45 +10,62 @@ import kotlin.jvm.JvmName @Serializable -data class GiftInfo private constructor( - @SerialName(giftField) - val gift: Gift, - @SerialName(ownedGiftIdField) - val ownedGiftId: GiftId? = null, - @SerialName(convertStarCountField) - val convertStarCount: Int? = null, - @SerialName(prepaidUpgradeStarCountField) - val prepaidUpgradeStarCount: Int? = null, - @SerialName(canBeUpgradedField) - val canBeUpgraded: Boolean = false, - @SerialName(textField) - val text: String? = null, - @SerialName(entitiesField) - val entities: RawMessageEntities = emptyList(), - @SerialName(isPrivateField) - val isPrivate: Boolean = false -) { - companion object { - @JvmName("PublicConstructor") - operator fun invoke( - gift: Gift, - ownedGiftId: GiftId? = null, - convertStarCount: Int? = null, - prepaidUpgradeStarCount: Int? = null, - canBeUpgraded: Boolean = false, - text: String? = null, - textSources: TextSourcesList = emptyList(), - position: Int, - isPrivate: Boolean = false - ) = GiftInfo( - gift, - ownedGiftId, - convertStarCount, - prepaidUpgradeStarCount, - canBeUpgraded, - text, - textSources.toRawMessageEntities(position), - isPrivate - ) +sealed interface GiftInfo { + val ownedGiftId: GiftId? + + @Serializable + data class Regular( + @SerialName(giftField) + val gift: Gift, + @SerialName(ownedGiftIdField) + override val ownedGiftId: GiftId? = null, + @SerialName(convertStarCountField) + val convertStarCount: Int? = null, + @SerialName(prepaidUpgradeStarCountField) + val prepaidUpgradeStarCount: Int? = null, + @SerialName(canBeUpgradedField) + val canBeUpgraded: Boolean = false, + @SerialName(textField) + val text: String? = null, + @SerialName(entitiesField) + val entities: RawMessageEntities = emptyList(), + @SerialName(isPrivateField) + val isPrivate: Boolean = false + ) : GiftInfo { + companion object { + @JvmName("PublicConstructor") + operator fun invoke( + gift: Gift, + ownedGiftId: GiftId? = null, + convertStarCount: Int? = null, + prepaidUpgradeStarCount: Int? = null, + canBeUpgraded: Boolean = false, + text: String? = null, + textSources: TextSourcesList = emptyList(), + position: Int, + isPrivate: Boolean = false + ) = Regular( + gift, + ownedGiftId, + convertStarCount, + prepaidUpgradeStarCount, + canBeUpgraded, + text, + textSources.toRawMessageEntities(position), + isPrivate + ) + } } + + @Serializable + data class Unique( + @SerialName(giftField) + val gift: UniqueGift, + @SerialName(originField) + val origin: String? = null, + @SerialName(ownedGiftIdField) + override val ownedGiftId: GiftId? = null, + @SerialName(transferStarCountField) + val transferStarCount: Int? = null + ): GiftInfo } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt deleted file mode 100644 index ae68159dd5..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.types.gifts - -import dev.inmo.tgbotapi.types.* -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class UniqueGiftInfo( - @SerialName(giftField) - val gift: UniqueGift, - @SerialName(originField) - val origin: String? = null, - @SerialName(ownedGiftIdField) - val ownedGiftId: GiftId? = null, - @SerialName(transferStarCountField) - val transferStarCount: Int? = null -) From 93e937aa6a94849aa7fc81e8eb89f3c08a307231 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Thu, 17 Apr 2025 18:16:52 +0300 Subject: [PATCH 25/27] refactor: merged UniqueGift and regular Gift types into one interface --- .../dev/inmo/tgbotapi/types/gifts/Gift.kt | 200 ++++++++++++------ .../dev/inmo/tgbotapi/types/gifts/GiftInfo.kt | 7 +- .../inmo/tgbotapi/types/gifts/UniqueGift.kt | 22 -- 3 files changed, 145 insertions(+), 84 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt index cdf71fd8e5..685bfb3303 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt @@ -11,55 +11,133 @@ import kotlinx.serialization.encoding.Encoder @Serializable(Gift.Companion::class) sealed interface Gift { - val id: GiftId - val sticker: Sticker - val starCount: Int - val totalCount: Int? - val upgradeStarCount: Int? - val remainingCount: Int? + @Serializable(Regular.Companion::class) + sealed interface Regular : Gift { + val id: GiftId + val sticker: Sticker + val starCount: Int + val totalCount: Int? + val upgradeStarCount: Int? + val remainingCount: Int? - @Serializable - data class Unlimited( - @SerialName(idField) - override val id: GiftId, - @SerialName(stickerField) - override val sticker: Sticker, - @SerialName(starCountField) - override val starCount: Int, - @SerialName(upgradeStarCountField) - override val upgradeStarCount: Int? = null - ) : Gift { - override val totalCount: Int? - get() = null - override val remainingCount: Int? - get() = null + @Serializable + data class Unlimited( + @SerialName(idField) + override val id: GiftId, + @SerialName(stickerField) + override val sticker: Sticker, + @SerialName(starCountField) + override val starCount: Int, + @SerialName(upgradeStarCountField) + override val upgradeStarCount: Int? = null + ) : Regular { + override val totalCount: Int? + get() = null + override val remainingCount: Int? + get() = null + } + + @Serializable + data class Limited( + @SerialName(idField) + override val id: GiftId, + @SerialName(stickerField) + override val sticker: Sticker, + @SerialName(starCountField) + override val starCount: Int, + @SerialName(totalCountField) + override val totalCount: Int, + @SerialName(remainingCountField) + override val remainingCount: Int, + @SerialName(upgradeStarCountField) + override val upgradeStarCount: Int? = null, + ) : Regular + + companion object : KSerializer { + @Serializable + @Suppress("propertyName") + private data class RegularGiftSurrogate( + val id: GiftId, + val sticker: Sticker, + val star_count: Int, + val total_count: Int? = null, + val remaining_count: Int? = null, + val upgrade_star_count: Int? = null, + ) + + override val descriptor: SerialDescriptor + get() = RegularGiftSurrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): Regular { + val surrogate = RegularGiftSurrogate.serializer().deserialize(decoder) + + return if (surrogate.total_count != null && surrogate.remaining_count != null) { + Limited( + id = surrogate.id, + sticker = surrogate.sticker, + starCount = surrogate.star_count, + totalCount = surrogate.total_count, + remainingCount = surrogate.remaining_count, + upgradeStarCount = surrogate.upgrade_star_count, + ) + } else { + Unlimited( + id = surrogate.id, + sticker = surrogate.sticker, + starCount = surrogate.star_count, + upgradeStarCount = surrogate.upgrade_star_count, + ) + } + } + + override fun serialize(encoder: Encoder, value: Regular) { + val surrogate = RegularGiftSurrogate( + id = value.id, + sticker = value.sticker, + star_count = value.starCount, + total_count = value.totalCount, + remaining_count = value.remainingCount, + upgrade_star_count = value.upgradeStarCount + ) + RegularGiftSurrogate.serializer().serialize(encoder, surrogate) + } + } } @Serializable - data class Limited( - @SerialName(idField) - override val id: GiftId, - @SerialName(stickerField) - override val sticker: Sticker, - @SerialName(starCountField) - override val starCount: Int, - @SerialName(totalCountField) - override val totalCount: Int, - @SerialName(remainingCountField) - override val remainingCount: Int, - @SerialName(upgradeStarCountField) - override val upgradeStarCount: Int? = null, + data class Unique( + @SerialName(baseNameField) + val baseName: String, + @SerialName(nameField) + val name: String, + @SerialName(numberField) + val number: Int, + @SerialName(modelField) + val model: UniqueGiftModel, + @SerialName(symbolField) + val symbol: UniqueGiftSymbol, + @SerialName(backdropField) + val backdrop: UniqueGiftBackdrop ) : Gift companion object : KSerializer { @Serializable - private data class GiftSurrogate( - val id: GiftId, - val sticker: Sticker, - val star_count: Int, + @Suppress("unused", "propertyName") + private class GiftSurrogate( + // regular gift fields + val id: GiftId?, + val sticker: Sticker?, + val star_count: Int?, val total_count: Int? = null, val remaining_count: Int? = null, val upgrade_star_count: Int? = null, + // unique gift fields + val base_name: String? = null, + val name: String? = null, + val number: Int? = null, + val model: UniqueGiftModel? = null, + val symbol: UniqueGiftSymbol? = null, + val backdrop: UniqueGiftBackdrop? = null, ) override val descriptor: SerialDescriptor @@ -68,33 +146,37 @@ sealed interface Gift { override fun deserialize(decoder: Decoder): Gift { val surrogate = GiftSurrogate.serializer().deserialize(decoder) - return if (surrogate.total_count != null && surrogate.remaining_count != null) { - Limited( - id = surrogate.id, - sticker = surrogate.sticker, - starCount = surrogate.star_count, - totalCount = surrogate.total_count, - remainingCount = surrogate.remaining_count, - upgradeStarCount = surrogate.upgrade_star_count, + return if (surrogate.base_name != null && surrogate.name != null && surrogate.number != null && surrogate.model != null && surrogate.symbol != null && surrogate.backdrop != null) { + Unique( + baseName = surrogate.base_name, + name = surrogate.name, + number = surrogate.number, + model = surrogate.model, + symbol = surrogate.symbol, + backdrop = surrogate.backdrop, ) } else { - Unlimited( - id = surrogate.id, - sticker = surrogate.sticker, - starCount = surrogate.star_count, - upgradeStarCount = surrogate.upgrade_star_count, - ) + decoder.decodeSerializableValue(Regular.serializer()) } } - override fun serialize(encoder: Encoder, value: Gift) { + override fun serialize( + encoder: Encoder, + value: Gift + ) { val surrogate = GiftSurrogate( - id = value.id, - sticker = value.sticker, - star_count = value.starCount, - total_count = value.totalCount, - remaining_count = value.remainingCount, - upgrade_star_count = value.upgradeStarCount + id = (value as? Regular)?.id, + sticker = (value as? Regular)?.sticker, + star_count = (value as? Regular)?.starCount, + total_count = (value as? Regular.Limited)?.totalCount, + remaining_count = (value as? Regular.Limited)?.remainingCount, + upgrade_star_count = (value as? Regular)?.upgradeStarCount, + base_name = (value as? Unique)?.baseName, + name = (value as? Unique)?.name, + number = (value as? Unique)?.number, + model = (value as? Unique)?.model, + symbol = (value as? Unique)?.symbol, + backdrop = (value as? Unique)?.backdrop, ) GiftSurrogate.serializer().serialize(encoder, surrogate) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt index 64a3966406..676a179281 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt @@ -12,11 +12,12 @@ import kotlin.jvm.JvmName @Serializable sealed interface GiftInfo { val ownedGiftId: GiftId? + val gift: Gift @Serializable data class Regular( @SerialName(giftField) - val gift: Gift, + override val gift: Gift.Regular, @SerialName(ownedGiftIdField) override val ownedGiftId: GiftId? = null, @SerialName(convertStarCountField) @@ -35,7 +36,7 @@ sealed interface GiftInfo { companion object { @JvmName("PublicConstructor") operator fun invoke( - gift: Gift, + gift: Gift.Regular, ownedGiftId: GiftId? = null, convertStarCount: Int? = null, prepaidUpgradeStarCount: Int? = null, @@ -60,7 +61,7 @@ sealed interface GiftInfo { @Serializable data class Unique( @SerialName(giftField) - val gift: UniqueGift, + override val gift: Gift.Unique, @SerialName(originField) val origin: String? = null, @SerialName(ownedGiftIdField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt deleted file mode 100644 index 30f30c7e6e..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGift.kt +++ /dev/null @@ -1,22 +0,0 @@ -package dev.inmo.tgbotapi.types.gifts - -import dev.inmo.tgbotapi.types.* -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - - -@Serializable -data class UniqueGift( - @SerialName(baseNameField) - val baseName: String, - @SerialName(nameField) - val name: String, - @SerialName(numberField) - val number: Int, - @SerialName(modelField) - val model: UniqueGiftModel, - @SerialName(symbolField) - val symbol: UniqueGiftSymbol, - @SerialName(backdropField) - val backdrop: UniqueGiftBackdrop -) From 67fb552d0174ea5eb34c4e302e89dd82c75f9797 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Thu, 17 Apr 2025 18:18:17 +0300 Subject: [PATCH 26/27] refactor: moved unique gift properties into separate package --- .../commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt | 3 +++ .../tgbotapi/types/gifts/{ => unique}/UniqueGiftBackdrop.kt | 2 +- .../types/gifts/{ => unique}/UniqueGiftBackdropColors.kt | 2 +- .../inmo/tgbotapi/types/gifts/{ => unique}/UniqueGiftModel.kt | 2 +- .../inmo/tgbotapi/types/gifts/{ => unique}/UniqueGiftSymbol.kt | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/{ => unique}/UniqueGiftBackdrop.kt (90%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/{ => unique}/UniqueGiftBackdropColors.kt (93%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/{ => unique}/UniqueGiftModel.kt (91%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/{ => unique}/UniqueGiftSymbol.kt (91%) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt index 685bfb3303..3ff24910ed 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt @@ -2,6 +2,9 @@ package dev.inmo.tgbotapi.types.gifts import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.files.Sticker +import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftBackdrop +import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftModel +import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftSymbol import kotlinx.serialization.KSerializer import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftBackdrop.kt similarity index 90% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftBackdrop.kt index 22bd75b826..2cf5b14930 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdrop.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftBackdrop.kt @@ -1,4 +1,4 @@ -package dev.inmo.tgbotapi.types.gifts +package dev.inmo.tgbotapi.types.gifts.unique import dev.inmo.tgbotapi.types.colorsField import dev.inmo.tgbotapi.types.nameField diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftBackdropColors.kt similarity index 93% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftBackdropColors.kt index fac98b28ed..d2acfdb353 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftBackdropColors.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftBackdropColors.kt @@ -1,4 +1,4 @@ -package dev.inmo.tgbotapi.types.gifts +package dev.inmo.tgbotapi.types.gifts.unique import dev.inmo.tgbotapi.types.centerColorField import dev.inmo.tgbotapi.types.edgeColorField diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftModel.kt similarity index 91% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftModel.kt index 2f95e03a30..28e3820c57 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftModel.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftModel.kt @@ -1,4 +1,4 @@ -package dev.inmo.tgbotapi.types.gifts +package dev.inmo.tgbotapi.types.gifts.unique import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.nameField diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftSymbol.kt similarity index 91% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftSymbol.kt index 3ce903732c..0c322ee19b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftSymbol.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/unique/UniqueGiftSymbol.kt @@ -1,4 +1,4 @@ -package dev.inmo.tgbotapi.types.gifts +package dev.inmo.tgbotapi.types.gifts.unique import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.nameField From 8d6d70a06a2a5f79aef7741a4d74bc01d95df368 Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Thu, 17 Apr 2025 18:31:56 +0300 Subject: [PATCH 27/27] refactor: replaced `Gift` with `Gift.Regular` across APIs and data models --- .../dev/inmo/tgbotapi/extensions/api/gifts/SendGift.kt | 8 ++++---- .../extensions/api/gifts/SendGiftGeneratedVariation.kt | 8 ++++---- .../api/gifts/SendGiftToChatGeneratedVariation.kt | 8 ++++---- .../kotlin/dev/inmo/tgbotapi/types/gifts/Gifts.kt | 2 +- .../tgbotapi/types/payments/stars/TransactionPartner.kt | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGift.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGift.kt index bdce832604..74670ce2bc 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGift.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGift.kt @@ -22,7 +22,7 @@ public suspend fun TelegramBot.sendGift( ) userId: UserId, @GenerationVariant( - Gift::class, + Gift.Regular::class, "id", "gift" ) @@ -49,7 +49,7 @@ public suspend fun TelegramBot.sendGiftToChat( ) chatId: ChatIdentifier, @GenerationVariant( - Gift::class, + Gift.Regular::class, "id", "gift" ) @@ -76,7 +76,7 @@ public suspend fun TelegramBot.sendGift( ) userId: UserId, @GenerationVariant( - Gift::class, + Gift.Regular::class, "id", "gift" ) @@ -101,7 +101,7 @@ public suspend fun TelegramBot.sendGiftToChat( ) chatId: ChatIdentifier, @GenerationVariant( - Gift::class, + Gift.Regular::class, "id", "gift" ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGiftGeneratedVariation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGiftGeneratedVariation.kt index 9340e8ef2d..c9aedeaa49 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGiftGeneratedVariation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGiftGeneratedVariation.kt @@ -34,7 +34,7 @@ public suspend fun TelegramBot.sendGift( public suspend fun TelegramBot.sendGift( userId: UserId, - gift: Gift, + gift: Gift.Regular, text: String, parseMode: ParseMode?, ): Boolean = sendGift( @@ -43,7 +43,7 @@ public suspend fun TelegramBot.sendGift( public suspend fun TelegramBot.sendGift( userId: UserId, - gift: Gift, + gift: Gift.Regular, text: String, parseMode: ParseMode?, upgradableToUnique: Boolean, @@ -54,7 +54,7 @@ public suspend fun TelegramBot.sendGift( public suspend fun TelegramBot.sendGift( user: User, - gift: Gift, + gift: Gift.Regular, text: String, parseMode: ParseMode?, ): Boolean = sendGift( @@ -63,7 +63,7 @@ public suspend fun TelegramBot.sendGift( public suspend fun TelegramBot.sendGift( user: User, - gift: Gift, + gift: Gift.Regular, text: String, parseMode: ParseMode?, upgradableToUnique: Boolean, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGiftToChatGeneratedVariation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGiftToChatGeneratedVariation.kt index 9761fdd0fd..17028861d1 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGiftToChatGeneratedVariation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGiftToChatGeneratedVariation.kt @@ -34,7 +34,7 @@ public suspend fun TelegramBot.sendGiftToChat( public suspend fun TelegramBot.sendGiftToChat( chatId: ChatIdentifier, - gift: Gift, + gift: Gift.Regular, text: String, parseMode: ParseMode?, ): Boolean = sendGiftToChat( @@ -43,7 +43,7 @@ public suspend fun TelegramBot.sendGiftToChat( public suspend fun TelegramBot.sendGiftToChat( chatId: ChatIdentifier, - gift: Gift, + gift: Gift.Regular, text: String, parseMode: ParseMode?, upgradableToUnique: Boolean, @@ -54,7 +54,7 @@ public suspend fun TelegramBot.sendGiftToChat( public suspend fun TelegramBot.sendGiftToChat( chat: PublicChat, - gift: Gift, + gift: Gift.Regular, text: String, parseMode: ParseMode?, ): Boolean = sendGiftToChat( @@ -63,7 +63,7 @@ public suspend fun TelegramBot.sendGiftToChat( public suspend fun TelegramBot.sendGiftToChat( chat: PublicChat, - gift: Gift, + gift: Gift.Regular, text: String, parseMode: ParseMode?, upgradableToUnique: Boolean, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gifts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gifts.kt index 07ae5c6fd1..e403a48d25 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gifts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gifts.kt @@ -7,5 +7,5 @@ import kotlinx.serialization.Serializable @Serializable data class Gifts( @SerialName(giftsField) - val gifts: List + val gifts: List ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt index d9dfe04f4c..ea7263dae4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt @@ -60,7 +60,7 @@ sealed interface TransactionPartner { @SerialName(paidMediaPayloadField) val paidMediaPayload: PaidMediaPayload? = null, @SerialName(giftField) - val gift: Gift? = null + val gift: Gift.Regular? = null ) : TransactionPartner, SubscriptionPeriodInfo { @EncodeDefault override val type: String = Companion.type @@ -75,7 +75,7 @@ sealed interface TransactionPartner { @SerialName(chatField) val chat: PreviewChat, @SerialName(giftField) - val gift: Gift? = null + val gift: Gift.Regular? = null ) : TransactionPartner { @EncodeDefault override val type: String = Companion.type @@ -150,7 +150,7 @@ sealed interface TransactionPartner { val subscription_period: TimeSpan? = null, val paid_media: List? = null, val paid_media_payload: PaidMediaPayload? = null, - val gift: Gift? = null, + val gift: Gift.Regular? = null, val request_count: Int? = null, val sponsor_user: PreviewBot? = null, val commission_per_mille: Int? = null,