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

rework of create new sticker set

This commit is contained in:
InsanusMokrassar 2023-03-10 14:00:57 +06:00
parent cd354e9456
commit afda5e0e7f
15 changed files with 200 additions and 519 deletions

View File

@ -2,6 +2,10 @@
## 7.0.0 ## 7.0.0
**THIS VERSION CONTAINS BREAKING CHANGES**:
* Fully reworked mechanism of stickers creating
## 6.1.0 ## 6.1.0
* `Versions`: * `Versions`:

View File

@ -1,58 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.stickers
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.stickers.CreateNewAnimatedStickerSet
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.MaskPosition
suspend fun TelegramBot.createNewAnimatedStickerSet(
userId: UserId,
name: String,
title: String,
sticker: FileId,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
)
suspend fun TelegramBot.createNewAnimatedStickerSet(
userId: UserId,
name: String,
title: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
)
suspend fun TelegramBot.createNewAnimatedStickerSet(
user: CommonUser,
name: String,
title: String,
sticker: FileId,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewAnimatedStickerSet(
user.id, name, title, sticker, emojis, containsMasks, maskPosition
)
suspend fun TelegramBot.createNewAnimatedStickerSet(
user: CommonUser,
name: String,
title: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewAnimatedStickerSet(
user.id, name, title, sticker, emojis, containsMasks, maskPosition
)

View File

@ -3,56 +3,30 @@ package dev.inmo.tgbotapi.extensions.api.stickers
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.stickers.CreateNewStaticStickerSet import dev.inmo.tgbotapi.requests.stickers.CreateNewStickerSet
import dev.inmo.tgbotapi.requests.stickers.InputSticker
import dev.inmo.tgbotapi.types.StickerFormat
import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.MaskPosition import dev.inmo.tgbotapi.types.stickers.MaskPosition
suspend fun TelegramBot.createNewStaticStickerSet( suspend fun TelegramBot.createNewStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String, title: String,
sticker: FileId, stickersFormat: StickerFormat,
emojis: String, stickers: List<InputSticker>,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute( ) = execute(
CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition) CreateNewStickerSet(userId, name, title, stickersFormat, stickers)
)
suspend fun TelegramBot.createNewStaticStickerSet(
userId: UserId,
name: String,
title: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
) )
suspend fun TelegramBot.createNewStaticStickerSet( suspend fun TelegramBot.createNewStickerSet(
user: CommonUser, user: CommonUser,
name: String, name: String,
title: String, title: String,
sticker: FileId, stickersFormat: StickerFormat,
emojis: String, stickers: List<InputSticker>,
containsMasks: Boolean? = null, ) = createNewStickerSet(
maskPosition: MaskPosition? = null user.id, name, title, stickersFormat, stickers
) = createNewStaticStickerSet(
user.id, name, title, sticker, emojis, containsMasks, maskPosition
)
suspend fun TelegramBot.createNewStaticStickerSet(
user: CommonUser,
name: String,
title: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewStaticStickerSet(
user.id, name, title, sticker, emojis, containsMasks, maskPosition
) )

View File

@ -1,58 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.stickers
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.stickers.CreateNewVideoStickerSet
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.MaskPosition
suspend fun TelegramBot.createNewVideoStickerSet(
userId: UserId,
name: String,
title: String,
sticker: FileId,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
)
suspend fun TelegramBot.createNewVideoStickerSet(
userId: UserId,
name: String,
title: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
)
suspend fun TelegramBot.createNewVideoStickerSet(
user: CommonUser,
name: String,
title: String,
sticker: FileId,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewVideoStickerSet(
user.id, name, title, sticker, emojis, containsMasks, maskPosition
)
suspend fun TelegramBot.createNewVideoStickerSet(
user: CommonUser,
name: String,
title: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewVideoStickerSet(
user.id, name, title, sticker, emojis, containsMasks, maskPosition
)

View File

@ -1,40 +0,0 @@
package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.stickers.MaskPosition
import kotlinx.serialization.*
@Serializable
@Deprecated("Use CreateNewStickerSet class instead")
data class CreateNewAnimatedStickerSet internal constructor(
@SerialName(userIdField)
override val userId: UserId,
@SerialName(nameField)
override val name: String,
@SerialName(titleField)
override val title: String,
@SerialName(emojisField)
override val emojis: String,
@SerialName(tgsStickerField)
val sticker: FileId? = null,
@SerialName(containsMasksField)
@Deprecated("Will be removed soon due to its redundancy")
val containsMasks: Boolean? = null,
@SerialName(maskPositionField)
override val maskPosition: MaskPosition? = null
) : CreateStickerSetAction {
init {
if(emojis.isEmpty()) {
throw IllegalArgumentException("Emojis must not be empty")
}
}
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = "createNewStickerSet"
}

View File

@ -1,40 +0,0 @@
package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.stickers.MaskPosition
import kotlinx.serialization.*
@Serializable
@Deprecated("Use CreateNewStickerSet class instead")
data class CreateNewStaticStickerSet internal constructor(
@SerialName(userIdField)
override val userId: UserId,
@SerialName(nameField)
override val name: String,
@SerialName(titleField)
override val title: String,
@SerialName(emojisField)
override val emojis: String,
@SerialName(pngStickerField)
val sticker: FileId? = null,
@SerialName(containsMasksField)
@Deprecated("Will be removed soon due to its redundancy")
val containsMasks: Boolean? = null,
@SerialName(maskPositionField)
override val maskPosition: MaskPosition? = null
) : CreateStickerSetAction {
init {
if(emojis.isEmpty()) {
throw IllegalArgumentException("Emojis must not be empty")
}
}
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = "createNewStickerSet"
}

View File

@ -7,36 +7,30 @@ import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.stickers.MaskPosition import dev.inmo.tgbotapi.types.stickers.MaskPosition
import kotlinx.serialization.* import kotlinx.serialization.*
internal fun CreateNewStickerSet( /**
* Will create one of [CreateNewStickerSet] types based on the first element of [stickers]
*
* @param needsRepainting Will be used only if you are creating custom emojis sticker pack (by passing [stickers] with
* type [InputSticker.WithKeywords.CustomEmoji])
*/
fun CreateNewStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String, title: String,
emojis: String, stickersFormat: StickerFormat,
stickerType: StickerType = StickerType.Regular, stickers: List<InputSticker>,
pngSticker: InputFile? = null, needsRepainting: Boolean? = null
tgsSticker: InputFile? = null,
webmSticker: InputFile? = null,
maskPosition: MaskPosition? = null
): Request<Boolean> { ): Request<Boolean> {
val data = CreateNewStickerSet( val data = when(stickers.first()) {
userId, is InputSticker.Mask -> CreateNewStickerSet.Mask(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.Mask>())
name, is InputSticker.WithKeywords.CustomEmoji -> CreateNewStickerSet.CustomEmoji(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.WithKeywords.CustomEmoji>(), needsRepainting)
title, is InputSticker.WithKeywords.Regular -> CreateNewStickerSet.Regular(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.WithKeywords.Regular>())
emojis, }
stickerType, val multipartParts = stickers.mapNotNull { (it.sticker as? MultipartFile) }
pngSticker as? FileId, return if (multipartParts.isNotEmpty()) {
tgsSticker as? FileId,
webmSticker as? FileId,
maskPosition
)
return if (pngSticker is MultipartFile || tgsSticker is MultipartFile || webmSticker is MultipartFile) {
CommonMultipartFileRequest( CommonMultipartFileRequest(
data, data,
listOfNotNull( multipartParts.associateBy { it.fileId }
(pngSticker as? MultipartFile) ?.let { pngStickerField to it },
(tgsSticker as? MultipartFile) ?.let { tgsStickerField to it },
(webmSticker as? MultipartFile) ?.let { webmStickerField to it },
).toMap()
) )
} else { } else {
data data
@ -44,34 +38,67 @@ internal fun CreateNewStickerSet(
} }
@Serializable @Serializable
data class CreateNewStickerSet internal constructor( sealed interface CreateNewStickerSet : CreateStickerSetAction {
val stickerType: StickerType
val stickers: List<InputSticker>
val stickersFormat: StickerFormat
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = "createNewStickerSet"
@Serializable
data class Regular(
@SerialName(userIdField) @SerialName(userIdField)
override val userId: UserId, override val userId: UserId,
@SerialName(nameField) @SerialName(nameField)
override val name: String, override val name: String,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(emojisField) @SerialName(stickerFormatField)
override val emojis: String, override val stickersFormat: StickerFormat,
@SerialName(stickersField)
override val stickers: List<InputSticker.WithKeywords.Regular>
) : CreateNewStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
val stickerType: StickerType = StickerType.Regular, override val stickerType: StickerType
@SerialName(pngStickerField) get() = StickerType.Regular
val pngSticker: FileId? = null,
@SerialName(tgsStickerField)
val tgsSticker: FileId? = null,
@SerialName(webmStickerField)
val webmSticker: FileId? = null,
@SerialName(maskPositionField)
override val maskPosition: MaskPosition? = null
) : CreateStickerSetAction {
init {
if(emojis.isEmpty()) {
throw IllegalArgumentException("Emojis must not be empty")
} }
@Serializable
data class Mask(
@SerialName(userIdField)
override val userId: UserId,
@SerialName(nameField)
override val name: String,
@SerialName(titleField)
override val title: String,
@SerialName(stickerFormatField)
override val stickersFormat: StickerFormat,
@SerialName(stickersField)
override val stickers: List<InputSticker.Mask>
) : CreateNewStickerSet {
@SerialName(stickerTypeField)
override val stickerType: StickerType
get() = StickerType.Mask
}
@Serializable
data class CustomEmoji(
@SerialName(userIdField)
override val userId: UserId,
@SerialName(nameField)
override val name: String,
@SerialName(titleField)
override val title: String,
@SerialName(stickerFormatField)
override val stickersFormat: StickerFormat,
@SerialName(stickersField)
override val stickers: List<InputSticker.WithKeywords.CustomEmoji>,
@SerialName(needsRepaintingField)
val needsRepainting: Boolean? = null
) : CreateNewStickerSet {
@SerialName(stickerTypeField)
override val stickerType: StickerType
get() = StickerType.CustomEmoji
} }
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = "createNewStickerSet"
} }

View File

@ -1,40 +0,0 @@
package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.stickers.MaskPosition
import kotlinx.serialization.*
@Serializable
@Deprecated("Use CreateNewStickerSet class instead")
data class CreateNewVideoStickerSet internal constructor(
@SerialName(userIdField)
override val userId: UserId,
@SerialName(nameField)
override val name: String,
@SerialName(titleField)
override val title: String,
@SerialName(emojisField)
override val emojis: String,
@SerialName(webmStickerField)
val sticker: FileId? = null,
@SerialName(containsMasksField)
@Deprecated("Will be removed soon due to its redundancy")
val containsMasks: Boolean? = null,
@SerialName(maskPositionField)
override val maskPosition: MaskPosition? = null
) : CreateStickerSetAction {
init {
if(emojis.isEmpty()) {
throw IllegalArgumentException("Emojis must not be empty")
}
}
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = "createNewStickerSet"
}

View File

@ -0,0 +1,53 @@
package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.types.emojiListField
import dev.inmo.tgbotapi.types.keywordsField
import dev.inmo.tgbotapi.types.maskPositionField
import dev.inmo.tgbotapi.types.stickerField
import dev.inmo.tgbotapi.types.stickers.MaskPosition
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@ClassCastsIncluded
@Serializable
sealed interface InputSticker {
val sticker: InputFile
val emojisList: List<String>
@Serializable
data class Mask(
@SerialName(stickerField)
override val sticker: InputFile,
@SerialName(emojiListField)
override val emojisList: List<String>,
@SerialName(maskPositionField)
val maskPosition: MaskPosition
) : InputSticker
@Serializable
sealed interface WithKeywords : InputSticker {
val keywords: List<String>
@Serializable
data class Regular(
@SerialName(stickerField)
override val sticker: InputFile,
@SerialName(emojiListField)
override val emojisList: List<String>,
@SerialName(keywordsField)
override val keywords: List<String>
) : WithKeywords
@Serializable
data class CustomEmoji(
@SerialName(stickerField)
override val sticker: InputFile,
@SerialName(emojiListField)
override val emojisList: List<String>,
@SerialName(keywordsField)
override val keywords: List<String>
) : WithKeywords
}
}

View File

@ -1,105 +0,0 @@
package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.StickerType
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.MaskPosition
fun CreateNewRegularStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
StickerType.Regular,
pngSticker = sticker
)
fun CreateNewRegularVideoStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
StickerType.Regular,
webmSticker = sticker
)
fun CreateNewRegularAnimatedStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
StickerType.Regular,
tgsSticker = sticker
)
fun CreateNewMaskStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String,
maskPosition: MaskPosition
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
StickerType.Mask,
pngSticker = sticker,
maskPosition = maskPosition
)
fun CreateNewMaskVideoStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String,
maskPosition: MaskPosition
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
StickerType.Mask,
webmSticker = sticker,
maskPosition = maskPosition
)
fun CreateNewMaskAnimatedStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String,
maskPosition: MaskPosition
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
StickerType.Mask,
tgsSticker = sticker,
maskPosition = maskPosition
)

View File

@ -1,80 +0,0 @@
package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.StickerType
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.MaskPosition
fun CreateNewVideoStickerSet(
userId: UserId,
linkName: String,
title: String,
sticker: InputFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
): Request<Boolean> = CreateNewStickerSet(
userId,
linkName,
title,
emojis,
if (containsMasks == true) StickerType.Mask else StickerType.Regular,
webmSticker = sticker,
maskPosition = maskPosition
)
fun CreateNewStaticStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
if (containsMasks == true) StickerType.Mask else StickerType.Regular,
pngSticker = sticker,
maskPosition = maskPosition
)
fun CreateNewStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
if (containsMasks == true) StickerType.Mask else StickerType.Regular,
pngSticker = sticker,
maskPosition = maskPosition
)
fun CreateNewAnimatedStickerSet(
userId: UserId,
name: String,
title: String,
sticker: InputFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
): Request<Boolean> = CreateNewStickerSet(
userId,
name,
title,
emojis,
if (containsMasks == true) StickerType.Mask else StickerType.Regular,
tgsSticker = sticker,
maskPosition = maskPosition
)

View File

@ -1,5 +1,5 @@
package dev.inmo.tgbotapi.requests.stickers.abstracts package dev.inmo.tgbotapi.requests.stickers.abstracts
interface CreateStickerSetAction : StandardStickerSetAction { interface CreateStickerSetAction : OwnerStickerSetAction {
val title: String val title: String
} }

View File

@ -83,6 +83,38 @@ sealed interface StickerType {
} }
} }
@Serializable(StickerFormat.Serializer::class)
sealed interface StickerFormat {
val type: String
@Serializable
object Static : StickerFormat { override val type: String = "static" }
@Serializable
object Animated : StickerFormat { override val type: String = "animated" }
@Serializable
object Video : StickerFormat { override val type: String = "video" }
@Serializable
data class Unknown(override val type: String = "custom_emoji") : StickerFormat
object Serializer : KSerializer<StickerFormat> {
override val descriptor: SerialDescriptor = String.serializer().descriptor
override fun deserialize(decoder: Decoder): StickerFormat {
return when (val type = decoder.decodeString()) {
Static.type -> Static
Animated.type -> Animated
Video.type -> Video
else -> Unknown(type)
}
}
override fun serialize(encoder: Encoder, value: StickerFormat) {
encoder.encodeString(value.type)
}
}
}
val usernameRegex = Regex("@[\\w\\d_]+") val usernameRegex = Regex("@[\\w\\d_]+")
val degreesLimit = 1 .. 360 val degreesLimit = 1 .. 360
@ -388,6 +420,8 @@ const val webmStickerField = "webm_sticker"
const val oldChatMemberField = "old_chat_member" const val oldChatMemberField = "old_chat_member"
const val newChatMemberField = "new_chat_member" const val newChatMemberField = "new_chat_member"
const val stickerTypeField = "sticker_type" const val stickerTypeField = "sticker_type"
const val stickerFormatField = "sticker_format"
const val needsRepaintingField = "needs_repainting"
const val okField = "ok" const val okField = "ok"
const val captionField = "caption" const val captionField = "caption"

View File

@ -330,6 +330,7 @@ data class MaskVideoSticker(
@Serializable @Serializable
sealed interface CustomEmojiSticker : Sticker { sealed interface CustomEmojiSticker : Sticker {
val customEmojiId: CustomEmojiId val customEmojiId: CustomEmojiId
val needsRepainting: Boolean
} }
@Serializable @Serializable
@ -352,6 +353,8 @@ data class CustomEmojiSimpleSticker(
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(needsRepaintingField)
override val needsRepainting: Boolean = false
) : CustomEmojiSticker ) : CustomEmojiSticker
@Serializable @Serializable
data class CustomEmojiAnimatedSticker( data class CustomEmojiAnimatedSticker(
@ -373,6 +376,8 @@ data class CustomEmojiAnimatedSticker(
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(needsRepaintingField)
override val needsRepainting: Boolean = false,
) : CustomEmojiSticker, AnimatedSticker ) : CustomEmojiSticker, AnimatedSticker
@Serializable @Serializable
data class CustomEmojiVideoSticker( data class CustomEmojiVideoSticker(
@ -394,6 +399,8 @@ data class CustomEmojiVideoSticker(
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(needsRepaintingField)
override val needsRepainting: Boolean = false,
) : CustomEmojiSticker, VideoSticker ) : CustomEmojiSticker, VideoSticker
@Serializable @Serializable

View File

@ -30,7 +30,10 @@ sealed interface StickerSet {
get() = false get() = false
val isVideo: Boolean val isVideo: Boolean
get() = false get() = false
val thumbnail: PhotoSize?
@Deprecated("Renamed in telegram bot api")
val thumb: PhotoSize? val thumb: PhotoSize?
get() = thumbnail
@Deprecated("Will be removed soon due to its redundancy") @Deprecated("Will be removed soon due to its redundancy")
val containsMasks: Boolean val containsMasks: Boolean
get() = this is MaskStickerSet get() = this is MaskStickerSet
@ -146,7 +149,7 @@ data class RegularSimpleStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<RegularSimpleSticker>, override val stickers: List<RegularSimpleSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : RegularStickerSet { ) : RegularStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -162,7 +165,7 @@ data class RegularAnimatedStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<RegularAnimatedSticker>, override val stickers: List<RegularAnimatedSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : RegularStickerSet, AnimatedStickerSet { ) : RegularStickerSet, AnimatedStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -178,7 +181,7 @@ data class RegularVideoStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<RegularVideoSticker>, override val stickers: List<RegularVideoSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : RegularStickerSet, VideoStickerSet { ) : RegularStickerSet, VideoStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -194,7 +197,7 @@ data class MaskSimpleStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<MaskSimpleSticker>, override val stickers: List<MaskSimpleSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : MaskStickerSet { ) : MaskStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -210,7 +213,7 @@ data class MaskAnimatedStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<MaskAnimatedSticker>, override val stickers: List<MaskAnimatedSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : MaskStickerSet, AnimatedStickerSet { ) : MaskStickerSet, AnimatedStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -226,7 +229,7 @@ data class MaskVideoStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<MaskVideoSticker>, override val stickers: List<MaskVideoSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : MaskStickerSet, VideoStickerSet { ) : MaskStickerSet, VideoStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -242,7 +245,7 @@ data class CustomEmojiSimpleStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<CustomEmojiSimpleSticker>, override val stickers: List<CustomEmojiSimpleSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : CustomEmojiStickerSet { ) : CustomEmojiStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -258,7 +261,7 @@ data class CustomEmojiAnimatedStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<CustomEmojiAnimatedSticker>, override val stickers: List<CustomEmojiAnimatedSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : CustomEmojiStickerSet, AnimatedStickerSet { ) : CustomEmojiStickerSet, AnimatedStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -274,7 +277,7 @@ data class CustomEmojiVideoStickerSet(
@SerialName(stickersField) @SerialName(stickersField)
override val stickers: List<CustomEmojiVideoSticker>, override val stickers: List<CustomEmojiVideoSticker>,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null override val thumbnail: PhotoSize? = null
) : CustomEmojiStickerSet, VideoStickerSet { ) : CustomEmojiStickerSet, VideoStickerSet {
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
@EncodeDefault @EncodeDefault
@ -292,6 +295,6 @@ data class UnknownStickerSet(
@SerialName(stickerTypeField) @SerialName(stickerTypeField)
override val stickerType: StickerType, override val stickerType: StickerType,
@SerialName(thumbnailField) @SerialName(thumbnailField)
override val thumb: PhotoSize? = null, override val thumbnail: PhotoSize? = null,
val raw: JsonElement val raw: JsonElement
) : CustomEmojiStickerSet, VideoStickerSet ) : CustomEmojiStickerSet, VideoStickerSet