mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
support of new stickers API
This commit is contained in:
parent
5f4a327c2e
commit
84abd006ad
@ -11,11 +11,10 @@ suspend fun TelegramBot.createNewStickerSet(
|
|||||||
userId: UserId,
|
userId: UserId,
|
||||||
name: String,
|
name: String,
|
||||||
title: String,
|
title: String,
|
||||||
stickersFormat: StickerFormat,
|
|
||||||
stickers: List<InputSticker>,
|
stickers: List<InputSticker>,
|
||||||
needsRepainting: Boolean = false
|
needsRepainting: Boolean = false
|
||||||
) = execute(
|
) = execute(
|
||||||
CreateNewStickerSet(userId, name, title, stickersFormat, stickers, needsRepainting)
|
CreateNewStickerSet(userId, name, title, stickers, needsRepainting)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -23,9 +22,8 @@ suspend fun TelegramBot.createNewStickerSet(
|
|||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
name: String,
|
name: String,
|
||||||
title: String,
|
title: String,
|
||||||
stickersFormat: StickerFormat,
|
|
||||||
stickers: List<InputSticker>,
|
stickers: List<InputSticker>,
|
||||||
needsRepainting: Boolean = false,
|
needsRepainting: Boolean = false,
|
||||||
) = createNewStickerSet(
|
) = createNewStickerSet(
|
||||||
user.id, name, title, stickersFormat, stickers, needsRepainting
|
user.id, name, title, stickers, needsRepainting
|
||||||
)
|
)
|
||||||
|
@ -4,6 +4,7 @@ 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.SetStickerSetThumbnail
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail
|
||||||
|
import dev.inmo.tgbotapi.types.StickerFormat
|
||||||
import dev.inmo.tgbotapi.types.StickerSetName
|
import dev.inmo.tgbotapi.types.StickerSetName
|
||||||
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
|
||||||
@ -12,63 +13,71 @@ import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|||||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
stickerSetName: StickerSetName,
|
stickerSetName: StickerSetName,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: FileId
|
thumbnail: FileId
|
||||||
) = execute(
|
) = execute(
|
||||||
SetStickerSetThumbnail(userId, stickerSetName, thumbnail)
|
SetStickerSetThumbnail(userId, stickerSetName, format, thumbnail)
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
stickerSetName: StickerSetName,
|
stickerSetName: StickerSetName,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: MultipartFile
|
thumbnail: MultipartFile
|
||||||
) = execute(
|
) = execute(
|
||||||
SetStickerSetThumbnail(userId, stickerSetName, thumbnail)
|
SetStickerSetThumbnail(userId, stickerSetName, format, thumbnail)
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
stickerSetName: StickerSetName,
|
stickerSetName: StickerSetName,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: FileId
|
thumbnail: FileId
|
||||||
) = setStickerSetThumbnail(
|
) = setStickerSetThumbnail(
|
||||||
user.id, stickerSetName, thumbnail
|
user.id, stickerSetName, format, thumbnail
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
stickerSetName: StickerSetName,
|
stickerSetName: StickerSetName,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: MultipartFile
|
thumbnail: MultipartFile
|
||||||
) = setStickerSetThumbnail(
|
) = setStickerSetThumbnail(
|
||||||
user.id, stickerSetName, thumbnail
|
user.id, stickerSetName, format, thumbnail
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
stickerSet: StickerSet,
|
stickerSet: StickerSet,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: FileId
|
thumbnail: FileId
|
||||||
) = setStickerSetThumbnail(
|
) = setStickerSetThumbnail(
|
||||||
userId, stickerSet.name, thumbnail
|
userId, stickerSet.name, format, thumbnail
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
stickerSet: StickerSet,
|
stickerSet: StickerSet,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: MultipartFile
|
thumbnail: MultipartFile
|
||||||
) = setStickerSetThumbnail(
|
) = setStickerSetThumbnail(
|
||||||
userId, stickerSet.name, thumbnail
|
userId, stickerSet.name, format, thumbnail
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
stickerSet: StickerSet,
|
stickerSet: StickerSet,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: FileId
|
thumbnail: FileId
|
||||||
) = setStickerSetThumbnail(
|
) = setStickerSetThumbnail(
|
||||||
user.id, stickerSet, thumbnail
|
user.id, stickerSet, format, thumbnail
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
stickerSet: StickerSet,
|
stickerSet: StickerSet,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: MultipartFile
|
thumbnail: MultipartFile
|
||||||
) = setStickerSetThumbnail(
|
) = setStickerSetThumbnail(
|
||||||
user.id, stickerSet, thumbnail
|
user.id, stickerSet, format, thumbnail
|
||||||
)
|
)
|
@ -21,14 +21,13 @@ fun CreateNewStickerSet(
|
|||||||
userId: UserId,
|
userId: UserId,
|
||||||
name: StickerSetName,
|
name: StickerSetName,
|
||||||
title: String,
|
title: String,
|
||||||
stickersFormat: StickerFormat,
|
|
||||||
stickers: List<InputSticker>,
|
stickers: List<InputSticker>,
|
||||||
needsRepainting: Boolean? = null
|
needsRepainting: Boolean? = null
|
||||||
): Request<Boolean> {
|
): Request<Boolean> {
|
||||||
val data = when(stickers.first()) {
|
val data = when(stickers.first()) {
|
||||||
is InputSticker.Mask -> CreateNewStickerSet.Mask(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.Mask>())
|
is InputSticker.Mask -> CreateNewStickerSet.Mask(userId, name, title, stickers.filterIsInstance<InputSticker.Mask>())
|
||||||
is InputSticker.WithKeywords.CustomEmoji -> CreateNewStickerSet.CustomEmoji(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.WithKeywords.CustomEmoji>(), needsRepainting)
|
is InputSticker.WithKeywords.CustomEmoji -> CreateNewStickerSet.CustomEmoji(userId, name, title, stickers.filterIsInstance<InputSticker.WithKeywords.CustomEmoji>(), needsRepainting)
|
||||||
is InputSticker.WithKeywords.Regular -> CreateNewStickerSet.Regular(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.WithKeywords.Regular>())
|
is InputSticker.WithKeywords.Regular -> CreateNewStickerSet.Regular(userId, name, title, stickers.filterIsInstance<InputSticker.WithKeywords.Regular>())
|
||||||
}
|
}
|
||||||
val multipartParts = stickers.mapNotNull {
|
val multipartParts = stickers.mapNotNull {
|
||||||
(it.sticker as? MultipartFile)
|
(it.sticker as? MultipartFile)
|
||||||
@ -63,14 +62,12 @@ fun CreateNewStickerSet(
|
|||||||
userId: UserId,
|
userId: UserId,
|
||||||
name: String,
|
name: String,
|
||||||
title: String,
|
title: String,
|
||||||
stickersFormat: StickerFormat,
|
|
||||||
stickers: List<InputSticker>,
|
stickers: List<InputSticker>,
|
||||||
needsRepainting: Boolean? = null
|
needsRepainting: Boolean? = null
|
||||||
) = CreateNewStickerSet(
|
) = CreateNewStickerSet(
|
||||||
userId = userId,
|
userId = userId,
|
||||||
name = StickerSetName(name),
|
name = StickerSetName(name),
|
||||||
title = title,
|
title = title,
|
||||||
stickersFormat = stickersFormat,
|
|
||||||
stickers = stickers,
|
stickers = stickers,
|
||||||
needsRepainting = needsRepainting
|
needsRepainting = needsRepainting
|
||||||
)
|
)
|
||||||
@ -79,7 +76,6 @@ fun CreateNewStickerSet(
|
|||||||
sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
||||||
val stickerType: StickerType
|
val stickerType: StickerType
|
||||||
val stickers: List<InputSticker>
|
val stickers: List<InputSticker>
|
||||||
val stickersFormat: StickerFormat
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
@ -94,8 +90,6 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
|||||||
override val name: StickerSetName,
|
override val name: StickerSetName,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
override val title: String,
|
override val title: String,
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
override val stickersFormat: StickerFormat,
|
|
||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<InputSticker.WithKeywords.Regular>
|
override val stickers: List<InputSticker.WithKeywords.Regular>
|
||||||
) : CreateNewStickerSet {
|
) : CreateNewStickerSet {
|
||||||
@ -111,8 +105,6 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
|||||||
override val name: StickerSetName,
|
override val name: StickerSetName,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
override val title: String,
|
override val title: String,
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
override val stickersFormat: StickerFormat,
|
|
||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<InputSticker.Mask>
|
override val stickers: List<InputSticker.Mask>
|
||||||
) : CreateNewStickerSet {
|
) : CreateNewStickerSet {
|
||||||
@ -128,8 +120,6 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
|||||||
override val name: StickerSetName,
|
override val name: StickerSetName,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
override val title: String,
|
override val title: String,
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
override val stickersFormat: StickerFormat,
|
|
||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<InputSticker.WithKeywords.CustomEmoji>,
|
override val stickers: List<InputSticker.WithKeywords.CustomEmoji>,
|
||||||
@SerialName(needsRepaintingField)
|
@SerialName(needsRepaintingField)
|
||||||
@ -148,8 +138,6 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
|||||||
override val name: StickerSetName,
|
override val name: StickerSetName,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
override val title: String,
|
override val title: String,
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
val stickersFormat: StickerFormat,
|
|
||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
val stickers: List<InputSticker>,
|
val stickers: List<InputSticker>,
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@ -172,7 +160,6 @@ object CreateNewStickerSetSerializer : KSerializer<CreateNewStickerSet>,
|
|||||||
it.userId,
|
it.userId,
|
||||||
it.name,
|
it.name,
|
||||||
it.title,
|
it.title,
|
||||||
it.stickersFormat,
|
|
||||||
it.stickers,
|
it.stickers,
|
||||||
it.stickerType,
|
it.stickerType,
|
||||||
(it as? CreateNewStickerSet.CustomEmoji)?.needsRepainting
|
(it as? CreateNewStickerSet.CustomEmoji)?.needsRepainting
|
||||||
@ -184,7 +171,6 @@ object CreateNewStickerSetSerializer : KSerializer<CreateNewStickerSet>,
|
|||||||
it.userId,
|
it.userId,
|
||||||
it.name,
|
it.name,
|
||||||
it.title,
|
it.title,
|
||||||
it.stickersFormat,
|
|
||||||
it.stickers.filterIsInstance<InputSticker.WithKeywords.CustomEmoji>(),
|
it.stickers.filterIsInstance<InputSticker.WithKeywords.CustomEmoji>(),
|
||||||
it.needsRepainting
|
it.needsRepainting
|
||||||
)
|
)
|
||||||
@ -192,14 +178,12 @@ object CreateNewStickerSetSerializer : KSerializer<CreateNewStickerSet>,
|
|||||||
it.userId,
|
it.userId,
|
||||||
it.name,
|
it.name,
|
||||||
it.title,
|
it.title,
|
||||||
it.stickersFormat,
|
|
||||||
it.stickers.filterIsInstance<InputSticker.Mask>(),
|
it.stickers.filterIsInstance<InputSticker.Mask>(),
|
||||||
)
|
)
|
||||||
StickerType.Regular -> CreateNewStickerSet.Regular(
|
StickerType.Regular -> CreateNewStickerSet.Regular(
|
||||||
it.userId,
|
it.userId,
|
||||||
it.name,
|
it.name,
|
||||||
it.title,
|
it.title,
|
||||||
it.stickersFormat,
|
|
||||||
it.stickers.filterIsInstance<InputSticker.WithKeywords.Regular>(),
|
it.stickers.filterIsInstance<InputSticker.WithKeywords.Regular>(),
|
||||||
)
|
)
|
||||||
is StickerType.Unknown -> error("Unable to create new sticker set due to error in type format: ${it.stickerType}")
|
is StickerType.Unknown -> error("Unable to create new sticker set due to error in type format: ${it.stickerType}")
|
||||||
|
@ -2,11 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.mapper.MapperSerializer
|
import dev.inmo.micro_utils.serialization.mapper.MapperSerializer
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
import dev.inmo.tgbotapi.types.StickerType
|
import dev.inmo.tgbotapi.types.*
|
||||||
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.types.stickers.MaskPosition
|
||||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
@ -17,12 +13,15 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable(InputStickerSerializer::class)
|
@Serializable(InputStickerSerializer::class)
|
||||||
sealed interface InputSticker {
|
sealed interface InputSticker {
|
||||||
val sticker: InputFile
|
val sticker: InputFile
|
||||||
|
val format: StickerFormat
|
||||||
val emojisList: List<String>
|
val emojisList: List<String>
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Mask(
|
data class Mask(
|
||||||
@SerialName(stickerField)
|
@SerialName(stickerField)
|
||||||
override val sticker: InputFile,
|
override val sticker: InputFile,
|
||||||
|
@SerialName(formatField)
|
||||||
|
override val format: StickerFormat,
|
||||||
@SerialName(emojiListField)
|
@SerialName(emojiListField)
|
||||||
override val emojisList: List<String>,
|
override val emojisList: List<String>,
|
||||||
@SerialName(maskPositionField)
|
@SerialName(maskPositionField)
|
||||||
@ -37,6 +36,8 @@ sealed interface InputSticker {
|
|||||||
data class Regular(
|
data class Regular(
|
||||||
@SerialName(stickerField)
|
@SerialName(stickerField)
|
||||||
override val sticker: InputFile,
|
override val sticker: InputFile,
|
||||||
|
@SerialName(formatField)
|
||||||
|
override val format: StickerFormat,
|
||||||
@SerialName(emojiListField)
|
@SerialName(emojiListField)
|
||||||
override val emojisList: List<String>,
|
override val emojisList: List<String>,
|
||||||
@SerialName(keywordsField)
|
@SerialName(keywordsField)
|
||||||
@ -47,6 +48,8 @@ sealed interface InputSticker {
|
|||||||
data class CustomEmoji(
|
data class CustomEmoji(
|
||||||
@SerialName(stickerField)
|
@SerialName(stickerField)
|
||||||
override val sticker: InputFile,
|
override val sticker: InputFile,
|
||||||
|
@SerialName(formatField)
|
||||||
|
override val format: StickerFormat,
|
||||||
@SerialName(emojiListField)
|
@SerialName(emojiListField)
|
||||||
override val emojisList: List<String>,
|
override val emojisList: List<String>,
|
||||||
@SerialName(keywordsField)
|
@SerialName(keywordsField)
|
||||||
@ -61,6 +64,7 @@ object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<Inpu
|
|||||||
when (it) {
|
when (it) {
|
||||||
is InputSticker.Mask -> SurrogateInputSticker(
|
is InputSticker.Mask -> SurrogateInputSticker(
|
||||||
it.sticker,
|
it.sticker,
|
||||||
|
it.format,
|
||||||
it.emojisList,
|
it.emojisList,
|
||||||
emptyList(),
|
emptyList(),
|
||||||
it.maskPosition,
|
it.maskPosition,
|
||||||
@ -68,6 +72,7 @@ object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<Inpu
|
|||||||
)
|
)
|
||||||
is InputSticker.WithKeywords.CustomEmoji -> SurrogateInputSticker(
|
is InputSticker.WithKeywords.CustomEmoji -> SurrogateInputSticker(
|
||||||
it.sticker,
|
it.sticker,
|
||||||
|
it.format,
|
||||||
it.emojisList,
|
it.emojisList,
|
||||||
it.keywords,
|
it.keywords,
|
||||||
null,
|
null,
|
||||||
@ -75,6 +80,7 @@ object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<Inpu
|
|||||||
)
|
)
|
||||||
is InputSticker.WithKeywords.Regular -> SurrogateInputSticker(
|
is InputSticker.WithKeywords.Regular -> SurrogateInputSticker(
|
||||||
it.sticker,
|
it.sticker,
|
||||||
|
it.format,
|
||||||
it.emojisList,
|
it.emojisList,
|
||||||
it.keywords,
|
it.keywords,
|
||||||
null,
|
null,
|
||||||
@ -86,21 +92,25 @@ object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<Inpu
|
|||||||
when (it.internalType) {
|
when (it.internalType) {
|
||||||
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||||
it.sticker,
|
it.sticker,
|
||||||
|
it.format,
|
||||||
it.emojisList,
|
it.emojisList,
|
||||||
it.keywords
|
it.keywords
|
||||||
)
|
)
|
||||||
StickerType.Mask -> InputSticker.Mask(
|
StickerType.Mask -> InputSticker.Mask(
|
||||||
it.sticker,
|
it.sticker,
|
||||||
|
it.format,
|
||||||
it.emojisList,
|
it.emojisList,
|
||||||
it.maskPosition
|
it.maskPosition
|
||||||
)
|
)
|
||||||
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
||||||
it.sticker,
|
it.sticker,
|
||||||
|
it.format,
|
||||||
it.emojisList,
|
it.emojisList,
|
||||||
it.keywords
|
it.keywords
|
||||||
)
|
)
|
||||||
is StickerType.Unknown -> InputSticker.WithKeywords.Regular(
|
is StickerType.Unknown -> InputSticker.WithKeywords.Regular(
|
||||||
it.sticker,
|
it.sticker,
|
||||||
|
it.format,
|
||||||
it.emojisList,
|
it.emojisList,
|
||||||
it.keywords
|
it.keywords
|
||||||
)
|
)
|
||||||
@ -111,6 +121,8 @@ object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<Inpu
|
|||||||
data class SurrogateInputSticker internal constructor(
|
data class SurrogateInputSticker internal constructor(
|
||||||
@SerialName(stickerField)
|
@SerialName(stickerField)
|
||||||
val sticker: InputFile,
|
val sticker: InputFile,
|
||||||
|
@SerialName(formatField)
|
||||||
|
val format: StickerFormat,
|
||||||
@SerialName(emojiListField)
|
@SerialName(emojiListField)
|
||||||
val emojisList: List<String>,
|
val emojisList: List<String>,
|
||||||
@SerialName(keywordsField)
|
@SerialName(keywordsField)
|
||||||
|
@ -9,10 +9,11 @@ import kotlinx.serialization.*
|
|||||||
fun SetStickerSetThumbnail(
|
fun SetStickerSetThumbnail(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
stickerSetName: StickerSetName,
|
stickerSetName: StickerSetName,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: MultipartFile
|
thumbnail: MultipartFile
|
||||||
): Request<Boolean> {
|
): Request<Boolean> {
|
||||||
return CommonMultipartFileRequest(
|
return CommonMultipartFileRequest(
|
||||||
SetStickerSetThumbnail(userId, stickerSetName),
|
SetStickerSetThumbnail(userId, stickerSetName, format),
|
||||||
mapOf(thumbnailField to thumbnail)
|
mapOf(thumbnailField to thumbnail)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -20,10 +21,12 @@ fun SetStickerSetThumbnail(
|
|||||||
fun SetStickerSetThumbnail(
|
fun SetStickerSetThumbnail(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
stickerSetName: String,
|
stickerSetName: String,
|
||||||
|
format: StickerFormat,
|
||||||
thumbnail: MultipartFile
|
thumbnail: MultipartFile
|
||||||
): Request<Boolean> = SetStickerSetThumbnail(
|
): Request<Boolean> = SetStickerSetThumbnail(
|
||||||
userId = userId,
|
userId = userId,
|
||||||
stickerSetName = StickerSetName(stickerSetName),
|
stickerSetName = StickerSetName(stickerSetName, ),
|
||||||
|
format = format,
|
||||||
thumbnail = thumbnail
|
thumbnail = thumbnail
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,6 +36,8 @@ data class SetStickerSetThumbnail (
|
|||||||
override val userId: UserId,
|
override val userId: UserId,
|
||||||
@SerialName(nameField)
|
@SerialName(nameField)
|
||||||
override val name: StickerSetName,
|
override val name: StickerSetName,
|
||||||
|
@SerialName(formatField)
|
||||||
|
val format: StickerFormat,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
val thumbnail: FileId? = null
|
val thumbnail: FileId? = null
|
||||||
) : OwnerStickerSetAction {
|
) : OwnerStickerSetAction {
|
||||||
|
@ -379,6 +379,7 @@ 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 stickerFormatField = "sticker_format"
|
||||||
|
const val formatField = "format"
|
||||||
const val needsRepaintingField = "needs_repainting"
|
const val needsRepaintingField = "needs_repainting"
|
||||||
|
|
||||||
const val okField = "ok"
|
const val okField = "ok"
|
||||||
|
@ -25,12 +25,7 @@ sealed interface StickerSet {
|
|||||||
val name: StickerSetName
|
val name: StickerSetName
|
||||||
val title: String
|
val title: String
|
||||||
val stickerType: StickerType
|
val stickerType: StickerType
|
||||||
val stickerFormat: StickerFormat
|
|
||||||
val stickers: List<Sticker>
|
val stickers: List<Sticker>
|
||||||
val isAnimated: Boolean
|
|
||||||
get() = false
|
|
||||||
val isVideo: Boolean
|
|
||||||
get() = false
|
|
||||||
val thumbnail: PhotoSize?
|
val thumbnail: PhotoSize?
|
||||||
|
|
||||||
object Serializer : KSerializer<StickerSet> {
|
object Serializer : KSerializer<StickerSet> {
|
||||||
@ -42,69 +37,33 @@ sealed interface StickerSet {
|
|||||||
|
|
||||||
return when (surrogate.sticker_type) {
|
return when (surrogate.sticker_type) {
|
||||||
StickerType.CustomEmoji -> when {
|
StickerType.CustomEmoji -> when {
|
||||||
surrogate.is_animated == true -> CustomEmojiAnimatedStickerSet(
|
else -> CustomEmojiStickerSet(
|
||||||
surrogate.name,
|
surrogate.name,
|
||||||
surrogate.title,
|
surrogate.title,
|
||||||
surrogate.stickers.filterIsInstance<CustomEmojiAnimatedSticker>(),
|
surrogate.stickers.filterIsInstance<CustomEmojiSticker>(),
|
||||||
surrogate.thumb
|
|
||||||
)
|
|
||||||
surrogate.is_video == true -> CustomEmojiVideoStickerSet(
|
|
||||||
surrogate.name,
|
|
||||||
surrogate.title,
|
|
||||||
surrogate.stickers.filterIsInstance<CustomEmojiVideoSticker>(),
|
|
||||||
surrogate.thumb
|
|
||||||
)
|
|
||||||
else -> CustomEmojiSimpleStickerSet(
|
|
||||||
surrogate.name,
|
|
||||||
surrogate.title,
|
|
||||||
surrogate.stickers.filterIsInstance<CustomEmojiSimpleSticker>(),
|
|
||||||
surrogate.thumb
|
surrogate.thumb
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
StickerType.Mask -> when {
|
StickerType.Mask -> when {
|
||||||
surrogate.is_animated == true -> MaskAnimatedStickerSet(
|
else -> MaskStickerSet(
|
||||||
surrogate.name,
|
surrogate.name,
|
||||||
surrogate.title,
|
surrogate.title,
|
||||||
surrogate.stickers.filterIsInstance<MaskAnimatedSticker>(),
|
surrogate.stickers.filterIsInstance<MaskSticker>(),
|
||||||
surrogate.thumb
|
|
||||||
)
|
|
||||||
surrogate.is_video == true -> MaskVideoStickerSet(
|
|
||||||
surrogate.name,
|
|
||||||
surrogate.title,
|
|
||||||
surrogate.stickers.filterIsInstance<MaskVideoSticker>(),
|
|
||||||
surrogate.thumb
|
|
||||||
)
|
|
||||||
else -> MaskSimpleStickerSet(
|
|
||||||
surrogate.name,
|
|
||||||
surrogate.title,
|
|
||||||
surrogate.stickers.filterIsInstance<MaskSimpleSticker>(),
|
|
||||||
surrogate.thumb
|
surrogate.thumb
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
StickerType.Regular -> when {
|
StickerType.Regular -> when {
|
||||||
surrogate.is_animated == true -> RegularAnimatedStickerSet(
|
else -> RegularStickerSet(
|
||||||
surrogate.name,
|
surrogate.name,
|
||||||
surrogate.title,
|
surrogate.title,
|
||||||
surrogate.stickers.filterIsInstance<RegularAnimatedSticker>(),
|
surrogate.stickers.filterIsInstance<RegularSticker>(),
|
||||||
surrogate.thumb
|
|
||||||
)
|
|
||||||
surrogate.is_video == true -> RegularVideoStickerSet(
|
|
||||||
surrogate.name,
|
|
||||||
surrogate.title,
|
|
||||||
surrogate.stickers.filterIsInstance<RegularVideoSticker>(),
|
|
||||||
surrogate.thumb
|
|
||||||
)
|
|
||||||
else -> RegularSimpleStickerSet(
|
|
||||||
surrogate.name,
|
|
||||||
surrogate.title,
|
|
||||||
surrogate.stickers.filterIsInstance<RegularSimpleSticker>(),
|
|
||||||
surrogate.thumb
|
surrogate.thumb
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is StickerType.Unknown -> UnknownStickerSet(
|
is StickerType.Unknown -> UnknownStickerSet(
|
||||||
surrogate.name,
|
surrogate.name,
|
||||||
surrogate.title,
|
surrogate.title,
|
||||||
surrogate.stickers.filterIsInstance<RegularSimpleSticker>(),
|
surrogate.stickers.filterIsInstance<RegularSticker>(),
|
||||||
surrogate.sticker_type,
|
surrogate.sticker_type,
|
||||||
surrogate.thumb,
|
surrogate.thumb,
|
||||||
json
|
json
|
||||||
@ -119,180 +78,48 @@ sealed interface StickerSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed interface AnimatedStickerSet : StickerSet {
|
data class RegularStickerSet(
|
||||||
override val isAnimated: Boolean
|
|
||||||
get() = true
|
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerFormat: StickerFormat
|
|
||||||
get() = StickerFormat.Animated
|
|
||||||
}
|
|
||||||
@Serializable
|
|
||||||
sealed interface VideoStickerSet : StickerSet {
|
|
||||||
override val isVideo: Boolean
|
|
||||||
get() = true
|
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerFormat: StickerFormat
|
|
||||||
get() = StickerFormat.Video
|
|
||||||
}
|
|
||||||
@Serializable
|
|
||||||
sealed interface RegularStickerSet : StickerSet
|
|
||||||
@Serializable
|
|
||||||
sealed interface MaskStickerSet : StickerSet
|
|
||||||
@Serializable
|
|
||||||
sealed interface CustomEmojiStickerSet : StickerSet
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class RegularSimpleStickerSet(
|
|
||||||
@SerialName(nameField)
|
@SerialName(nameField)
|
||||||
override val name: StickerSetName,
|
override val name: StickerSetName,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
override val title: String,
|
override val title: String,
|
||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<RegularSimpleSticker>,
|
override val stickers: List<RegularSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : RegularStickerSet {
|
) : StickerSet {
|
||||||
@SerialName(stickerTypeField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerType: StickerType = StickerType.Regular
|
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerFormat: StickerFormat = StickerFormat.Static
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class RegularAnimatedStickerSet(
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: StickerSetName,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(stickersField)
|
|
||||||
override val stickers: List<RegularAnimatedSticker>,
|
|
||||||
@SerialName(thumbnailField)
|
|
||||||
override val thumbnail: PhotoSize? = null
|
|
||||||
) : RegularStickerSet, AnimatedStickerSet {
|
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val stickerType: StickerType = StickerType.Regular
|
override val stickerType: StickerType = StickerType.Regular
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RegularVideoStickerSet(
|
data class MaskStickerSet(
|
||||||
@SerialName(nameField)
|
@SerialName(nameField)
|
||||||
override val name: StickerSetName,
|
override val name: StickerSetName,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
override val title: String,
|
override val title: String,
|
||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<RegularVideoSticker>,
|
override val stickers: List<MaskSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : RegularStickerSet, VideoStickerSet {
|
) : StickerSet {
|
||||||
@SerialName(stickerTypeField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerType: StickerType = StickerType.Regular
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class MaskSimpleStickerSet(
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: StickerSetName,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(stickersField)
|
|
||||||
override val stickers: List<MaskSimpleSticker>,
|
|
||||||
@SerialName(thumbnailField)
|
|
||||||
override val thumbnail: PhotoSize? = null
|
|
||||||
) : MaskStickerSet {
|
|
||||||
@SerialName(stickerTypeField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerType: StickerType = StickerType.Mask
|
|
||||||
|
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerFormat: StickerFormat = StickerFormat.Static
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class MaskAnimatedStickerSet(
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: StickerSetName,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(stickersField)
|
|
||||||
override val stickers: List<MaskAnimatedSticker>,
|
|
||||||
@SerialName(thumbnailField)
|
|
||||||
override val thumbnail: PhotoSize? = null
|
|
||||||
) : MaskStickerSet, AnimatedStickerSet {
|
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val stickerType: StickerType = StickerType.Mask
|
override val stickerType: StickerType = StickerType.Mask
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MaskVideoStickerSet(
|
data class CustomEmojiStickerSet(
|
||||||
@SerialName(nameField)
|
@SerialName(nameField)
|
||||||
override val name: StickerSetName,
|
override val name: StickerSetName,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
override val title: String,
|
override val title: String,
|
||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<MaskVideoSticker>,
|
override val stickers: List<CustomEmojiSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : MaskStickerSet, VideoStickerSet {
|
) : StickerSet {
|
||||||
@SerialName(stickerTypeField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerType: StickerType = StickerType.Mask
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class CustomEmojiSimpleStickerSet(
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: StickerSetName,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(stickersField)
|
|
||||||
override val stickers: List<CustomEmojiSimpleSticker>,
|
|
||||||
@SerialName(thumbnailField)
|
|
||||||
override val thumbnail: PhotoSize? = null
|
|
||||||
) : CustomEmojiStickerSet {
|
|
||||||
@SerialName(stickerTypeField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerType: StickerType = StickerType.CustomEmoji
|
|
||||||
|
|
||||||
@SerialName(stickerFormatField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerFormat: StickerFormat = StickerFormat.Static
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class CustomEmojiAnimatedStickerSet(
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: StickerSetName,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(stickersField)
|
|
||||||
override val stickers: List<CustomEmojiAnimatedSticker>,
|
|
||||||
@SerialName(thumbnailField)
|
|
||||||
override val thumbnail: PhotoSize? = null
|
|
||||||
) : CustomEmojiStickerSet, AnimatedStickerSet {
|
|
||||||
@SerialName(stickerTypeField)
|
|
||||||
@EncodeDefault
|
|
||||||
override val stickerType: StickerType = StickerType.CustomEmoji
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class CustomEmojiVideoStickerSet(
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: StickerSetName,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(stickersField)
|
|
||||||
override val stickers: List<CustomEmojiVideoSticker>,
|
|
||||||
@SerialName(thumbnailField)
|
|
||||||
override val thumbnail: PhotoSize? = null
|
|
||||||
) : CustomEmojiStickerSet, VideoStickerSet {
|
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val stickerType: StickerType = StickerType.CustomEmoji
|
override val stickerType: StickerType = StickerType.CustomEmoji
|
||||||
@ -311,4 +138,4 @@ data class UnknownStickerSet(
|
|||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: PhotoSize? = null,
|
override val thumbnail: PhotoSize? = null,
|
||||||
val raw: JsonElement
|
val raw: JsonElement
|
||||||
) : CustomEmojiStickerSet, VideoStickerSet
|
) : StickerSet
|
||||||
|
Loading…
Reference in New Issue
Block a user