diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStaticStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStickerSet.kt similarity index 78% rename from tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStaticStickerSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStickerSet.kt index cbd0b41fdb..68ec50773e 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStaticStickerSet.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStickerSet.kt @@ -1,14 +1,11 @@ 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.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.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition suspend fun TelegramBot.createNewStickerSet( userId: UserId, @@ -16,8 +13,9 @@ suspend fun TelegramBot.createNewStickerSet( title: String, stickersFormat: StickerFormat, stickers: List, + needsRepainting: Boolean = false ) = execute( - CreateNewStickerSet(userId, name, title, stickersFormat, stickers) + CreateNewStickerSet(userId, name, title, stickersFormat, stickers, needsRepainting) ) @@ -27,6 +25,7 @@ suspend fun TelegramBot.createNewStickerSet( title: String, stickersFormat: StickerFormat, stickers: List, + needsRepainting: Boolean = false, ) = createNewStickerSet( - user.id, name, title, stickersFormat, stickers + user.id, name, title, stickersFormat, stickers, needsRepainting ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt index 7331e5d109..575dd1fba5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.files import dev.inmo.tgbotapi.requests.abstracts.FileId +import dev.inmo.tgbotapi.requests.stickers.InputSticker import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.stickers.MaskPosition import dev.inmo.tgbotapi.utils.RiskFeature @@ -42,6 +43,8 @@ sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile { get() = false val isVideo get() = false + + fun asInputSticker(emojis: List = emoji ?.let { listOf(it) } ?: error("Unable to create input sticker without emojis")): InputSticker } @OptIn(RiskFeature::class) @@ -206,6 +209,12 @@ sealed interface AnimatedSticker : Sticker { @Serializable sealed interface RegularSticker : Sticker { val premiumAnimationFile: File? + + override fun asInputSticker(emojis: List) = InputSticker.WithKeywords.Regular( + fileId, + emojis, + emptyList() + ) } @Serializable @@ -281,6 +290,12 @@ data class RegularVideoSticker( @Serializable sealed interface MaskSticker : Sticker { val maskPosition: MaskPosition? + + override fun asInputSticker(emojis: List) = InputSticker.Mask( + fileId, + emojis, + maskPosition + ) } @Serializable data class MaskSimpleSticker( @@ -354,6 +369,12 @@ data class MaskVideoSticker( sealed interface CustomEmojiSticker : Sticker { val customEmojiId: CustomEmojiId val needsRepainting: Boolean + + override fun asInputSticker(emojis: List) = InputSticker.WithKeywords.CustomEmoji( + fileId, + emojis, + emptyList() + ) } @Serializable @@ -451,4 +472,10 @@ data class UnknownSticker( @SerialName(stickerFormatField) override val stickerFormat: StickerFormat = StickerFormat.Static, val raw: JsonElement -) : Sticker +) : Sticker { + override fun asInputSticker(emojis: List) = InputSticker.WithKeywords.Regular( + fileId, + emojis, + emptyList() + ) +}