From fba6707f44e1bf0b0ce3e996c7d413f09362474f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 1 Feb 2022 17:59:23 +0600 Subject: [PATCH] fixes in create sticker set methods --- .../api/stickers/CreateNewAnimatedStickerSet.kt | 12 ++++++++---- .../api/stickers/CreateNewStaticStickerSet.kt | 12 ++++++++---- .../api/stickers/CreateNewVideoStickerSet.kt | 12 ++++++++---- .../requests/stickers/CreateNewAnimatedStickerSet.kt | 8 ++++++-- .../requests/stickers/CreateNewStaticStickerSet.kt | 11 ++++++++--- .../requests/stickers/CreateNewVideoStickerSet.kt | 10 +++++++--- .../stickers/abstracts/CreateStickerSetAction.kt | 5 +++++ 7 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/CreateStickerSetAction.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt index c5bf76b6f3..4678ad058f 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt @@ -11,44 +11,48 @@ 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, sticker, emojis, containsMasks, maskPosition) + 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, sticker, emojis, containsMasks, maskPosition) + 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, sticker, emojis, containsMasks, maskPosition + 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, sticker, emojis, containsMasks, maskPosition + user.id, name, title, sticker, emojis, containsMasks, maskPosition ) 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/CreateNewStaticStickerSet.kt index be70b86597..0622223b81 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/CreateNewStaticStickerSet.kt @@ -11,44 +11,48 @@ import dev.inmo.tgbotapi.types.stickers.MaskPosition suspend fun TelegramBot.createNewStaticStickerSet( userId: UserId, name: String, + title: String, sticker: FileId, emojis: String, containsMasks: Boolean? = null, maskPosition: MaskPosition? = null ) = execute( - CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) + CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition) ) suspend fun TelegramBot.createNewStaticStickerSet( userId: UserId, name: String, + title: String, sticker: MultipartFile, emojis: String, containsMasks: Boolean? = null, maskPosition: MaskPosition? = null ) = execute( - CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) + CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition) ) suspend fun TelegramBot.createNewStaticStickerSet( user: CommonUser, name: String, + title: String, sticker: FileId, emojis: String, containsMasks: Boolean? = null, maskPosition: MaskPosition? = null ) = createNewStaticStickerSet( - user.id, name, sticker, emojis, containsMasks, maskPosition + 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, sticker, emojis, containsMasks, maskPosition + user.id, name, title, sticker, emojis, containsMasks, maskPosition ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewVideoStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewVideoStickerSet.kt index 805285a1ea..0f8f8dd0a5 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewVideoStickerSet.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewVideoStickerSet.kt @@ -11,44 +11,48 @@ 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, sticker, emojis, containsMasks, maskPosition) + 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, sticker, emojis, containsMasks, maskPosition) + 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, sticker, emojis, containsMasks, maskPosition + 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, sticker, emojis, containsMasks, maskPosition + user.id, name, title, sticker, emojis, containsMasks, maskPosition ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewAnimatedStickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewAnimatedStickerSet.kt index 08aa78a3ec..c2d58f715a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewAnimatedStickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewAnimatedStickerSet.kt @@ -2,6 +2,7 @@ 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 @@ -10,12 +11,13 @@ import kotlinx.serialization.* fun CreateNewAnimatedStickerSet( userId: UserId, name: String, + title: String, sticker: InputFile, emojis: String, containsMasks: Boolean? = null, maskPosition: MaskPosition? = null ): Request { - val data = CreateNewAnimatedStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition) + val data = CreateNewAnimatedStickerSet(userId, name, title, emojis, sticker as? FileId, containsMasks, maskPosition) return when (sticker) { is MultipartFile -> CommonMultipartFileRequest( data, @@ -31,6 +33,8 @@ data class CreateNewAnimatedStickerSet internal constructor( override val userId: UserId, @SerialName(nameField) override val name: String, + @SerialName(titleField) + override val title: String, @SerialName(emojisField) override val emojis: String, @SerialName(tgsStickerField) @@ -39,7 +43,7 @@ data class CreateNewAnimatedStickerSet internal constructor( val containsMasks: Boolean? = null, @SerialName(maskPositionField) override val maskPosition: MaskPosition? = null -) : StandardStickerSetAction { +) : CreateStickerSetAction { init { if(emojis.isEmpty()) { throw IllegalArgumentException("Emojis must not be empty") diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStaticStickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStaticStickerSet.kt index 97c92583ea..85b0d5a514 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStaticStickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStaticStickerSet.kt @@ -2,6 +2,7 @@ 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 @@ -10,12 +11,13 @@ import kotlinx.serialization.* fun CreateNewStaticStickerSet( userId: UserId, name: String, + title: String, sticker: InputFile, emojis: String, containsMasks: Boolean? = null, maskPosition: MaskPosition? = null ): Request { - val data = CreateNewStaticStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition) + val data = CreateNewStaticStickerSet(userId, name, title, emojis, sticker as? FileId, containsMasks, maskPosition) return when (sticker) { is MultipartFile -> CommonMultipartFileRequest( data, @@ -28,11 +30,12 @@ fun CreateNewStaticStickerSet( fun CreateNewStickerSet( userId: UserId, name: String, + title: String, sticker: InputFile, emojis: String, containsMasks: Boolean? = null, maskPosition: MaskPosition? = null -): Request = CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) +): Request = CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition) @Serializable data class CreateNewStaticStickerSet internal constructor( @@ -40,6 +43,8 @@ data class CreateNewStaticStickerSet internal constructor( override val userId: UserId, @SerialName(nameField) override val name: String, + @SerialName(titleField) + override val title: String, @SerialName(emojisField) override val emojis: String, @SerialName(pngStickerField) @@ -48,7 +53,7 @@ data class CreateNewStaticStickerSet internal constructor( val containsMasks: Boolean? = null, @SerialName(maskPositionField) override val maskPosition: MaskPosition? = null -) : StandardStickerSetAction { +) : CreateStickerSetAction { init { if(emojis.isEmpty()) { throw IllegalArgumentException("Emojis must not be empty") diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewVideoStickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewVideoStickerSet.kt index d05c6ad3b1..0ba64a025c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewVideoStickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewVideoStickerSet.kt @@ -2,6 +2,7 @@ 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 @@ -9,13 +10,14 @@ import kotlinx.serialization.* fun CreateNewVideoStickerSet( userId: UserId, - name: String, + linkName: String, + title: String, sticker: InputFile, emojis: String, containsMasks: Boolean? = null, maskPosition: MaskPosition? = null ): Request { - val data = CreateNewVideoStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition) + val data = CreateNewVideoStickerSet(userId, linkName, title, emojis, sticker as? FileId, containsMasks, maskPosition) return when (sticker) { is MultipartFile -> CommonMultipartFileRequest( data, @@ -31,6 +33,8 @@ data class CreateNewVideoStickerSet internal constructor( override val userId: UserId, @SerialName(nameField) override val name: String, + @SerialName(titleField) + override val title: String, @SerialName(emojisField) override val emojis: String, @SerialName(webmStickerField) @@ -39,7 +43,7 @@ data class CreateNewVideoStickerSet internal constructor( val containsMasks: Boolean? = null, @SerialName(maskPositionField) override val maskPosition: MaskPosition? = null -) : StandardStickerSetAction { +) : CreateStickerSetAction { init { if(emojis.isEmpty()) { throw IllegalArgumentException("Emojis must not be empty") diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/CreateStickerSetAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/CreateStickerSetAction.kt new file mode 100644 index 0000000000..31091c0592 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/CreateStickerSetAction.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.requests.stickers.abstracts + +interface CreateStickerSetAction : StandardStickerSetAction { + val title: String +}