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

add sticker format to sticker object

This commit is contained in:
InsanusMokrassar 2023-03-11 00:46:20 +06:00
parent f75df0a425
commit 988d9995c5

View File

@ -35,6 +35,7 @@ data class StickerSurrogate(
sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile { sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile {
val emoji: String? val emoji: String?
val stickerSetName: StickerSetName? val stickerSetName: StickerSetName?
val stickerFormat: StickerFormat
val isAnimated val isAnimated
get() = false get() = false
@ -165,6 +166,11 @@ object StickerSerializer : KSerializer<Sticker> {
surrogate.emoji, surrogate.emoji,
surrogate.set_name, surrogate.set_name,
surrogate.file_size, surrogate.file_size,
when {
surrogate.is_animated == true -> StickerFormat.Animated
surrogate.is_video == true -> StickerFormat.Video
else -> StickerFormat.Static
},
json json
) )
} }
@ -180,11 +186,17 @@ object StickerSerializer : KSerializer<Sticker> {
sealed interface VideoSticker : Sticker { sealed interface VideoSticker : Sticker {
override val isVideo: Boolean override val isVideo: Boolean
get() = true get() = true
override val stickerFormat: StickerFormat
get() = StickerFormat.Video
} }
@Serializable @Serializable
sealed interface AnimatedSticker : Sticker { sealed interface AnimatedSticker : Sticker {
override val isAnimated: Boolean override val isAnimated: Boolean
get() = true get() = true
override val stickerFormat: StickerFormat
get() = StickerFormat.Animated
} }
@Serializable @Serializable
@ -209,10 +221,14 @@ data class RegularSimpleSticker(
@SerialName(stickerSetNameField) @SerialName(stickerSetNameField)
override val stickerSetName: StickerSetName? = null, override val stickerSetName: StickerSetName? = null,
@SerialName(premiumAnimationField) @SerialName(premiumAnimationField)
override val premiumAnimationFile: File?, override val premiumAnimationFile: File? = null,
@SerialName(fileSizeField) @SerialName(fileSizeField)
override val fileSize: Long? = null, override val fileSize: Long? = null,
) : RegularSticker ) : RegularSticker {
@SerialName(stickerFormatField)
@EncodeDefault
override val stickerFormat: StickerFormat = StickerFormat.Static
}
@Serializable @Serializable
data class RegularAnimatedSticker( data class RegularAnimatedSticker(
@ -231,7 +247,7 @@ data class RegularAnimatedSticker(
@SerialName(stickerSetNameField) @SerialName(stickerSetNameField)
override val stickerSetName: StickerSetName? = null, override val stickerSetName: StickerSetName? = null,
@SerialName(premiumAnimationField) @SerialName(premiumAnimationField)
override val premiumAnimationFile: File?, override val premiumAnimationFile: File? = null,
@SerialName(fileSizeField) @SerialName(fileSizeField)
override val fileSize: Long? = null, override val fileSize: Long? = null,
) : RegularSticker, AnimatedSticker ) : RegularSticker, AnimatedSticker
@ -252,7 +268,7 @@ data class RegularVideoSticker(
@SerialName(stickerSetNameField) @SerialName(stickerSetNameField)
override val stickerSetName: StickerSetName? = null, override val stickerSetName: StickerSetName? = null,
@SerialName(premiumAnimationField) @SerialName(premiumAnimationField)
override val premiumAnimationFile: File?, override val premiumAnimationFile: File? = null,
@SerialName(fileSizeField) @SerialName(fileSizeField)
override val fileSize: Long? = null, override val fileSize: Long? = null,
) : RegularSticker, VideoSticker ) : RegularSticker, VideoSticker
@ -282,7 +298,11 @@ data class MaskSimpleSticker(
override val stickerSetName: StickerSetName? = null, override val stickerSetName: StickerSetName? = null,
@SerialName(fileSizeField) @SerialName(fileSizeField)
override val fileSize: Long? = null, override val fileSize: Long? = null,
) : MaskSticker ) : MaskSticker {
@SerialName(stickerFormatField)
@EncodeDefault
override val stickerFormat: StickerFormat = StickerFormat.Static
}
@Serializable @Serializable
data class MaskAnimatedSticker( data class MaskAnimatedSticker(
@SerialName(fileIdField) @SerialName(fileIdField)
@ -354,7 +374,11 @@ data class CustomEmojiSimpleSticker(
override val fileSize: Long? = null, override val fileSize: Long? = null,
@SerialName(needsRepaintingField) @SerialName(needsRepaintingField)
override val needsRepainting: Boolean = false override val needsRepainting: Boolean = false
) : CustomEmojiSticker ) : CustomEmojiSticker {
@SerialName(stickerFormatField)
@EncodeDefault
override val stickerFormat: StickerFormat = StickerFormat.Static
}
@Serializable @Serializable
data class CustomEmojiAnimatedSticker( data class CustomEmojiAnimatedSticker(
@SerialName(fileIdField) @SerialName(fileIdField)
@ -420,5 +444,7 @@ data class UnknownSticker(
override val stickerSetName: StickerSetName? = null, override val stickerSetName: StickerSetName? = null,
@SerialName(fileSizeField) @SerialName(fileSizeField)
override val fileSize: Long? = null, override val fileSize: Long? = null,
@SerialName(stickerFormatField)
override val stickerFormat: StickerFormat = StickerFormat.Static,
val raw: JsonElement val raw: JsonElement
) : Sticker ) : Sticker