1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2026-03-03 17:32:23 +00:00

add is_burned support

This commit is contained in:
2026-02-20 13:55:19 +06:00
parent eccc687aec
commit 83b4d2155f
5 changed files with 83 additions and 23 deletions

View File

@@ -175,6 +175,7 @@ const val languageCodeField = "language_code"
const val addedToAttachmentMenuField = "added_to_attachment_menu"
const val allowsWriteToPMField = "allows_write_to_pm"
const val isPremiumField = "is_premium"
const val isBurnedField = "is_burned"
const val hasPrivateForwardsField = "has_private_forwards"
const val hasRestrictedVoiceAndVideoMessagesField = "has_restricted_voice_and_video_messages"
const val emojiStatusCustomEmojiIdField = "emoji_status_custom_emoji_id"

View File

@@ -33,6 +33,9 @@ sealed interface Gift {
val background: dev.inmo.tgbotapi.types.gifts.GiftBackground?
val uniqueGiftVariantCount: Int?
/**
* Represents a [Gift](https://core.telegram.org/bots/api#gift) for fields of unlimited gifts
*/
@Serializable
data class Unlimited(
@SerialName(idField)
@@ -64,6 +67,9 @@ sealed interface Gift {
get() = null
}
/**
* Represents a [Gift](https://core.telegram.org/bots/api#gift) for fields of limited gifts
*/
@Serializable
data class Limited(
@SerialName(idField)
@@ -173,6 +179,9 @@ sealed interface Gift {
}
}
/**
* Represents a [UniqueGift](https://core.telegram.org/bots/api#uniquegift) from telegram bots api
*/
@Serializable
data class Unique(
@SerialName(giftIdField)
@@ -180,7 +189,7 @@ sealed interface Gift {
@SerialName(baseNameField)
val baseName: String,
@SerialName(nameField)
val name: String,
val name: UniqueGiftName,
@SerialName(numberField)
val number: Int,
@SerialName(modelField)
@@ -189,14 +198,16 @@ sealed interface Gift {
val symbol: UniqueGiftSymbol,
@SerialName(backdropField)
val backdrop: UniqueGiftBackdrop,
@SerialName(publisherChatField)
override val publisherChat: PreviewChat? = null,
@SerialName(isFromBlockchainField)
val isFromBlockchain: Boolean = false,
@SerialName(isPremiumField)
val isPremium: Boolean = false,
@SerialName(isBurnedField)
val isBurned: Boolean = false,
@SerialName(isFromBlockchainField)
val isFromBlockchain: Boolean = false,
@SerialName(colorsField)
val colors: UniqueGiftColors? = null
val colors: UniqueGiftColors? = null,
@SerialName(publisherChatField)
override val publisherChat: PreviewChat? = null,
) : Gift
companion object : KSerializer<Gift> {
@@ -218,7 +229,7 @@ sealed interface Gift {
val unique_gift_variant_count: Int? = null,
// unique gift fields
val base_name: String? = null,
val name: String? = null,
val name: UniqueGiftName? = null,
val number: Int? = null,
val model: UniqueGiftModel? = null,
val symbol: UniqueGiftSymbol? = null,

View File

@@ -0,0 +1,14 @@
package dev.inmo.tgbotapi.types.gifts
import kotlinx.serialization.Serializable
import kotlin.jvm.JvmInline
/**
* Represents a name for a unique gift, encapsulating its value as a single, immutable string.
*/
@Serializable
@JvmInline
value class UniqueGiftName(val value: String) {
val nftLink
get() = "https://t.me/nft/$value"
}

View File

@@ -4,6 +4,7 @@ package dev.inmo.tgbotapi.types.stories
import dev.inmo.micro_utils.colors.common.HEXAColor
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.gifts.UniqueGiftName
import dev.inmo.tgbotapi.types.location.LocationAddress
import dev.inmo.tgbotapi.types.reactions.ReactionType
import dev.inmo.tgbotapi.utils.IntRGB24HEXAColorSerializer
@@ -94,7 +95,7 @@ sealed interface StoryAreaType {
@Serializable
data class UniqueGift(
@SerialName(nameField)
val name: String
val name: UniqueGiftName
) : StoryAreaType {
@EncodeDefault
override val type: Type = Companion
@@ -194,7 +195,7 @@ sealed interface StoryAreaType {
)
is UniqueGift -> Surrogate(
type = value.type.name,
name = value.name
name = value.name.value
)
is Unknown -> Surrogate(
type = value.type.name
@@ -227,7 +228,7 @@ sealed interface StoryAreaType {
backgroundColor = surrogate.backgroundColor ?: return unknown
)
UniqueGift.name -> UniqueGift(
name = surrogate.name ?: return unknown
name = surrogate.name ?.let(::UniqueGiftName) ?: return unknown
)
else -> unknown
}