From ac88fd1d0282fb7566abe9df141c6505b3509735 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 00:23:16 +0600 Subject: [PATCH 01/28] start 6.2.0 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3490340bd8..a70e7be7b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 6.2.0 + ## 6.1.0 * `Versions`: diff --git a/gradle.properties b/gradle.properties index 9c2d8b6297..c8e186f7b8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=6.1.0 +library_version=6.2.0 From a0aadef31bad6a6af66a3befd01ff2b5dc0dd98b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 00:34:57 +0600 Subject: [PATCH 02/28] add support of localized bot description --- .../extensions/api/bot/GetMyDescription.kt | 16 ++++++++++++ .../api/bot/GetMyShortDescription.kt | 16 ++++++++++++ .../extensions/api/bot/SetMyDescription.kt | 19 ++++++++++++++ .../api/bot/SetMyShortDescription.kt | 15 +++++++++++ .../tgbotapi/requests/bot/GetMyDescription.kt | 23 +++++++++++++++++ .../requests/bot/GetMyShortDescription.kt | 23 +++++++++++++++++ .../tgbotapi/requests/bot/SetMyDescription.kt | 25 +++++++++++++++++++ .../requests/bot/SetMyShortDescription.kt | 25 +++++++++++++++++++ .../dev/inmo/tgbotapi/types/BotDescription.kt | 10 ++++++++ .../tgbotapi/types/BotShortDescription.kt | 10 ++++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + 11 files changed, 183 insertions(+) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyDescription.kt create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyShortDescription.kt create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyDescription.kt create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescription.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyDescription.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyShortDescription.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDescription.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyShortDescription.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotDescription.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotShortDescription.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyDescription.kt new file mode 100644 index 0000000000..acb3288ed2 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyDescription.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.extensions.api.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.bot.GetMyCommands +import dev.inmo.tgbotapi.requests.bot.GetMyDescription +import dev.inmo.tgbotapi.types.commands.BotCommandScope +import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault + +suspend fun TelegramBot.getMyDescription( + languageCode: IetfLanguageCode? = null +) = execute(GetMyDescription(languageCode)) + +suspend fun TelegramBot.getMyDescription( + languageCode: String? +) = getMyDescription(languageCode ?.let(::IetfLanguageCode)) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyShortDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyShortDescription.kt new file mode 100644 index 0000000000..bfebfef460 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyShortDescription.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.extensions.api.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.bot.GetMyCommands +import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription +import dev.inmo.tgbotapi.types.commands.BotCommandScope +import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault + +suspend fun TelegramBot.getMyShortDescription( + languageCode: IetfLanguageCode? = null +) = execute(GetMyShortDescription(languageCode)) + +suspend fun TelegramBot.getMyShortDescription( + languageCode: String? +) = getMyShortDescription(languageCode ?.let(::IetfLanguageCode)) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyDescription.kt new file mode 100644 index 0000000000..370ca5a9a7 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyDescription.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.extensions.api.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.bot.GetMyCommands +import dev.inmo.tgbotapi.requests.bot.GetMyDescription +import dev.inmo.tgbotapi.requests.bot.SetMyDescription +import dev.inmo.tgbotapi.types.commands.BotCommandScope +import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault + +suspend fun TelegramBot.setMyDescription( + description: String? = null, + languageCode: IetfLanguageCode? = null +) = execute(SetMyDescription(description, languageCode)) + +suspend fun TelegramBot.setMyDescription( + description: String?, + languageCode: String? +) = setMyDescription(description, languageCode ?.let(::IetfLanguageCode)) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescription.kt new file mode 100644 index 0000000000..2fcc869793 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescription.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.extensions.api.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription + +suspend fun TelegramBot.setMyShortDescription( + shortDescription: String? = null, + languageCode: IetfLanguageCode? = null +) = execute(SetMyShortDescription(shortDescription, languageCode)) + +suspend fun TelegramBot.setMyShortDescription( + shortDescription: String?, + languageCode: String? +) = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLanguageCode)) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyDescription.kt new file mode 100644 index 0000000000..fc971d3ea2 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyDescription.kt @@ -0,0 +1,23 @@ +package dev.inmo.tgbotapi.requests.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.types.commands.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +class GetMyDescription( + @SerialName(languageCodeField) + @Serializable(IetfLanguageCodeSerializer::class) + override val ietfLanguageCode: IetfLanguageCode? = null +) : SimpleRequest, WithOptionalLanguageCode { + override fun method(): String = "getMyDescription" + override val resultDeserializer: DeserializationStrategy + get() = BotDescription.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyShortDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyShortDescription.kt new file mode 100644 index 0000000000..c12ff05551 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyShortDescription.kt @@ -0,0 +1,23 @@ +package dev.inmo.tgbotapi.requests.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.types.commands.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +class GetMyShortDescription( + @SerialName(languageCodeField) + @Serializable(IetfLanguageCodeSerializer::class) + override val ietfLanguageCode: IetfLanguageCode? = null +) : SimpleRequest, WithOptionalLanguageCode { + override fun method(): String = "getMyShortDescription" + override val resultDeserializer: DeserializationStrategy + get() = BotShortDescription.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDescription.kt new file mode 100644 index 0000000000..f0ce0520c9 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDescription.kt @@ -0,0 +1,25 @@ +package dev.inmo.tgbotapi.requests.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.types.commands.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +class SetMyDescription( + @SerialName(descriptionField) + val description: String? = null, + @SerialName(languageCodeField) + @Serializable(IetfLanguageCodeSerializer::class) + override val ietfLanguageCode: IetfLanguageCode? = null +) : SimpleRequest, WithOptionalLanguageCode { + override fun method(): String = "setMyDescription" + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyShortDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyShortDescription.kt new file mode 100644 index 0000000000..1a11061860 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyShortDescription.kt @@ -0,0 +1,25 @@ +package dev.inmo.tgbotapi.requests.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.types.commands.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +class SetMyShortDescription( + @SerialName(shortDescriptionField) + val shortDescription: String? = null, + @SerialName(languageCodeField) + @Serializable(IetfLanguageCodeSerializer::class) + override val ietfLanguageCode: IetfLanguageCode? = null +) : SimpleRequest, WithOptionalLanguageCode { + override fun method(): String = "setMyShortDescription" + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotDescription.kt new file mode 100644 index 0000000000..d94fae277d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotDescription.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class BotDescription( + @SerialName(descriptionField) + val description: String +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotShortDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotShortDescription.kt new file mode 100644 index 0000000000..3ecbcf8b3d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotShortDescription.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class BotShortDescription( + @SerialName(shortDescriptionField) + val shortDescription: String +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 4dada53823..051774ede9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -385,6 +385,7 @@ const val emojiField = "emoji" const val emojisField = "emojis" const val titleField = "title" const val descriptionField = "description" +const val shortDescriptionField = "short_description" const val performerField = "performer" const val durationField = "duration" const val widthField = "width" From a9725eb439ab3ead3d965a31b6985756b65544d6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 11:16:13 +0600 Subject: [PATCH 03/28] add support of setStickerSetTitle --- .../api/stickers/SetStickerSetTitle.kt | 22 +++++++++++++++++++ .../requests/stickers/SetStickerSetThumb.kt | 3 ++- .../requests/stickers/SetStickerSetTitle.kt | 20 +++++++++++++++++ .../abstracts/OwnerStickerSetAction.kt | 11 ++++++++++ .../abstracts/StandardStickerSetAction.kt | 4 ++-- .../stickers/abstracts/StickerSetAction.kt | 6 ++--- 6 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetTitle.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetTitle.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/OwnerStickerSetAction.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetTitle.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetTitle.kt new file mode 100644 index 0000000000..dea01e2f61 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetTitle.kt @@ -0,0 +1,22 @@ +package dev.inmo.tgbotapi.extensions.api.stickers + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.stickers.SetStickerSetTitle +import dev.inmo.tgbotapi.types.StickerSetName +import dev.inmo.tgbotapi.types.files.Sticker +import dev.inmo.tgbotapi.types.stickers.StickerSet + +suspend fun TelegramBot.setStickerSetTitle( + name: StickerSetName, + title: String +) = execute(SetStickerSetTitle(name, title)) + +suspend fun TelegramBot.setStickerSetTitle( + sticker: Sticker, + title: String +) = setStickerSetTitle(sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker"), title) + +suspend fun TelegramBot.setStickerSetTitle( + stickerSet: StickerSet, + title: String +) = setStickerSetTitle(stickerSet.name, title) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt index 7f5d960383..a35f2a2b87 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.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.OwnerStickerSetAction import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction import dev.inmo.tgbotapi.types.* import kotlinx.serialization.* @@ -25,7 +26,7 @@ data class SetStickerSetThumb ( override val name: StickerSetName, @SerialName(thumbField) val thumb: FileId? = null -) : StickerSetAction { +) : OwnerStickerSetAction { override val requestSerializer: SerializationStrategy<*> get() = serializer() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetTitle.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetTitle.kt new file mode 100644 index 0000000000..ab042b8122 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetTitle.kt @@ -0,0 +1,20 @@ +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.StickerSetAction +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* + +@Serializable +data class SetStickerSetTitle ( + @SerialName(nameField) + override val name: StickerSetName, + @SerialName(titleField) + val title: String +) : StickerSetAction { + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "setStickerSetTitle" +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/OwnerStickerSetAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/OwnerStickerSetAction.kt new file mode 100644 index 0000000000..2984e740f9 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/OwnerStickerSetAction.kt @@ -0,0 +1,11 @@ +package dev.inmo.tgbotapi.requests.stickers.abstracts + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.StickerSetName +import dev.inmo.tgbotapi.types.UserId +import kotlinx.serialization.KSerializer +import kotlinx.serialization.builtins.serializer + +interface OwnerStickerSetAction : StickerSetAction { + val userId: UserId +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction.kt index c829ffc1c3..ea7368cba7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers.abstracts import dev.inmo.tgbotapi.types.stickers.MaskPosition -interface StandardStickerSetAction : StickerSetAction { +interface StandardStickerSetAction : OwnerStickerSetAction { val emojis: String // must be more than one val maskPosition: MaskPosition? -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StickerSetAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StickerSetAction.kt index 5f2ebb57ae..f2a4013521 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StickerSetAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StickerSetAction.kt @@ -1,14 +1,14 @@ package dev.inmo.tgbotapi.requests.stickers.abstracts import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.StickerSetName import dev.inmo.tgbotapi.types.UserId import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.serializer interface StickerSetAction : SimpleRequest { - val userId: UserId - val name: String + val name: StickerSetName override val resultDeserializer: KSerializer get() = Boolean.serializer() -} \ No newline at end of file +} From 1633b9baafd132039a53110e5ef7be32d1c21acd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 11:18:37 +0600 Subject: [PATCH 04/28] add deleteStickerSet --- .../api/stickers/DeleteStickerSet.kt | 25 +++++++++++++++++++ .../requests/stickers/DeleteStickerSet.kt | 21 ++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerSet.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/DeleteStickerSet.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerSet.kt new file mode 100644 index 0000000000..bae7665e09 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerSet.kt @@ -0,0 +1,25 @@ +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.stickers.DeleteStickerFromSet +import dev.inmo.tgbotapi.requests.stickers.DeleteStickerSet +import dev.inmo.tgbotapi.types.StickerSetName +import dev.inmo.tgbotapi.types.files.Sticker +import dev.inmo.tgbotapi.types.stickers.StickerSet + +suspend fun TelegramBot.deleteStickerSet( + name: StickerSetName +) = execute( + DeleteStickerSet(name) +) + +suspend fun TelegramBot.deleteStickerSet( + sticker: Sticker +) = deleteStickerSet( + sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker") +) + +suspend fun TelegramBot.deleteStickerSet( + stickerSet: StickerSet, +) = deleteStickerSet(stickerSet.name) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/DeleteStickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/DeleteStickerSet.kt new file mode 100644 index 0000000000..7c807b5adb --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/DeleteStickerSet.kt @@ -0,0 +1,21 @@ +package dev.inmo.tgbotapi.requests.stickers + +import dev.inmo.tgbotapi.requests.abstracts.FileId +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.StickerSetName +import dev.inmo.tgbotapi.types.nameField +import dev.inmo.tgbotapi.types.stickerField +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class DeleteStickerSet( + @SerialName(nameField) + val name: StickerSetName +) : SimpleRequest { + override fun method(): String = "deleteStickerSet" + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} From 5533303d860662851e5ebaad0b163ac49733b066 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 11:28:21 +0600 Subject: [PATCH 05/28] add setStickerEmojiList --- .../api/stickers/SetStickerEmojiList.kt | 25 ++++++++++++++ .../requests/stickers/DeleteStickerFromSet.kt | 5 +-- .../requests/stickers/SetStickerEmojiList.kt | 33 +++++++++++++++++++ .../stickers/SetStickerPositionInSet.kt | 5 +-- .../stickers/abstracts/StickerAction.kt | 8 +++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 3 ++ 6 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerEmojiList.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerEmojiList.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StickerAction.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerEmojiList.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerEmojiList.kt new file mode 100644 index 0000000000..b8b1a45f5c --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerEmojiList.kt @@ -0,0 +1,25 @@ +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.stickers.SetStickerEmojiList +import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet +import dev.inmo.tgbotapi.types.files.Sticker + +suspend fun TelegramBot.setStickerEmojiList( + sticker: FileId, + emojis: List +) = execute( + SetStickerEmojiList( + sticker, + emojis + ) +) + +suspend fun TelegramBot.setStickerEmojiList( + sticker: Sticker, + vararg emojis: String +) = setStickerEmojiList( + sticker.fileId, + emojis.toList() +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/DeleteStickerFromSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/DeleteStickerFromSet.kt index b6d5340fda..b9f1228b8f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/DeleteStickerFromSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/DeleteStickerFromSet.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction import dev.inmo.tgbotapi.types.stickerField import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer @@ -9,8 +10,8 @@ import kotlinx.serialization.builtins.serializer @Serializable data class DeleteStickerFromSet( @SerialName(stickerField) - val sticker: FileId -) : SimpleRequest { + override val sticker: FileId +) : StickerAction { override fun method(): String = "deleteStickerFromSet" override val resultDeserializer: DeserializationStrategy get() = Boolean.serializer() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerEmojiList.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerEmojiList.kt new file mode 100644 index 0000000000..ef4bf80327 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerEmojiList.kt @@ -0,0 +1,33 @@ +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.OwnerStickerSetAction +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class SetStickerEmojiList ( + @SerialName(stickerField) + override val sticker: FileId, + @SerialName(emojiListField) + val emojis: List +) : StickerAction { + constructor(sticker: FileId, vararg emojis: String) : this(sticker, emojis.toList()) + + init { + require(emojis.size !in emojisInStickerLimit) { + "Emojis size should be in range $emojisInStickerLimit, but was ${emojis.size}" + } + } + + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "setStickerEmojiList" +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerPositionInSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerPositionInSet.kt index 7b8bbe0599..1952c0840d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerPositionInSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerPositionInSet.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction import dev.inmo.tgbotapi.types.positionField import dev.inmo.tgbotapi.types.stickerField import kotlinx.serialization.* @@ -10,10 +11,10 @@ import kotlinx.serialization.builtins.serializer @Serializable data class SetStickerPositionInSet( @SerialName(stickerField) - val sticker: FileId, + override val sticker: FileId, @SerialName(positionField) val position: Int -) : SimpleRequest { +) : StickerAction { init { if (position < 0) { throw IllegalArgumentException("Position must be positive or 0") diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StickerAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StickerAction.kt new file mode 100644 index 0000000000..8fb01eb88c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StickerAction.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.requests.stickers.abstracts + +import dev.inmo.tgbotapi.requests.abstracts.FileId +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest + +interface StickerAction : SimpleRequest { + val sticker: FileId +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 051774ede9..45710e163d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -134,6 +134,8 @@ val suggestedTipAmountsLimit = 1 .. 4 val inputFieldPlaceholderLimit = 1 .. 64 +val emojisInStickerLimit = 1 .. 20 + const val botActionActualityTime: Seconds = 5 // Made as lazy for correct work in K/JS @@ -257,6 +259,7 @@ const val createsJoinRequestField = "creates_join_request" const val pendingJoinRequestCountField = "pending_join_request_count" const val memberLimitField = "member_limit" const val iconColorField = "icon_color" +const val emojiListField = "emoji_list" const val requestContactField = "request_contact" const val requestLocationField = "request_location" From d8c659f866c6d8afe0dc5453a91f8170060b8878 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 11:32:44 +0600 Subject: [PATCH 06/28] add setStickerKeywords --- .../api/stickers/SetStickerKeywords.kt | 26 +++++++++++++ .../requests/stickers/SetStickerKeywords.kt | 38 +++++++++++++++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 5 +++ 3 files changed, 69 insertions(+) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerKeywords.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerKeywords.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerKeywords.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerKeywords.kt new file mode 100644 index 0000000000..2653455511 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerKeywords.kt @@ -0,0 +1,26 @@ +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.stickers.SetStickerEmojiList +import dev.inmo.tgbotapi.requests.stickers.SetStickerKeywords +import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet +import dev.inmo.tgbotapi.types.files.Sticker + +suspend fun TelegramBot.setStickerKeywords( + sticker: FileId, + keywords: List +) = execute( + SetStickerKeywords( + sticker, + keywords + ) +) + +suspend fun TelegramBot.setStickerKeywords( + sticker: Sticker, + vararg keywords: String +) = setStickerKeywords( + sticker.fileId, + keywords.toList() +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerKeywords.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerKeywords.kt new file mode 100644 index 0000000000..3a384c6f78 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerKeywords.kt @@ -0,0 +1,38 @@ +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.OwnerStickerSetAction +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class SetStickerKeywords ( + @SerialName(stickerField) + override val sticker: FileId, + @SerialName(keywordsField) + val keywords: List +) : StickerAction { + constructor(sticker: FileId, vararg keywords: String) : this(sticker, keywords.toList()) + + init { + require(keywords.size !in keywordsInStickerLimit) { + "Keywords list size should be in range $keywordsInStickerLimit, but was ${keywords.size}" + } + keywords.forEach { + require(it.length in stickerKeywordLengthLimit) { + "Keyword length should be in range $stickerKeywordLengthLimit, but was ${it.length} (word \"$it\")" + } + } + } + + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "setStickerKeywords" +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 45710e163d..b06249e225 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -136,6 +136,10 @@ val inputFieldPlaceholderLimit = 1 .. 64 val emojisInStickerLimit = 1 .. 20 +val keywordsInStickerLimit = 0 .. 20 + +val stickerKeywordLengthLimit = 0 .. 64 + const val botActionActualityTime: Seconds = 5 // Made as lazy for correct work in K/JS @@ -412,6 +416,7 @@ const val offsetField = "offset" const val limitField = "limit" const val stickersField = "stickers" const val stickerField = "sticker" +const val keywordsField = "keywords" const val urlField = "url" const val addressField = "address" const val actionField = "action" From e30361ad1e0fbf83bcef82b959d41675a5b14e13 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 12:01:08 +0600 Subject: [PATCH 07/28] rename thumb field --- .../api/send/media/SendAnimation.kt | 4 +- .../extensions/api/send/media/SendAudio.kt | 4 +- .../extensions/api/send/media/SendDocument.kt | 4 +- .../extensions/api/send/media/SendVideo.kt | 4 +- .../api/send/media/SendVideoNote.kt | 2 +- .../abstracts/ThumbedSendMessageRequest.kt | 6 ++- .../requests/send/media/SendAnimation.kt | 8 ++-- .../tgbotapi/requests/send/media/SendAudio.kt | 8 ++-- .../requests/send/media/SendDocument.kt | 8 ++-- .../tgbotapi/requests/send/media/SendVideo.kt | 8 ++-- .../requests/send/media/SendVideoNote.kt | 8 ++-- .../tgbotapi/requests/send/media/SendVoice.kt | 4 +- .../requests/stickers/SetStickerSetThumb.kt | 7 ++-- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 2 + .../tgbotapi/types/files/AnimationFile.kt | 2 +- .../inmo/tgbotapi/types/files/AudioFile.kt | 4 +- .../inmo/tgbotapi/types/files/DocumentFile.kt | 4 +- .../dev/inmo/tgbotapi/types/files/Sticker.kt | 40 +++++++++---------- .../tgbotapi/types/files/ThumbedMediaFile.kt | 7 ++-- .../inmo/tgbotapi/types/files/VideoFile.kt | 8 ++-- .../tgbotapi/types/files/VideoNoteFile.kt | 2 +- .../types/media/TelegramMediaAudio.kt | 4 +- .../types/media/TelegramMediaDocument.kt | 4 +- .../types/message/content/AnimationContent.kt | 4 +- .../types/message/content/AudioContent.kt | 2 +- .../types/message/content/DocumentContent.kt | 2 +- .../types/message/content/StickerContent.kt | 2 +- .../types/message/content/VideoContent.kt | 2 +- .../types/message/content/VideoNoteContent.kt | 4 +- .../tgbotapi/types/stickers/StickerSet.kt | 21 +++++----- 30 files changed, 97 insertions(+), 92 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt index 623e44ccf2..22817f4192 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt @@ -73,7 +73,7 @@ suspend fun TelegramBot.sendAnimation( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, animation.fileId, animation.thumbnail ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -177,7 +177,7 @@ suspend fun TelegramBot.sendAnimation( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumb ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, animation.fileId, animation.thumbnail ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt index a6752e3470..355a26fa85 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt @@ -88,7 +88,7 @@ suspend fun TelegramBot.sendAudio( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -180,7 +180,7 @@ suspend inline fun TelegramBot.sendAudio( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt index 7173129726..787e5fc7f6 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt @@ -83,7 +83,7 @@ suspend fun TelegramBot.sendDocument( replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = sendDocument( - chatId, document.fileId, document.thumb ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection + chatId, document.fileId, document.thumbnail ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection ) /** @@ -170,7 +170,7 @@ suspend inline fun TelegramBot.sendDocument( replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = sendDocument( - chatId, document.fileId, document.thumb ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection + chatId, document.fileId, document.thumbnail ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection ) /** diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt index 3b1b6c7481..c9ad764b91 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt @@ -70,7 +70,7 @@ suspend fun TelegramBot.sendVideo( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -167,7 +167,7 @@ suspend inline fun TelegramBot.sendVideo( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt index 5eb4b848b3..d4c0cc11a6 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt @@ -57,7 +57,7 @@ suspend fun TelegramBot.sendVideoNote( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVideoNote( - chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, videoNote.fileId, videoNote.thumbnail ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ThumbedSendMessageRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ThumbedSendMessageRequest.kt index 450c624f69..97cedd3095 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ThumbedSendMessageRequest.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ThumbedSendMessageRequest.kt @@ -1,5 +1,9 @@ package dev.inmo.tgbotapi.requests.send.abstracts interface ThumbedSendMessageRequest: SendMessageRequest { + val thumbnail: String? + + @Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnail")) val thumb: String? -} \ No newline at end of file + get() = thumbnail +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt index ec83f84067..ae61f5c46d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt @@ -129,8 +129,8 @@ data class SendAnimationData internal constructor( override val chatId: ChatIdentifier, @SerialName(animationField) val animation: String? = null, - @SerialName(thumbField) - override val thumb: String? = null, + @SerialName(thumbnailField) + override val thumbnail: String? = null, @SerialName(captionField) override val text: String? = null, @SerialName(parseModeField) @@ -187,8 +187,8 @@ data class SendAnimationData internal constructor( data class SendAnimationFiles internal constructor( val animation: MultipartFile? = null, - val thumb: MultipartFile? = null + val thumbnail: MultipartFile? = null ) : Files by mapOfNotNull( animationField to animation, - thumbField to thumb + thumbnailField to thumbnail ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt index b819e076af..dcb1d268f5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt @@ -126,8 +126,8 @@ data class SendAudioData internal constructor( override val chatId: ChatIdentifier, @SerialName(audioField) val audio: String? = null, - @SerialName(thumbField) - override val thumb: String? = null, + @SerialName(thumbnailField) + override val thumbnail: String? = null, @SerialName(captionField) override val text: String? = null, @SerialName(parseModeField) @@ -182,8 +182,8 @@ data class SendAudioData internal constructor( data class SendAudioFiles internal constructor( val audio: MultipartFile? = null, - val thumb: MultipartFile? = null + val thumbnail: MultipartFile? = null ) : Files by mapOfNotNull( audioField to audio, - thumbField to thumb + thumbnailField to thumbnail ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt index 35b2ab3d93..8ff04c4aca 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt @@ -144,8 +144,8 @@ data class SendDocumentData internal constructor( override val chatId: ChatIdentifier, @SerialName(documentField) val document: String? = null, - @SerialName(thumbField) - override val thumb: String? = null, + @SerialName(thumbnailField) + override val thumbnail: String? = null, @SerialName(captionField) override val text: String? = null, @SerialName(parseModeField) @@ -193,8 +193,8 @@ data class SendDocumentData internal constructor( data class SendDocumentFiles internal constructor( val document: MultipartFile? = null, - val thumb: MultipartFile? = null + val thumbnail: MultipartFile? = null ) : Files by mapOfNotNull( documentField to document, - thumbField to thumb + thumbnailField to thumbnail ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt index 0b749649d2..e427c4f10a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt @@ -133,8 +133,8 @@ data class SendVideoData internal constructor( override val chatId: ChatIdentifier, @SerialName(videoField) val video: String? = null, - @SerialName(thumbField) - override val thumb: String? = null, + @SerialName(thumbnailField) + override val thumbnail: String? = null, @SerialName(captionField) override val text: String? = null, @SerialName(parseModeField) @@ -193,8 +193,8 @@ data class SendVideoData internal constructor( data class SendVideoFiles internal constructor( val video: MultipartFile? = null, - val thumb: MultipartFile? = null + val thumbnail: MultipartFile? = null ) : Files by mapOfNotNull( videoField to video, - thumbField to thumb + thumbnailField to thumbnail ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt index d80bd0679b..914e50eafa 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt @@ -62,8 +62,8 @@ data class SendVideoNoteData internal constructor( override val chatId: ChatIdentifier, @SerialName(videoNoteField) val videoNote: String? = null, - @SerialName(thumbField) - override val thumb: String? = null, + @SerialName(thumbnailField) + override val thumbnail: String? = null, @SerialName(durationField) override val duration: Long? = null, @SerialName(lengthField) @@ -99,8 +99,8 @@ data class SendVideoNoteData internal constructor( data class SendVideoNoteFiles internal constructor( val videoNote: MultipartFile? = null, - val thumb: MultipartFile? = null + val thumbnail: MultipartFile? = null ) : Files by mapOfNotNull( videoNoteField to videoNote, - thumbField to thumb + thumbnailField to thumbnail ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt index 900632aea1..0b914246fb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt @@ -156,8 +156,8 @@ data class SendVoiceData internal constructor( data class SendVoiceFiles internal constructor( val voice: MultipartFile? = null, - val thumb: MultipartFile? = null + val thumbnail: MultipartFile? = null ) : Files by mapOfNotNull( voiceField to voice, - thumbField to thumb + thumbnailField to thumbnail ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt index a35f2a2b87..821f005b64 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt @@ -3,18 +3,17 @@ 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.OwnerStickerSetAction -import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction import dev.inmo.tgbotapi.types.* import kotlinx.serialization.* fun SetStickerSetThumb( userId: UserId, stickerSetName: String, - thumb: MultipartFile + thumbnail: MultipartFile ): Request { return CommonMultipartFileRequest( SetStickerSetThumb(userId, stickerSetName), - mapOf(thumbField to thumb) + mapOf(thumbnailField to thumbnail) ) } @@ -24,7 +23,7 @@ data class SetStickerSetThumb ( override val userId: UserId, @SerialName(nameField) override val name: StickerSetName, - @SerialName(thumbField) + @SerialName(thumbnailField) val thumb: FileId? = null ) : OwnerStickerSetAction { override val requestSerializer: SerializationStrategy<*> diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index b06249e225..be3c2992b3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -387,6 +387,8 @@ const val explanationField = "explanation" const val idField = "id" const val pollIdField = "poll_id" const val textField = "text" +const val thumbnailField = "thumbnail" +@Deprecated("Renamed (in telegram bot api)", ReplaceWith("thumbnailField", "dev.inmo.tgbotapi.types.thumbnailField")) const val thumbField = "thumb" const val emojiField = "emoji" const val emojisField = "emojis" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt index 7293d908cf..6492f43f39 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt @@ -16,7 +16,7 @@ data class AnimationFile( override val width: Int, override val height: Int, override val duration: Long? = null, - override val thumb: PhotoSize? = null, + override val thumbnail: PhotoSize? = null, @SerialName(fileNameField) override val fileName: String? = null, @SerialName(mimeTypeField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt index 8a3f4ebd28..e8a85ac00b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt @@ -25,8 +25,8 @@ data class AudioFile( override val mimeType: MimeType? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, - @SerialName(thumbField) - override val thumb: PhotoSize? = null + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null ) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile, Performerable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt index c477da4b4f..f2b57fe6a7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt @@ -15,7 +15,7 @@ data class DocumentFile( override val fileUniqueId: FileUniqueId, @SerialName(fileSizeField) override val fileSize: Long? = null, - override val thumb: PhotoSize? = null, + override val thumbnail: PhotoSize? = null, @SerialName(mimeTypeField) override val mimeType: MimeType? = null, @SerialName(fileNameField) @@ -30,7 +30,7 @@ inline fun TelegramMediaFile.asDocumentFile() = if (this is DocumentFile) { fileId, fileUniqueId, fileSize, - (this as? ThumbedMediaFile) ?.thumb, + (this as? ThumbedMediaFile) ?.thumbnail, (this as? MimedMediaFile) ?.mimeType, (this as? CustomNamedMediaFile) ?.fileName ) 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 26a66f446f..e017de9a20 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 @@ -202,8 +202,8 @@ data class RegularSimpleSticker( override val width: Int, @SerialName(heightField) override val height: Int, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -225,8 +225,8 @@ data class RegularAnimatedSticker( override val width: Int, @SerialName(heightField) override val height: Int, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -246,8 +246,8 @@ data class RegularVideoSticker( override val width: Int, @SerialName(heightField) override val height: Int, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -275,8 +275,8 @@ data class MaskSimpleSticker( override val height: Int, @SerialName(maskPositionField) override val maskPosition: MaskPosition, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -296,8 +296,8 @@ data class MaskAnimatedSticker( override val height: Int, @SerialName(maskPositionField) override val maskPosition: MaskPosition, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -317,8 +317,8 @@ data class MaskVideoSticker( override val height: Int, @SerialName(maskPositionField) override val maskPosition: MaskPosition, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -344,8 +344,8 @@ data class CustomEmojiSimpleSticker( override val height: Int, @SerialName(customEmojiIdField) override val customEmojiId: CustomEmojiId, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -365,8 +365,8 @@ data class CustomEmojiAnimatedSticker( override val height: Int, @SerialName(customEmojiIdField) override val customEmojiId: CustomEmojiId, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -386,8 +386,8 @@ data class CustomEmojiVideoSticker( override val height: Int, @SerialName(customEmojiIdField) override val customEmojiId: CustomEmojiId, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) @@ -406,8 +406,8 @@ data class UnknownSticker( override val width: Int, @SerialName(heightField) override val height: Int, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(emojiField) override val emoji: String? = null, @SerialName(stickerSetNameField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/ThumbedMediaFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/ThumbedMediaFile.kt index b988901009..456519d3bb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/ThumbedMediaFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/ThumbedMediaFile.kt @@ -1,8 +1,9 @@ package dev.inmo.tgbotapi.types.files -import dev.inmo.tgbotapi.types.files.PhotoSize -import dev.inmo.tgbotapi.types.files.TelegramMediaFile - sealed interface ThumbedMediaFile : TelegramMediaFile { + val thumbnail: PhotoSize? + + @Deprecated("Renamed (in telegram bot api)", ReplaceWith("thumbnail")) val thumb: PhotoSize? + get() = thumbnail } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index 7aaf0bf72d..3fbc99a402 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -21,8 +21,8 @@ data class VideoFile( override val height: Int, @SerialName(durationField) override val duration: Long? = null, - @SerialName(thumbField) - override val thumb: PhotoSize? = null, + @SerialName(thumbnailField) + override val thumbnail: PhotoSize? = null, @SerialName(fileNameField) override val fileName: String? = null, @SerialName(mimeTypeField) @@ -44,7 +44,7 @@ inline fun VideoFile.toTelegramMediaVideo( width, height, duration, - thumb ?.fileId + thumbnail ?.fileId ) @Suppress("NOTHING_TO_INLINE") @@ -58,5 +58,5 @@ inline fun VideoFile.toTelegramMediaVideo( width, height, duration, - thumb ?.fileId + thumbnail ?.fileId ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt index 04b65e14fa..d98d872261 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt @@ -15,7 +15,7 @@ data class VideoNoteFile( @SerialName("length") override val width: Int, override val duration: Long? = null, - override val thumb: PhotoSize? = null, + override val thumbnail: PhotoSize? = null, @SerialName(fileSizeField) override val fileSize: Long? = null ) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaAudio.kt index bb9efe8f07..9a21b6ca1d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaAudio.kt @@ -77,7 +77,7 @@ fun AudioFile.toTelegramMediaAudio( duration, performer, title, - thumb ?.fileId + thumbnail ?.fileId ) fun AudioFile.toTelegramMediaAudio( @@ -89,5 +89,5 @@ fun AudioFile.toTelegramMediaAudio( duration, performer, title, - thumb ?.fileId + thumbnail ?.fileId ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaDocument.kt index 8f4e4d8df1..8049a4b692 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaDocument.kt @@ -78,7 +78,7 @@ fun DocumentFile.toTelegramMediaDocument( fileId, text, parseMode, - thumb ?.fileId + thumbnail ?.fileId ) fun DocumentFile.toTelegramMediaDocument( @@ -86,5 +86,5 @@ fun DocumentFile.toTelegramMediaDocument( ) = TelegramMediaDocument( fileId, textSources, - thumb ?.fileId + thumbnail ?.fileId ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt index cd7df6d9f1..1552b97f54 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt @@ -32,7 +32,7 @@ data class AnimationContent( ): Request> = SendAnimation( chatId, media.fileId, - media.thumb ?.fileId, + media.thumbnail ?.fileId, textSources, spoilered, media.duration, @@ -53,6 +53,6 @@ data class AnimationContent( media.width, media.height, media.duration, - media.thumb ?.fileId + media.thumbnail ?.fileId ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt index 5ac88ae625..0b56455154 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt @@ -30,7 +30,7 @@ data class AudioContent( ): Request> = SendAudio( chatId, media.fileId, - media.thumb ?.fileId, + media.thumbnail ?.fileId, textSources, media.duration, media.performer, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt index 5c27ebbf9f..1b2720bcc8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt @@ -32,7 +32,7 @@ data class DocumentContent( ): Request> = SendDocument( chatId, media.fileId, - media.thumb ?.fileId, + media.thumbnail ?.fileId, textSources, messageThreadId, disableNotification, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt index 635f855d5a..dfb21e7942 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt @@ -37,6 +37,6 @@ data class StickerContent( override fun asTelegramMedia(): TelegramMediaDocument = TelegramMediaDocument( media.fileId, null, - thumb = media.thumb ?.fileId + thumb = media.thumbnail ?.fileId ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt index 15d877b916..7b8ed78713 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt @@ -31,7 +31,7 @@ data class VideoContent( ): Request> = SendVideo( chatId, media.fileId, - media.thumb ?.fileId, + media.thumbnail ?.fileId, textSources, spoilered, media.duration, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoNoteContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoNoteContent.kt index 047f0203e5..8e47237fd0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoNoteContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoNoteContent.kt @@ -26,7 +26,7 @@ data class VideoNoteContent( ): Request> = SendVideoNote( chatId, media.fileId, - media.thumb ?.fileId, + media.thumbnail ?.fileId, media.duration, media.width, messageThreadId, @@ -42,6 +42,6 @@ data class VideoNoteContent( width = media.width, height = media.height, duration = media.duration, - thumb = media.thumb ?.fileId + thumb = media.thumbnail ?.fileId ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt index 922c6c6b52..fc53396886 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt @@ -7,7 +7,6 @@ import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonElement @Serializable @@ -146,7 +145,7 @@ data class RegularSimpleStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : RegularStickerSet { @SerialName(stickerTypeField) @@ -162,7 +161,7 @@ data class RegularAnimatedStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : RegularStickerSet, AnimatedStickerSet { @SerialName(stickerTypeField) @@ -178,7 +177,7 @@ data class RegularVideoStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : RegularStickerSet, VideoStickerSet { @SerialName(stickerTypeField) @@ -194,7 +193,7 @@ data class MaskSimpleStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : MaskStickerSet { @SerialName(stickerTypeField) @@ -210,7 +209,7 @@ data class MaskAnimatedStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : MaskStickerSet, AnimatedStickerSet { @SerialName(stickerTypeField) @@ -226,7 +225,7 @@ data class MaskVideoStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : MaskStickerSet, VideoStickerSet { @SerialName(stickerTypeField) @@ -242,7 +241,7 @@ data class CustomEmojiSimpleStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : CustomEmojiStickerSet { @SerialName(stickerTypeField) @@ -258,7 +257,7 @@ data class CustomEmojiAnimatedStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : CustomEmojiStickerSet, AnimatedStickerSet { @SerialName(stickerTypeField) @@ -274,7 +273,7 @@ data class CustomEmojiVideoStickerSet( override val title: String, @SerialName(stickersField) override val stickers: List, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null ) : CustomEmojiStickerSet, VideoStickerSet { @SerialName(stickerTypeField) @@ -292,7 +291,7 @@ data class UnknownStickerSet( override val stickers: List, @SerialName(stickerTypeField) override val stickerType: StickerType, - @SerialName(thumbField) + @SerialName(thumbnailField) override val thumb: PhotoSize? = null, val raw: JsonElement ) : CustomEmojiStickerSet, VideoStickerSet From e7b21dcd3d0f8c9908fc7859b0c48ad3998f63b2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 12:11:17 +0600 Subject: [PATCH 08/28] rename setStickerSetThumb to setStickerSetThumbnail --- .../api/stickers/SetStickerSetThumb.kt | 79 ++++++++++++++++++- .../requests/stickers/SetStickerSetThumb.kt | 33 -------- .../stickers/SetStickerSetThumbnail.kt | 47 +++++++++++ 3 files changed, 123 insertions(+), 36 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumbnail.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt index 8831061c60..d38f7ed4f3 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt @@ -3,27 +3,95 @@ package dev.inmo.tgbotapi.extensions.api.thumbs 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.SetStickerSetThumb +import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail +import dev.inmo.tgbotapi.types.StickerSetName import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.stickers.StickerSet +suspend fun TelegramBot.setStickerSetThumbnail( + userId: UserId, + stickerSetName: StickerSetName, + thumbnail: FileId +) = execute( + SetStickerSetThumbnail(userId, stickerSetName, thumbnail) +) + +suspend fun TelegramBot.setStickerSetThumbnail( + userId: UserId, + stickerSetName: StickerSetName, + thumbnail: MultipartFile +) = execute( + SetStickerSetThumbnail(userId, stickerSetName, thumbnail) +) + +suspend fun TelegramBot.setStickerSetThumbnail( + user: CommonUser, + stickerSetName: StickerSetName, + thumbnail: FileId +) = setStickerSetThumbnail( + user.id, stickerSetName, thumbnail +) + +suspend fun TelegramBot.setStickerSetThumbnail( + user: CommonUser, + stickerSetName: StickerSetName, + thumbnail: MultipartFile +) = setStickerSetThumbnail( + user.id, stickerSetName, thumbnail +) + +suspend fun TelegramBot.setStickerSetThumbnail( + userId: UserId, + stickerSet: StickerSet, + thumbnail: FileId +) = setStickerSetThumbnail( + userId, stickerSet.name, thumbnail +) + +suspend fun TelegramBot.setStickerSetThumbnail( + userId: UserId, + stickerSet: StickerSet, + thumbnail: MultipartFile +) = setStickerSetThumbnail( + userId, stickerSet.name, thumbnail +) + +suspend fun TelegramBot.setStickerSetThumbnail( + user: CommonUser, + stickerSet: StickerSet, + thumbnail: FileId +) = setStickerSetThumbnail( + user.id, stickerSet.name, thumbnail +) + +suspend fun TelegramBot.setStickerSetThumbnail( + user: CommonUser, + stickerSet: StickerSet, + thumbnail: MultipartFile +) = setStickerSetThumbnail( + user.id, stickerSet.name, thumbnail +) + +@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(userId, thumbSetName, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail")) suspend fun TelegramBot.setStickerSetThumb( userId: UserId, thumbSetName: String, thumb: FileId ) = execute( - SetStickerSetThumb(userId, thumbSetName, thumb) + SetStickerSetThumbnail(userId, thumbSetName, thumb) ) +@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(userId, thumbSetName, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail")) suspend fun TelegramBot.setStickerSetThumb( userId: UserId, thumbSetName: String, thumb: MultipartFile ) = execute( - SetStickerSetThumb(userId, thumbSetName, thumb) + SetStickerSetThumbnail(userId, thumbSetName, thumb) ) +@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(user, thumbSetName, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail")) suspend fun TelegramBot.setStickerSetThumb( user: CommonUser, thumbSetName: String, @@ -32,6 +100,7 @@ suspend fun TelegramBot.setStickerSetThumb( user.id, thumbSetName, thumb ) +@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(user, thumbSetName, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail")) suspend fun TelegramBot.setStickerSetThumb( user: CommonUser, thumbSetName: String, @@ -40,6 +109,7 @@ suspend fun TelegramBot.setStickerSetThumb( user.id, thumbSetName, thumb ) +@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(userId, thumbSet, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail")) suspend fun TelegramBot.setStickerSetThumb( userId: UserId, thumbSet: StickerSet, @@ -48,6 +118,7 @@ suspend fun TelegramBot.setStickerSetThumb( userId, thumbSet.name, thumb ) +@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(userId, thumbSet, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail")) suspend fun TelegramBot.setStickerSetThumb( userId: UserId, thumbSet: StickerSet, @@ -56,6 +127,7 @@ suspend fun TelegramBot.setStickerSetThumb( userId, thumbSet.name, thumb ) +@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(user, thumbSet, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail")) suspend fun TelegramBot.setStickerSetThumb( user: CommonUser, thumbSet: StickerSet, @@ -64,6 +136,7 @@ suspend fun TelegramBot.setStickerSetThumb( user.id, thumbSet.name, thumb ) +@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(user, thumbSet, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail")) suspend fun TelegramBot.setStickerSetThumb( user: CommonUser, thumbSet: StickerSet, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt deleted file mode 100644 index 821f005b64..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumb.kt +++ /dev/null @@ -1,33 +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.OwnerStickerSetAction -import dev.inmo.tgbotapi.types.* -import kotlinx.serialization.* - -fun SetStickerSetThumb( - userId: UserId, - stickerSetName: String, - thumbnail: MultipartFile -): Request { - return CommonMultipartFileRequest( - SetStickerSetThumb(userId, stickerSetName), - mapOf(thumbnailField to thumbnail) - ) -} - -@Serializable -data class SetStickerSetThumb ( - @SerialName(userIdField) - override val userId: UserId, - @SerialName(nameField) - override val name: StickerSetName, - @SerialName(thumbnailField) - val thumb: FileId? = null -) : OwnerStickerSetAction { - override val requestSerializer: SerializationStrategy<*> - get() = serializer() - - override fun method(): String = "setStickerSetThumb" -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumbnail.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumbnail.kt new file mode 100644 index 0000000000..588ff1b64b --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumbnail.kt @@ -0,0 +1,47 @@ +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.OwnerStickerSetAction +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* + +fun SetStickerSetThumbnail( + userId: UserId, + stickerSetName: String, + thumbnail: MultipartFile +): Request { + return CommonMultipartFileRequest( + SetStickerSetThumbnail(userId, stickerSetName), + mapOf(thumbnailField to thumbnail) + ) +} + +@Deprecated("Renamed", ReplaceWith("SetStickerSetThumbnail(userId, stickerSetName, thumbnail)", "dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail")) +fun SetStickerSetThumb( + userId: UserId, + stickerSetName: String, + thumbnail: MultipartFile +): Request = SetStickerSetThumbnail(userId, stickerSetName, thumbnail) + +@Serializable +data class SetStickerSetThumbnail ( + @SerialName(userIdField) + override val userId: UserId, + @SerialName(nameField) + override val name: StickerSetName, + @SerialName(thumbnailField) + val thumbnail: FileId? = null +) : OwnerStickerSetAction { + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "setStickerSetThumbnail" +} + +@Deprecated("Renamed", ReplaceWith("SetStickerSetThumbnail(userId, name, thumbnail)", "dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail")) +fun SetStickerSetThumb( + userId: UserId, + name: StickerSetName, + thumbnail: FileId? = null +) = SetStickerSetThumbnail(userId, name, thumbnail) From 90b9c66beaf3b732724b1cd0f8ddf73f9e9c84ce Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 12:24:12 +0600 Subject: [PATCH 09/28] rename all thumb* usages --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 8 ++++ .../InlineQueryResultArticle.kt | 12 +++--- .../InlineQueryResultContact.kt | 12 +++--- .../InlineQueryResultDocumentImpl.kt | 32 ++++++++-------- .../InlineQueryResultGifImpl.kt | 38 +++++++++---------- .../InlineQueryResultLocation.kt | 12 +++--- .../InlineQueryResultMpeg4GifImpl.kt | 26 ++++++------- .../InlineQueryResultPhotoImpl.kt | 12 +++--- .../InlineQueryResultVenue.kt | 12 +++--- .../InlineQueryResultVideoImpl.kt | 12 +++--- .../abstracts/ThumbSizedInlineQueryResult.kt | 8 +++- .../abstracts/ThumbedInlineQueryResult.kt | 8 +++- 12 files changed, 106 insertions(+), 86 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index be3c2992b3..cb3abb8999 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -332,9 +332,17 @@ const val stickerFileIdField = "sticker_file_id" const val gameShortNameField = "game_short_name" +const val thumbnailUrlField = "thumbnail_url" +@Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnailUrlField", "dev.inmo.tgbotapi.types.thumbnailUrlField")) const val thumbUrlField = "thumb_url" +const val thumbnailMimeTypeField = "thumbnail_mime_type" +@Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnailMimeTypeField", "dev.inmo.tgbotapi.types.thumbnailMimeTypeField")) const val thumbMimeTypeField = "thumb_mime_type" +const val thumbnailWidthField = "thumbnail_width" +@Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnailWidthField", "dev.inmo.tgbotapi.types.thumbnailWidthField")) const val thumbWidthField = "thumb_width" +const val thumbnailHeightField = "thumbnail_height" +@Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnailHeightField", "dev.inmo.tgbotapi.types.thumbnailHeightField")) const val thumbHeightField = "thumb_height" const val inputMessageContentField = "input_message_content" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt index 870e3e7fc8..efdf2b08a4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt @@ -23,12 +23,12 @@ class InlineQueryResultArticle( val hideUrl: Boolean? = null, @SerialName(descriptionField) override val description: String? = null, - @SerialName(thumbUrlField) - override val thumbUrl: String? = null, - @SerialName(thumbWidthField) - override val thumbWidth: Int? = null, - @SerialName(thumbHeightField) - override val thumbHeight: Int? = null + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String? = null, + @SerialName(thumbnailWidthField) + override val thumbnailWidth: Int? = null, + @SerialName(thumbnailHeightField) + override val thumbnailHeight: Int? = null ) : InlineQueryResult, ThumbSizedInlineQueryResult, TitledInlineQueryResult, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt index 25ee6f4c9a..5b15d28ad9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt @@ -20,12 +20,12 @@ data class InlineQueryResultContact( override val lastName: String? = null, @SerialName(vcardField) override val vcard: String? = null, - @SerialName(thumbUrlField) - override val thumbUrl: String? = null, - @SerialName(thumbWidthField) - override val thumbWidth: Int? = null, - @SerialName(thumbHeightField) - override val thumbHeight: Int? = null, + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String? = null, + @SerialName(thumbnailWidthField) + override val thumbnailWidth: Int? = null, + @SerialName(thumbnailHeightField) + override val thumbnailHeight: Int? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt index ea2d06a3cb..f7ce408e89 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt @@ -21,24 +21,24 @@ fun InlineQueryResultDocumentImpl( url: String, title: String, mimeType: MimeType, - thumbUrl: String? = null, - thumbWidth: Int? = null, - thumbHeight: Int? = null, + thumbnailUrl: String? = null, + thumbnailWidth: Int? = null, + thumbnailHeight: Int? = null, description: String? = null, text: String? = null, parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultDocumentImpl(id, url, title, mimeType, thumbUrl, thumbWidth, thumbHeight, description, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultDocumentImpl(id, url, title, mimeType, thumbnailUrl, thumbnailWidth, thumbnailHeight, description, text, parseMode, null, replyMarkup, inputMessageContent) fun InlineQueryResultDocumentImpl( id: InlineQueryIdentifier, url: String, title: String, mimeType: MimeType, - thumbUrl: String? = null, - thumbWidth: Int? = null, - thumbHeight: Int? = null, + thumbnailUrl: String? = null, + thumbnailWidth: Int? = null, + thumbnailHeight: Int? = null, description: String? = null, entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, @@ -48,9 +48,9 @@ fun InlineQueryResultDocumentImpl( url, title, mimeType, - thumbUrl, - thumbWidth, - thumbHeight, + thumbnailUrl, + thumbnailWidth, + thumbnailHeight, description, entities.makeString(), null, @@ -69,12 +69,12 @@ data class InlineQueryResultDocumentImpl internal constructor( override val title: String, @SerialName(mimeTypeField) override val mimeType: MimeType, - @SerialName(thumbUrlField) - override val thumbUrl: String? = null, - @SerialName(thumbWidthField) - override val thumbWidth: Int? = null, - @SerialName(thumbHeightField) - override val thumbHeight: Int? = null, + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String? = null, + @SerialName(thumbnailWidthField) + override val thumbnailWidth: Int? = null, + @SerialName(thumbnailHeightField) + override val thumbnailHeight: Int? = null, @SerialName(descriptionField) override val description: String? = null, @SerialName(captionField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt index 7945ea13f2..8142ead6de 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt @@ -20,8 +20,8 @@ import kotlinx.serialization.Serializable fun InlineQueryResultGifImpl( id: InlineQueryIdentifier, url: String, - thumbUrl: String, - thumbMimeType: MimeType? = null, + thumbnailUrl: String, + thumbnailMimeType: MimeType? = null, width: Int? = null, height: Int? = null, duration: Int? = null, @@ -30,13 +30,13 @@ fun InlineQueryResultGifImpl( parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultGifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultGifImpl(id, url, thumbnailUrl, thumbnailMimeType, width, height, duration, title, text, parseMode, null, replyMarkup, inputMessageContent) fun InlineQueryResultGifImpl( id: InlineQueryIdentifier, url: String, - thumbUrl: String, - thumbMimeType: MimeType? = null, + thumbnailUrl: String, + thumbnailMimeType: MimeType? = null, width: Int? = null, height: Int? = null, duration: Int? = null, @@ -47,8 +47,8 @@ fun InlineQueryResultGifImpl( ) = InlineQueryResultGifImpl( id, url, - thumbUrl, - thumbMimeType, + thumbnailUrl, + thumbnailMimeType, width, height, duration, @@ -63,8 +63,8 @@ fun InlineQueryResultGifImpl( fun InlineQueryResultGifImpl( id: InlineQueryIdentifier, gifFile: FileId, - thumbUrl: String, - thumbMimeType: MimeType? = null, + thumbnailUrl: String, + thumbnailMimeType: MimeType? = null, width: Int? = null, height: Int? = null, duration: Int? = null, @@ -73,13 +73,13 @@ fun InlineQueryResultGifImpl( parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultGifImpl(id, gifFile.fileId, thumbUrl, thumbMimeType, width, height, duration, title, text, parseMode, replyMarkup, inputMessageContent) +) = InlineQueryResultGifImpl(id, gifFile.fileId, thumbnailUrl, thumbnailMimeType, width, height, duration, title, text, parseMode, replyMarkup, inputMessageContent) fun InlineQueryResultGifImpl( id: InlineQueryIdentifier, gifFile: FileId, - thumbUrl: String, - thumbMimeType: MimeType? = null, + thumbnailUrl: String, + thumbnailMimeType: MimeType? = null, width: Int? = null, height: Int? = null, duration: Int? = null, @@ -88,7 +88,7 @@ fun InlineQueryResultGifImpl( replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultGifImpl( - id, gifFile.fileId, thumbUrl, thumbMimeType, width, height, duration, title, entities, replyMarkup, inputMessageContent + id, gifFile.fileId, thumbnailUrl, thumbnailMimeType, width, height, duration, title, entities, replyMarkup, inputMessageContent ) @Serializable @@ -97,10 +97,10 @@ data class InlineQueryResultGifImpl internal constructor( override val id: InlineQueryIdentifier, @SerialName(gifUrlField) override val url: String, - @SerialName(thumbUrlField) - override val thumbUrl: String, - @SerialName(thumbMimeTypeField) - override val thumbMimeType: MimeType? = null, + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String, + @SerialName(thumbnailMimeTypeField) + override val thumbnailMimeType: MimeType? = null, @SerialName(gifWidthField) override val width: Int? = null, @SerialName(gifHeightField) @@ -126,8 +126,8 @@ data class InlineQueryResultGifImpl internal constructor( } init { - if (thumbMimeType != null && thumbMimeType !in telegramInlineModeGifPermittedMimeTypes) { - error("Passed thumb mime type is not permitted in Telegram Bot API. Passed $thumbMimeType, but permitted $telegramInlineModeGifPermittedMimeTypes") + if (thumbnailMimeType != null && thumbnailMimeType !in telegramInlineModeGifPermittedMimeTypes) { + error("Passed thumb mime type is not permitted in Telegram Bot API. Passed $thumbnailMimeType, but permitted $telegramInlineModeGifPermittedMimeTypes") } } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt index cd1426d15b..1fa53ddb7a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt @@ -26,12 +26,12 @@ data class InlineQueryResultLocation( override val heading: Degrees? = null, @SerialName(proximityAlertRadiusField) override val proximityAlertRadius: Meters? = null, - @SerialName(thumbUrlField) - override val thumbUrl: String? = null, - @SerialName(thumbWidthField) - override val thumbWidth: Int? = null, - @SerialName(thumbHeightField) - override val thumbHeight: Int? = null, + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String? = null, + @SerialName(thumbnailWidthField) + override val thumbnailWidth: Int? = null, + @SerialName(thumbnailHeightField) + override val thumbnailHeight: Int? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt index bda5d0b884..50b69a3ac1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt @@ -19,8 +19,8 @@ import kotlinx.serialization.Serializable fun InlineQueryResultMpeg4GifImpl( id: InlineQueryIdentifier, url: String, - thumbUrl: String, - thumbMimeType: MimeType? = null, + thumbnailUrl: String, + thumbnailMimeType: MimeType? = null, width: Int? = null, height: Int? = null, duration: Int? = null, @@ -29,13 +29,13 @@ fun InlineQueryResultMpeg4GifImpl( parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultMpeg4GifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultMpeg4GifImpl(id, url, thumbnailUrl, thumbnailMimeType, width, height, duration, title, text, parseMode, null, replyMarkup, inputMessageContent) fun InlineQueryResultMpeg4GifImpl( id: InlineQueryIdentifier, url: String, - thumbUrl: String, - thumbMimeType: MimeType? = null, + thumbnailUrl: String, + thumbnailMimeType: MimeType? = null, width: Int? = null, height: Int? = null, duration: Int? = null, @@ -46,8 +46,8 @@ fun InlineQueryResultMpeg4GifImpl( ) = InlineQueryResultMpeg4GifImpl( id, url, - thumbUrl, - thumbMimeType, + thumbnailUrl, + thumbnailMimeType, width, height, duration, @@ -65,10 +65,10 @@ data class InlineQueryResultMpeg4GifImpl internal constructor( override val id: InlineQueryIdentifier, @SerialName(mpeg4GifUrlField) override val url: String, - @SerialName(thumbUrlField) - override val thumbUrl: String, - @SerialName(thumbMimeTypeField) - override val thumbMimeType: MimeType? = null, + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String, + @SerialName(thumbnailMimeTypeField) + override val thumbnailMimeType: MimeType? = null, @SerialName(mpeg4GifWidthField) override val width: Int? = null, @SerialName(mpeg4GifHeightField) @@ -94,8 +94,8 @@ data class InlineQueryResultMpeg4GifImpl internal constructor( } init { - if (thumbMimeType != null && thumbMimeType !in telegramInlineModeGifPermittedMimeTypes) { - error("Passed thumb mime type is not permitted in Telegram Bot API. Passed $thumbMimeType, but permitted $telegramInlineModeGifPermittedMimeTypes") + if (thumbnailMimeType != null && thumbnailMimeType !in telegramInlineModeGifPermittedMimeTypes) { + error("Passed thumb mime type is not permitted in Telegram Bot API. Passed $thumbnailMimeType, but permitted $telegramInlineModeGifPermittedMimeTypes") } } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt index 905a51f47d..13a40dccc5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt @@ -18,7 +18,7 @@ import kotlinx.serialization.Serializable fun InlineQueryResultPhotoImpl( id: InlineQueryIdentifier, url: String, - thumbUrl: String, + thumbnailUrl: String, width: Int? = null, height: Int? = null, title: String? = null, @@ -27,12 +27,12 @@ fun InlineQueryResultPhotoImpl( parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultPhotoImpl(id, url, thumbUrl, width, height, title, description, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultPhotoImpl(id, url, thumbnailUrl, width, height, title, description, text, parseMode, null, replyMarkup, inputMessageContent) fun InlineQueryResultPhotoImpl( id: InlineQueryIdentifier, url: String, - thumbUrl: String, + thumbnailUrl: String, width: Int? = null, height: Int? = null, title: String? = null, @@ -43,7 +43,7 @@ fun InlineQueryResultPhotoImpl( ) = InlineQueryResultPhotoImpl( id, url, - thumbUrl, + thumbnailUrl, width, height, title, @@ -61,8 +61,8 @@ data class InlineQueryResultPhotoImpl internal constructor( override val id: InlineQueryIdentifier, @SerialName(photoUrlField) override val url: String, - @SerialName(thumbUrlField) - override val thumbUrl: String, + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String, @SerialName(photoWidthField) override val width: Int? = null, @SerialName(photoHeightField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt index afd4b6ac3f..da1949d9c7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt @@ -29,12 +29,12 @@ data class InlineQueryResultVenue( override val googlePlaceId: GooglePlaceId? = null, @SerialName(googlePlaceTypeField) override val googlePlaceType: GooglePlaceType? = null, - @SerialName(thumbUrlField) - override val thumbUrl: String? = null, - @SerialName(thumbWidthField) - override val thumbWidth: Int? = null, - @SerialName(thumbHeightField) - override val thumbHeight: Int? = null, + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String? = null, + @SerialName(thumbnailWidthField) + override val thumbnailWidth: Int? = null, + @SerialName(thumbnailHeightField) + override val thumbnailHeight: Int? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt index c711860c18..31ce8a7e50 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt @@ -19,7 +19,7 @@ import kotlinx.serialization.Serializable fun InlineQueryResultVideoImpl( id: InlineQueryIdentifier, url: String, - thumbUrl: String, + thumbnailUrl: String, mimeType: MimeType, title: String, width: Int? = null, @@ -30,12 +30,12 @@ fun InlineQueryResultVideoImpl( parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultVideoImpl(id, url, thumbUrl, mimeType, title, width, height, duration, description, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultVideoImpl(id, url, thumbnailUrl, mimeType, title, width, height, duration, description, text, parseMode, null, replyMarkup, inputMessageContent) fun InlineQueryResultVideoImpl( id: InlineQueryIdentifier, url: String, - thumbUrl: String, + thumbnailUrl: String, mimeType: MimeType, title: String, width: Int? = null, @@ -48,7 +48,7 @@ fun InlineQueryResultVideoImpl( ) = InlineQueryResultVideoImpl( id, url, - thumbUrl, + thumbnailUrl, mimeType, title, width, @@ -68,8 +68,8 @@ data class InlineQueryResultVideoImpl internal constructor( override val id: InlineQueryIdentifier, @SerialName(videoUrlField) override val url: String, - @SerialName(thumbUrlField) - override val thumbUrl: String, + @SerialName(thumbnailUrlField) + override val thumbnailUrl: String, @SerialName(mimeTypeField) override val mimeType: MimeType, @SerialName(titleField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/ThumbSizedInlineQueryResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/ThumbSizedInlineQueryResult.kt index ed49bc5b70..a8c110da8d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/ThumbSizedInlineQueryResult.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/ThumbSizedInlineQueryResult.kt @@ -1,6 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts interface ThumbSizedInlineQueryResult : InlineQueryResult, ThumbedInlineQueryResult { + val thumbnailWidth: Int? + @Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnailWidth")) val thumbWidth: Int? + get() = thumbnailWidth + val thumbnailHeight: Int? + @Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnailHeight")) val thumbHeight: Int? -} \ No newline at end of file + get() = thumbnailHeight +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/ThumbedInlineQueryResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/ThumbedInlineQueryResult.kt index c81ae4a9e7..d2e9895351 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/ThumbedInlineQueryResult.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/ThumbedInlineQueryResult.kt @@ -3,9 +3,15 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts import dev.inmo.tgbotapi.utils.MimeType interface ThumbedInlineQueryResult : InlineQueryResult { + val thumbnailUrl: String? + @Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnailUrl")) val thumbUrl: String? + get() = thumbnailUrl } interface ThumbedWithMimeTypeInlineQueryResult : ThumbedInlineQueryResult { + val thumbnailMimeType: MimeType? + @Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnailMimeType")) val thumbMimeType: MimeType? -} \ No newline at end of file + get() = thumbnailMimeType +} From 79c9e6258f347e544a87b54050829f7cbdfd6dcf Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 12:28:16 +0600 Subject: [PATCH 10/28] add setStickerMaskPosition --- .../api/stickers/SetStickerMaskPosition.kt | 19 ++++++++++++++ .../stickers/SetStickerMaskPosition.kt | 26 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerMaskPosition.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerMaskPosition.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerMaskPosition.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerMaskPosition.kt new file mode 100644 index 0000000000..7d05db2349 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerMaskPosition.kt @@ -0,0 +1,19 @@ +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.stickers.SetStickerEmojiList +import dev.inmo.tgbotapi.requests.stickers.SetStickerMaskPosition +import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet +import dev.inmo.tgbotapi.types.files.Sticker +import dev.inmo.tgbotapi.types.stickers.MaskPosition + +suspend fun TelegramBot.setStickerMaskPosition( + sticker: FileId, + maskPosition: MaskPosition +) = execute( + SetStickerMaskPosition( + sticker, + maskPosition + ) +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerMaskPosition.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerMaskPosition.kt new file mode 100644 index 0000000000..853e7ad893 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerMaskPosition.kt @@ -0,0 +1,26 @@ +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.OwnerStickerSetAction +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.stickers.MaskPosition +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class SetStickerMaskPosition ( + @SerialName(stickerField) + override val sticker: FileId, + @SerialName(maskPositionField) + val maskPosition: MaskPosition +) : StickerAction { + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "setStickerMaskPosition" +} From b0e32e8ad93c041852f79eb584ec5b6f29f5aa29 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 12:43:09 +0600 Subject: [PATCH 11/28] add opportunity to send emoji with sticker --- .../requests/send/media/SendSticker.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt index 71bad4d3b8..3de84286d7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt @@ -8,14 +8,19 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import dev.inmo.tgbotapi.types.message.content.StickerContent +import dev.inmo.tgbotapi.utils.mapOfNotNull import dev.inmo.tgbotapi.utils.toJsonWithoutNulls import kotlinx.serialization.* import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.JsonPrimitive +import kotlinx.serialization.json.buildJsonObject +import kotlinx.serialization.json.put fun SendSticker( chatId: ChatIdentifier, sticker: InputFile, threadId: MessageThreadId? = chatId.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -32,7 +37,7 @@ fun SendSticker( replyMarkup ).let { when (sticker) { - is MultipartFile -> SendStickerByFile(it, sticker) + is MultipartFile -> SendStickerByFile(it, sticker, emoji) is FileId -> it } } @@ -69,8 +74,16 @@ data class SendStickerByFileId internal constructor( data class SendStickerByFile internal constructor( @Transient private val sendStickerByFileId: SendStickerByFileId, - val sticker: MultipartFile + val sticker: MultipartFile, + val emoji: String? ) : MultipartRequest>, Request> by sendStickerByFileId { override val mediaMap: Map = mapOf(stickerField to sticker) - override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer()) + override val paramsJson: JsonObject + get() { + return JsonObject( + mapOfNotNull( + emojiField to emoji ?.let { JsonPrimitive(it) } + ) + sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer()) + ) + } } From cd354e9456401a213bbbd0ed1a6e13c7a94842f1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 13:40:15 +0600 Subject: [PATCH 12/28] upgrade version up to 7.0.0 --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a70e7be7b6..12d7d0d378 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # TelegramBotAPI changelog -## 6.2.0 +## 7.0.0 ## 6.1.0 diff --git a/gradle.properties b/gradle.properties index c8e186f7b8..6932fd1002 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=6.2.0 +library_version=7.0.0 From afda5e0e7f144ab8d310edf802d4472e680d67a9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 14:00:57 +0600 Subject: [PATCH 13/28] rework of create new sticker set --- CHANGELOG.md | 4 + .../stickers/CreateNewAnimatedStickerSet.kt | 58 -------- .../api/stickers/CreateNewStaticStickerSet.kt | 50 ++----- .../api/stickers/CreateNewVideoStickerSet.kt | 58 -------- .../stickers/CreateNewAnimatedStickerSet.kt | 40 ------ .../stickers/CreateNewStaticStickerSet.kt | 40 ------ .../requests/stickers/CreateNewStickerSet.kt | 125 +++++++++++------- .../stickers/CreateNewVideoStickerSet.kt | 40 ------ .../requests/stickers/InputSticker.kt | 53 ++++++++ .../NewCreateNewStickerSetFunctions.kt | 105 --------------- .../OldCreateNewStickerSetFunctions.kt | 80 ----------- .../abstracts/CreateStickerSetAction.kt | 2 +- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 34 +++++ .../dev/inmo/tgbotapi/types/files/Sticker.kt | 7 + .../tgbotapi/types/stickers/StickerSet.kt | 23 ++-- 15 files changed, 200 insertions(+), 519 deletions(-) delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewVideoStickerSet.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewAnimatedStickerSet.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStaticStickerSet.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewVideoStickerSet.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/NewCreateNewStickerSetFunctions.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/OldCreateNewStickerSetFunctions.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 12d7d0d378..047f7877d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 7.0.0 +**THIS VERSION CONTAINS BREAKING CHANGES**: + +* Fully reworked mechanism of stickers creating + ## 6.1.0 * `Versions`: 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 deleted file mode 100644 index 57a024cfec..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt +++ /dev/null @@ -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 -) 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 19f512c8a2..cbd0b41fdb 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 @@ -3,56 +3,30 @@ 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.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.UserId import dev.inmo.tgbotapi.types.stickers.MaskPosition -suspend fun TelegramBot.createNewStaticStickerSet( +suspend fun TelegramBot.createNewStickerSet( userId: UserId, name: String, title: String, - sticker: FileId, - emojis: String, - containsMasks: Boolean? = null, - maskPosition: MaskPosition? = null + stickersFormat: StickerFormat, + stickers: List, ) = execute( - 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, title, sticker, emojis, containsMasks, maskPosition) + CreateNewStickerSet(userId, name, title, stickersFormat, stickers) ) -suspend fun TelegramBot.createNewStaticStickerSet( +suspend fun TelegramBot.createNewStickerSet( user: CommonUser, name: String, title: String, - sticker: FileId, - emojis: String, - containsMasks: Boolean? = null, - maskPosition: MaskPosition? = null -) = 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 + stickersFormat: StickerFormat, + stickers: List, +) = createNewStickerSet( + user.id, name, title, stickersFormat, stickers ) 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 deleted file mode 100644 index 9e8360244a..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewVideoStickerSet.kt +++ /dev/null @@ -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 -) 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 deleted file mode 100644 index 0dbebdb595..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewAnimatedStickerSet.kt +++ /dev/null @@ -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" -} 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 deleted file mode 100644 index 6e12b9d012..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStaticStickerSet.kt +++ /dev/null @@ -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" -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt index 537c5f70b5..7895e7ef93 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt @@ -7,36 +7,30 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.stickers.MaskPosition 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, name: String, title: String, - emojis: String, - stickerType: StickerType = StickerType.Regular, - pngSticker: InputFile? = null, - tgsSticker: InputFile? = null, - webmSticker: InputFile? = null, - maskPosition: MaskPosition? = null + stickersFormat: StickerFormat, + stickers: List, + needsRepainting: Boolean? = null ): Request { - val data = CreateNewStickerSet( - userId, - name, - title, - emojis, - stickerType, - pngSticker as? FileId, - tgsSticker as? FileId, - webmSticker as? FileId, - maskPosition - ) - return if (pngSticker is MultipartFile || tgsSticker is MultipartFile || webmSticker is MultipartFile) { + val data = when(stickers.first()) { + is InputSticker.Mask -> CreateNewStickerSet.Mask(userId, name, title, stickersFormat, stickers.filterIsInstance()) + is InputSticker.WithKeywords.CustomEmoji -> CreateNewStickerSet.CustomEmoji(userId, name, title, stickersFormat, stickers.filterIsInstance(), needsRepainting) + is InputSticker.WithKeywords.Regular -> CreateNewStickerSet.Regular(userId, name, title, stickersFormat, stickers.filterIsInstance()) + } + val multipartParts = stickers.mapNotNull { (it.sticker as? MultipartFile) } + return if (multipartParts.isNotEmpty()) { CommonMultipartFileRequest( data, - listOfNotNull( - (pngSticker as? MultipartFile) ?.let { pngStickerField to it }, - (tgsSticker as? MultipartFile) ?.let { tgsStickerField to it }, - (webmSticker as? MultipartFile) ?.let { webmStickerField to it }, - ).toMap() + multipartParts.associateBy { it.fileId } ) } else { data @@ -44,34 +38,67 @@ internal fun CreateNewStickerSet( } @Serializable -data class CreateNewStickerSet 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(stickerTypeField) - val stickerType: StickerType = StickerType.Regular, - @SerialName(pngStickerField) - 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") - } - } +sealed interface CreateNewStickerSet : CreateStickerSetAction { + val stickerType: StickerType + val stickers: List + val stickersFormat: StickerFormat override val requestSerializer: SerializationStrategy<*> get() = serializer() override fun method(): String = "createNewStickerSet" + + @Serializable + data class Regular( + @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 + ) : CreateNewStickerSet { + @SerialName(stickerTypeField) + override val stickerType: StickerType + get() = StickerType.Regular + } + @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 + ) : 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, + @SerialName(needsRepaintingField) + val needsRepainting: Boolean? = null + ) : CreateNewStickerSet { + @SerialName(stickerTypeField) + override val stickerType: StickerType + get() = StickerType.CustomEmoji + } } 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 deleted file mode 100644 index cfaeb78075..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewVideoStickerSet.kt +++ /dev/null @@ -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" -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt new file mode 100644 index 0000000000..aaac6fc0cc --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt @@ -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 + + @Serializable + data class Mask( + @SerialName(stickerField) + override val sticker: InputFile, + @SerialName(emojiListField) + override val emojisList: List, + @SerialName(maskPositionField) + val maskPosition: MaskPosition + ) : InputSticker + + @Serializable + sealed interface WithKeywords : InputSticker { + val keywords: List + + @Serializable + data class Regular( + @SerialName(stickerField) + override val sticker: InputFile, + @SerialName(emojiListField) + override val emojisList: List, + @SerialName(keywordsField) + override val keywords: List + ) : WithKeywords + + @Serializable + data class CustomEmoji( + @SerialName(stickerField) + override val sticker: InputFile, + @SerialName(emojiListField) + override val emojisList: List, + @SerialName(keywordsField) + override val keywords: List + ) : WithKeywords + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/NewCreateNewStickerSetFunctions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/NewCreateNewStickerSetFunctions.kt deleted file mode 100644 index 2cd56868bf..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/NewCreateNewStickerSetFunctions.kt +++ /dev/null @@ -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 = CreateNewStickerSet( - userId, - name, - title, - emojis, - StickerType.Regular, - pngSticker = sticker -) - -fun CreateNewRegularVideoStickerSet( - userId: UserId, - name: String, - title: String, - sticker: InputFile, - emojis: String -): Request = CreateNewStickerSet( - userId, - name, - title, - emojis, - StickerType.Regular, - webmSticker = sticker -) - -fun CreateNewRegularAnimatedStickerSet( - userId: UserId, - name: String, - title: String, - sticker: InputFile, - emojis: String -): Request = CreateNewStickerSet( - userId, - name, - title, - emojis, - StickerType.Regular, - tgsSticker = sticker -) - - -fun CreateNewMaskStickerSet( - userId: UserId, - name: String, - title: String, - sticker: InputFile, - emojis: String, - maskPosition: MaskPosition -): Request = 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 = 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 = CreateNewStickerSet( - userId, - name, - title, - emojis, - StickerType.Mask, - tgsSticker = sticker, - maskPosition = maskPosition -) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/OldCreateNewStickerSetFunctions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/OldCreateNewStickerSetFunctions.kt deleted file mode 100644 index 69f747c53f..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/OldCreateNewStickerSetFunctions.kt +++ /dev/null @@ -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 = 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 = 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 = 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 = CreateNewStickerSet( - userId, - name, - title, - emojis, - if (containsMasks == true) StickerType.Mask else StickerType.Regular, - tgsSticker = sticker, - maskPosition = maskPosition -) 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 index 31091c0592..7ef6ee655f 100644 --- 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 @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.requests.stickers.abstracts -interface CreateStickerSetAction : StandardStickerSetAction { +interface CreateStickerSetAction : OwnerStickerSetAction { val title: String } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index cb3abb8999..73fa5dec7b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -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 { + 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 degreesLimit = 1 .. 360 @@ -388,6 +420,8 @@ const val webmStickerField = "webm_sticker" const val oldChatMemberField = "old_chat_member" const val newChatMemberField = "new_chat_member" const val stickerTypeField = "sticker_type" +const val stickerFormatField = "sticker_format" +const val needsRepaintingField = "needs_repainting" const val okField = "ok" const val captionField = "caption" 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 e017de9a20..48932491ab 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 @@ -330,6 +330,7 @@ data class MaskVideoSticker( @Serializable sealed interface CustomEmojiSticker : Sticker { val customEmojiId: CustomEmojiId + val needsRepainting: Boolean } @Serializable @@ -352,6 +353,8 @@ data class CustomEmojiSimpleSticker( override val stickerSetName: StickerSetName? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, + @SerialName(needsRepaintingField) + override val needsRepainting: Boolean = false ) : CustomEmojiSticker @Serializable data class CustomEmojiAnimatedSticker( @@ -373,6 +376,8 @@ data class CustomEmojiAnimatedSticker( override val stickerSetName: StickerSetName? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, + @SerialName(needsRepaintingField) + override val needsRepainting: Boolean = false, ) : CustomEmojiSticker, AnimatedSticker @Serializable data class CustomEmojiVideoSticker( @@ -394,6 +399,8 @@ data class CustomEmojiVideoSticker( override val stickerSetName: StickerSetName? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, + @SerialName(needsRepaintingField) + override val needsRepainting: Boolean = false, ) : CustomEmojiSticker, VideoSticker @Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt index fc53396886..e86e5215a2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt @@ -30,7 +30,10 @@ sealed interface StickerSet { get() = false val isVideo: Boolean get() = false + val thumbnail: PhotoSize? + @Deprecated("Renamed in telegram bot api") val thumb: PhotoSize? + get() = thumbnail @Deprecated("Will be removed soon due to its redundancy") val containsMasks: Boolean get() = this is MaskStickerSet @@ -146,7 +149,7 @@ data class RegularSimpleStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : RegularStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -162,7 +165,7 @@ data class RegularAnimatedStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : RegularStickerSet, AnimatedStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -178,7 +181,7 @@ data class RegularVideoStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : RegularStickerSet, VideoStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -194,7 +197,7 @@ data class MaskSimpleStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : MaskStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -210,7 +213,7 @@ data class MaskAnimatedStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : MaskStickerSet, AnimatedStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -226,7 +229,7 @@ data class MaskVideoStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : MaskStickerSet, VideoStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -242,7 +245,7 @@ data class CustomEmojiSimpleStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : CustomEmojiStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -258,7 +261,7 @@ data class CustomEmojiAnimatedStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : CustomEmojiStickerSet, AnimatedStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -274,7 +277,7 @@ data class CustomEmojiVideoStickerSet( @SerialName(stickersField) override val stickers: List, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null + override val thumbnail: PhotoSize? = null ) : CustomEmojiStickerSet, VideoStickerSet { @SerialName(stickerTypeField) @EncodeDefault @@ -292,6 +295,6 @@ data class UnknownStickerSet( @SerialName(stickerTypeField) override val stickerType: StickerType, @SerialName(thumbnailField) - override val thumb: PhotoSize? = null, + override val thumbnail: PhotoSize? = null, val raw: JsonElement ) : CustomEmojiStickerSet, VideoStickerSet From 1b4d13e452bff0365fe8f7e00af5430c91d8a6f8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 14:20:34 +0600 Subject: [PATCH 14/28] rework of addStickerToSet --- CHANGELOG.md | 2 +- .../api/stickers/AddStaticStickerToSet.kt | 125 +++++++++--------- .../stickers/AddAnimatedStickerToSet.kt | 50 ------- .../stickers/AddStaticStickerToSet.kt | 50 ------- ...ideoStickerToSet.kt => AddStickerToSet.kt} | 29 ++-- .../abstracts/StandardStickerSetAction.kt | 4 +- 6 files changed, 76 insertions(+), 184 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddAnimatedStickerToSet.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddStaticStickerToSet.kt rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/{AddVideoStickerToSet.kt => AddStickerToSet.kt} (52%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 047f7877d1..3ae378e21b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ **THIS VERSION CONTAINS BREAKING CHANGES**: -* Fully reworked mechanism of stickers creating +* Fully reworked mechanism of stickers creating and adding ## 6.1.0 diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt index 58491ea03c..5008e44952 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt @@ -2,89 +2,94 @@ 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.InputFile import dev.inmo.tgbotapi.requests.abstracts.MultipartFile -import dev.inmo.tgbotapi.requests.stickers.AddStaticStickerToSet +import dev.inmo.tgbotapi.requests.stickers.AddStickerToSet +import dev.inmo.tgbotapi.requests.stickers.InputSticker +import dev.inmo.tgbotapi.types.StickerType import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.stickers.MaskPosition import dev.inmo.tgbotapi.types.stickers.StickerSet -suspend fun TelegramBot.addStaticStickerToSet( +suspend fun TelegramBot.addStickerToSet( userId: UserId, stickerSetName: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null + inputSticker: InputSticker ) = execute( - AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition) + AddStickerToSet(userId, stickerSetName, inputSticker) ) -suspend fun TelegramBot.addStaticStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = execute( - AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition) -) - -suspend fun TelegramBot.addStaticStickerToSet( - user: CommonUser, - stickerSetName: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addStaticStickerToSet( - user.id, stickerSetName, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addStaticStickerToSet( - user: CommonUser, - stickerSetName: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addStaticStickerToSet( - user.id, stickerSetName, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addStaticStickerToSet( +suspend fun TelegramBot.addStickerToSet( userId: UserId, stickerSet: StickerSet, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addStaticStickerToSet( - userId, stickerSet.name, sticker, emojis, maskPosition + sticker: InputFile, + emojis: List, + keywords: List = emptyList() +) = addStickerToSet( + userId, + stickerSet.name, + when (stickerSet.stickerType) { + StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji( + sticker, + emojis, + keywords + ) + StickerType.Mask -> error("Unable to create Mask sticker to the set without maskPosition parameter") + StickerType.Regular -> InputSticker.WithKeywords.Regular( + sticker, + emojis, + keywords + ) + is StickerType.Unknown -> error("Unable to create sticker to the set with type ${stickerSet.stickerType}") + } ) -suspend fun TelegramBot.addStaticStickerToSet( +suspend fun TelegramBot.addStickerToSet( userId: UserId, stickerSet: StickerSet, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addStaticStickerToSet( - userId, stickerSet.name, sticker, emojis, maskPosition + sticker: InputFile, + emojis: List, + maskPosition: MaskPosition +) = addStickerToSet( + userId, + stickerSet.name, + when (stickerSet.stickerType) { + StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji( + sticker, + emojis, + emptyList() + ) + StickerType.Mask -> InputSticker.Mask( + sticker, + emojis, + maskPosition + ) + StickerType.Regular -> InputSticker.WithKeywords.Regular( + sticker, + emojis, + emptyList() + ) + is StickerType.Unknown -> error("Unable to create sticker to the set with type ${stickerSet.stickerType}") + } ) -suspend fun TelegramBot.addStaticStickerToSet( +suspend fun TelegramBot.addStickerToSet( user: CommonUser, stickerSet: StickerSet, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addStaticStickerToSet( - user.id, stickerSet.name, sticker, emojis, maskPosition + sticker: InputFile, + emojis: List, + keywords: List = emptyList() +) = addStickerToSet( + user.id, stickerSet, sticker, emojis, keywords ) -suspend fun TelegramBot.addStaticStickerToSet( +suspend fun TelegramBot.addStickerToSet( user: CommonUser, stickerSet: StickerSet, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addStaticStickerToSet( - user.id, stickerSet.name, sticker, emojis, maskPosition + sticker: InputFile, + emojis: List, + maskPosition: MaskPosition +) = addStickerToSet( + user.id, stickerSet, sticker, emojis, maskPosition ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddAnimatedStickerToSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddAnimatedStickerToSet.kt deleted file mode 100644 index 3789e835f2..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddAnimatedStickerToSet.kt +++ /dev/null @@ -1,50 +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.StandardStickerSetAction -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.stickers.MaskPosition -import kotlinx.serialization.* - -fun AddAnimatedStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: InputFile, - emojis: String, - maskPosition: MaskPosition? = null -): Request { - val data = AddAnimatedStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition) - return when (sticker) { - is MultipartFile -> CommonMultipartFileRequest( - data, - mapOf(tgsStickerField to sticker) - ) - is FileId -> data - } -} - -@Serializable -data class AddAnimatedStickerToSet internal constructor( - @SerialName(userIdField) - override val userId: UserId, - @SerialName(nameField) - override val name: String, - @SerialName(emojisField) - override val emojis: String, - @SerialName(tgsStickerField) - val sticker: FileId? = null, - @SerialName(maskPositionField) - override val maskPosition: MaskPosition? = null -) : StandardStickerSetAction { - init { - if(emojis.isEmpty()) { - throw IllegalArgumentException("Emojis must not be empty") - } - } - - override val requestSerializer: SerializationStrategy<*> - get() = serializer() - - override fun method(): String = "addStickerToSet" -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddStaticStickerToSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddStaticStickerToSet.kt deleted file mode 100644 index 521e6ca245..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddStaticStickerToSet.kt +++ /dev/null @@ -1,50 +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.StandardStickerSetAction -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.stickers.MaskPosition -import kotlinx.serialization.* - -fun AddStaticStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: InputFile, - emojis: String, - maskPosition: MaskPosition? = null -): Request { - val data = AddStaticStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition) - return when (sticker) { - is MultipartFile -> CommonMultipartFileRequest( - data, - mapOf(pngStickerField to sticker) - ) - is FileId -> data - } -} - -@Serializable -data class AddStaticStickerToSet internal constructor( - @SerialName(userIdField) - override val userId: UserId, - @SerialName(nameField) - override val name: String, - @SerialName(emojisField) - override val emojis: String, - @SerialName(pngStickerField) - val sticker: FileId? = null, - @SerialName(maskPositionField) - override val maskPosition: MaskPosition? = null -) : StandardStickerSetAction { - init { - if(emojis.isEmpty()) { - throw IllegalArgumentException("Emojis must not be empty") - } - } - - override val requestSerializer: SerializationStrategy<*> - get() = serializer() - - override fun method(): String = "addStickerToSet" -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddVideoStickerToSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddStickerToSet.kt similarity index 52% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddVideoStickerToSet.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddStickerToSet.kt index 456e452dc1..a5a1ce7cf2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddVideoStickerToSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/AddStickerToSet.kt @@ -4,45 +4,32 @@ import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.stickers.MaskPosition import kotlinx.serialization.* -fun AddVideoStickerToSet( +fun AddStickerToSet( userId: UserId, stickerSetName: String, - sticker: InputFile, - emojis: String, - maskPosition: MaskPosition? = null + inputSticker: InputSticker ): Request { - val data = AddVideoStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition) - return when (sticker) { + val data = AddStickerToSetData(userId, stickerSetName, inputSticker) + return when (val sticker = inputSticker.sticker) { is MultipartFile -> CommonMultipartFileRequest( data, - mapOf(webmStickerField to sticker) + mapOf(sticker.fileId to sticker) ) is FileId -> data } } @Serializable -data class AddVideoStickerToSet internal constructor( +data class AddStickerToSetData internal constructor( @SerialName(userIdField) override val userId: UserId, @SerialName(nameField) override val name: String, - @SerialName(emojisField) - override val emojis: String, - @SerialName(webmStickerField) - val sticker: FileId? = null, - @SerialName(maskPositionField) - override val maskPosition: MaskPosition? = null + @SerialName(stickerField) + override val inputSticker: InputSticker ) : StandardStickerSetAction { - init { - if(emojis.isEmpty()) { - throw IllegalArgumentException("Emojis must not be empty") - } - } - override val requestSerializer: SerializationStrategy<*> get() = serializer() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction.kt index ea7368cba7..4df281c4c2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.requests.stickers.abstracts +import dev.inmo.tgbotapi.requests.stickers.InputSticker import dev.inmo.tgbotapi.types.stickers.MaskPosition interface StandardStickerSetAction : OwnerStickerSetAction { - val emojis: String // must be more than one - val maskPosition: MaskPosition? + val inputSticker: InputSticker } From 4390c12180815746cea59ba62966488d07b1abf0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 14:24:42 +0600 Subject: [PATCH 15/28] update uploadStickerFile --- .../extensions/api/stickers/UploadStickerFile.kt | 11 +++++++---- .../tgbotapi/requests/stickers/UploadStickerFile.kt | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt index ef815150a1..64cce2e2a4 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt @@ -3,19 +3,22 @@ package dev.inmo.tgbotapi.extensions.api.stickers import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.MultipartFile import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile +import dev.inmo.tgbotapi.types.StickerFormat import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.UserId suspend fun TelegramBot.uploadStickerFile( userId: UserId, - sticker: MultipartFile + sticker: MultipartFile, + stickerFormat: StickerFormat ) = execute( - UploadStickerFile(userId, sticker) + UploadStickerFile(userId, sticker, stickerFormat) ) suspend fun TelegramBot.uploadStickerFile( user: CommonUser, - sticker: MultipartFile + sticker: MultipartFile, + stickerFormat: StickerFormat ) = execute( - UploadStickerFile(user.id, sticker) + UploadStickerFile(user.id, sticker, stickerFormat) ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/UploadStickerFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/UploadStickerFile.kt index b65910036d..7d3d793e17 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/UploadStickerFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/UploadStickerFile.kt @@ -13,7 +13,9 @@ data class UploadStickerFile( @SerialName(userIdField) val userId: UserId, @Transient - val sticker: MultipartFile = throw IllegalStateException("Detected autocreating try: this class can't be deserialized") + val sticker: MultipartFile = throw IllegalStateException("Detected autocreating try: this class can't be deserialized"), + @SerialName(stickerFormatField) + val stickerFormat: StickerFormat ): MultipartRequest { init { // TODO:: add check of width/height of image and type of file - it must be png with max side length is 512px @@ -21,7 +23,7 @@ data class UploadStickerFile( override fun method(): String = "uploadStickerFile" @Transient - override val mediaMap: Map = mapOf(pngStickerField to sticker) + override val mediaMap: Map = mapOf(stickerField to sticker) @Transient override val paramsJson: JsonObject = toJsonWithoutNulls(serializer()) override val resultDeserializer: DeserializationStrategy From dff04d26ca3b0c7967bcd152fbe25b30cb6ad97c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 14:29:55 +0600 Subject: [PATCH 16/28] add support of setCustomEmojiStickerSetThumbnail --- .../stickers/SetCustomEmojiStickerSetThumb.kt | 26 +++++++++++++++++++ .../SetCustomEmojiStickerSetThumbnail.kt | 21 +++++++++++++++ .../stickers/SetStickerSetThumbnail.kt | 14 ---------- 3 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetCustomEmojiStickerSetThumb.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetCustomEmojiStickerSetThumbnail.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetCustomEmojiStickerSetThumb.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetCustomEmojiStickerSetThumb.kt new file mode 100644 index 0000000000..b75abd9786 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetCustomEmojiStickerSetThumb.kt @@ -0,0 +1,26 @@ +package dev.inmo.tgbotapi.extensions.api.thumbs + +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.SetCustomEmojiStickerSetThumbnail +import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.StickerSetName +import dev.inmo.tgbotapi.types.chat.CommonUser +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.stickers.StickerSet + +suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail( + stickerSetName: StickerSetName, + customEmojiId: CustomEmojiId +) = execute( + SetCustomEmojiStickerSetThumbnail(stickerSetName, customEmojiId) +) + +suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail( + stickerSet: StickerSet, + customEmojiId: CustomEmojiId +) = setCustomEmojiStickerSetThumbnail( + stickerSet.name, customEmojiId +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetCustomEmojiStickerSetThumbnail.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetCustomEmojiStickerSetThumbnail.kt new file mode 100644 index 0000000000..701ba5bf9a --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetCustomEmojiStickerSetThumbnail.kt @@ -0,0 +1,21 @@ +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.OwnerStickerSetAction +import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* + +@Serializable +data class SetCustomEmojiStickerSetThumbnail ( + @SerialName(nameField) + override val name: StickerSetName, + @SerialName(customEmojiIdField) + val customEmojiId: CustomEmojiId +) : StickerSetAction { + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "setCustomEmojiStickerSetThumbnail" +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumbnail.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumbnail.kt index 588ff1b64b..122050922c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumbnail.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/SetStickerSetThumbnail.kt @@ -17,13 +17,6 @@ fun SetStickerSetThumbnail( ) } -@Deprecated("Renamed", ReplaceWith("SetStickerSetThumbnail(userId, stickerSetName, thumbnail)", "dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail")) -fun SetStickerSetThumb( - userId: UserId, - stickerSetName: String, - thumbnail: MultipartFile -): Request = SetStickerSetThumbnail(userId, stickerSetName, thumbnail) - @Serializable data class SetStickerSetThumbnail ( @SerialName(userIdField) @@ -38,10 +31,3 @@ data class SetStickerSetThumbnail ( override fun method(): String = "setStickerSetThumbnail" } - -@Deprecated("Renamed", ReplaceWith("SetStickerSetThumbnail(userId, name, thumbnail)", "dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail")) -fun SetStickerSetThumb( - userId: UserId, - name: StickerSetName, - thumbnail: FileId? = null -) = SetStickerSetThumbnail(userId, name, thumbnail) From 2d2310daca66fdc286739bac1110d6146d5a6daa Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 14:43:34 +0600 Subject: [PATCH 17/28] fixes in build --- .../tgbotapi/extensions/api/send/Replies.kt | 6 +- .../api/send/RepliesWithChatsAndMessages.kt | 6 +- .../tgbotapi/extensions/api/send/Sends.kt | 6 +- .../extensions/api/send/media/SendSticker.kt | 12 ++- .../api/stickers/AddAnimatedStickerToSet.kt | 90 ------------------- ...aticStickerToSet.kt => AddStickerToSet.kt} | 2 - .../api/stickers/AddVideoStickerToSet.kt | 90 ------------------- .../CreateNewMaskAnimatedStickerSet.kt | 54 ----------- .../api/stickers/CreateNewMaskStickerSet.kt | 54 ----------- .../stickers/CreateNewMaskVideoStickerSet.kt | 54 ----------- .../CreateNewRegularAnimatedStickerSet.kt | 50 ----------- .../stickers/CreateNewRegularStickerSet.kt | 50 ----------- .../CreateNewRegularVideoStickerSet.kt | 50 ----------- .../types/message/content/StickerContent.kt | 1 + .../extensions/utils/ClassCastsNew.kt | 38 ++++++++ 15 files changed, 59 insertions(+), 504 deletions(-) delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt rename tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/{AddStaticStickerToSet.kt => AddStickerToSet.kt} (96%) delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddVideoStickerToSet.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskAnimatedStickerSet.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskStickerSet.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskVideoStickerSet.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularAnimatedStickerSet.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularStickerSet.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularVideoStickerSet.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index e22e4d39e1..69ef258f6a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -685,20 +685,22 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithSticker( to: Message, sticker: InputFile, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, sticker: Sticker, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Videos diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 6547d1db14..67af3688cb 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -761,22 +761,24 @@ suspend inline fun TelegramBot.replyWithSticker( toMessageId: MessageId, sticker: InputFile, threadId: MessageThreadId? = toChatId.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: Sticker, threadId: MessageThreadId? = toChatId.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Videos diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt index 70455fc405..c9ce336499 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt @@ -1111,12 +1111,13 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, sticker: Sticker, threadId: MessageThreadId? = chatId.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendSticker] request @@ -1127,12 +1128,13 @@ suspend fun TelegramBot.send( chat: Chat, sticker: Sticker, threadId: MessageThreadId? = chat.id.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt index f3e4812bd5..26ee351e09 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt @@ -19,13 +19,14 @@ suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, sticker: InputFile, threadId: MessageThreadId? = chatId.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) /** @@ -36,12 +37,13 @@ suspend fun TelegramBot.sendSticker( chat: Chat, sticker: InputFile, threadId: MessageThreadId? = chat.id.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat.id, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat.id, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -51,12 +53,13 @@ suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, sticker: Sticker, threadId: MessageThreadId? = chatId.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chatId, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chatId, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -66,9 +69,10 @@ suspend fun TelegramBot.sendSticker( chat: Chat, sticker: Sticker, threadId: MessageThreadId? = chat.id.threadId, + emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt deleted file mode 100644 index fda0cee830..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt +++ /dev/null @@ -1,90 +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.AddAnimatedStickerToSet -import dev.inmo.tgbotapi.types.chat.CommonUser -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition -import dev.inmo.tgbotapi.types.stickers.StickerSet - -suspend fun TelegramBot.addAnimatedStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = execute( - AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition) -) - -suspend fun TelegramBot.addAnimatedStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = execute( - AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition) -) - -suspend fun TelegramBot.addAnimatedStickerToSet( - user: CommonUser, - stickerSetName: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addAnimatedStickerToSet( - user.id, stickerSetName, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addAnimatedStickerToSet( - user: CommonUser, - stickerSetName: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addAnimatedStickerToSet( - user.id, stickerSetName, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addAnimatedStickerToSet( - userId: UserId, - stickerSet: StickerSet, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addAnimatedStickerToSet( - userId, stickerSet.name, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addAnimatedStickerToSet( - userId: UserId, - stickerSet: StickerSet, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addAnimatedStickerToSet( - userId, stickerSet.name, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addAnimatedStickerToSet( - user: CommonUser, - stickerSet: StickerSet, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addAnimatedStickerToSet( - user.id, stickerSet.name, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addAnimatedStickerToSet( - user: CommonUser, - stickerSet: StickerSet, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addAnimatedStickerToSet( - user.id, stickerSet.name, sticker, emojis, maskPosition -) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt similarity index 96% rename from tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt index 5008e44952..cc167680ba 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt @@ -1,9 +1,7 @@ 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.InputFile -import dev.inmo.tgbotapi.requests.abstracts.MultipartFile import dev.inmo.tgbotapi.requests.stickers.AddStickerToSet import dev.inmo.tgbotapi.requests.stickers.InputSticker import dev.inmo.tgbotapi.types.StickerType diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddVideoStickerToSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddVideoStickerToSet.kt deleted file mode 100644 index 34f9ed4dd5..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddVideoStickerToSet.kt +++ /dev/null @@ -1,90 +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.AddVideoStickerToSet -import dev.inmo.tgbotapi.types.chat.CommonUser -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition -import dev.inmo.tgbotapi.types.stickers.StickerSet - -suspend fun TelegramBot.addVideoStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = execute( - AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition) -) - -suspend fun TelegramBot.addVideoStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = execute( - AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition) -) - -suspend fun TelegramBot.addVideoStickerToSet( - user: CommonUser, - stickerSetName: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addVideoStickerToSet( - user.id, stickerSetName, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addVideoStickerToSet( - user: CommonUser, - stickerSetName: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addVideoStickerToSet( - user.id, stickerSetName, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addVideoStickerToSet( - userId: UserId, - stickerSet: StickerSet, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addVideoStickerToSet( - userId, stickerSet.name, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addVideoStickerToSet( - userId: UserId, - stickerSet: StickerSet, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addVideoStickerToSet( - userId, stickerSet.name, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addVideoStickerToSet( - user: CommonUser, - stickerSet: StickerSet, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addVideoStickerToSet( - user.id, stickerSet.name, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.addVideoStickerToSet( - user: CommonUser, - stickerSet: StickerSet, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addVideoStickerToSet( - user.id, stickerSet.name, sticker, emojis, maskPosition -) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskAnimatedStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskAnimatedStickerSet.kt deleted file mode 100644 index 23dea7d300..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskAnimatedStickerSet.kt +++ /dev/null @@ -1,54 +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.* -import dev.inmo.tgbotapi.types.chat.CommonUser -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition - -suspend fun TelegramBot.createNewMaskAnimatedStickerSet( - userId: UserId, - name: String, - title: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition -) = execute( - CreateNewMaskAnimatedStickerSet(userId, name, title, sticker, emojis, maskPosition) -) - -suspend fun TelegramBot.createNewMaskAnimatedStickerSet( - userId: UserId, - name: String, - title: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition -) = execute( - CreateNewMaskAnimatedStickerSet(userId, name, title, sticker, emojis, maskPosition) -) - - -suspend fun TelegramBot.createNewMaskAnimatedStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition -) = createNewMaskAnimatedStickerSet( - user.id, name, title, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.createNewMaskAnimatedStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition -) = createNewMaskAnimatedStickerSet( - user.id, name, title, sticker, emojis, maskPosition -) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskStickerSet.kt deleted file mode 100644 index 743f19300f..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskStickerSet.kt +++ /dev/null @@ -1,54 +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.* -import dev.inmo.tgbotapi.types.chat.CommonUser -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition - -suspend fun TelegramBot.createNewMaskStickerSet( - userId: UserId, - name: String, - title: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition -) = execute( - CreateNewMaskStickerSet(userId, name, title, sticker, emojis, maskPosition) -) - -suspend fun TelegramBot.createNewMaskStickerSet( - userId: UserId, - name: String, - title: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition -) = execute( - CreateNewMaskStickerSet(userId, name, title, sticker, emojis, maskPosition) -) - - -suspend fun TelegramBot.createNewMaskStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition -) = createNewMaskStickerSet( - user.id, name, title, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.createNewMaskStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition -) = createNewMaskStickerSet( - user.id, name, title, sticker, emojis, maskPosition -) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskVideoStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskVideoStickerSet.kt deleted file mode 100644 index c519ec0565..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewMaskVideoStickerSet.kt +++ /dev/null @@ -1,54 +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.* -import dev.inmo.tgbotapi.types.chat.CommonUser -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition - -suspend fun TelegramBot.createNewMaskVideoStickerSet( - userId: UserId, - name: String, - title: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition -) = execute( - CreateNewMaskVideoStickerSet(userId, name, title, sticker, emojis, maskPosition) -) - -suspend fun TelegramBot.createNewMaskVideoStickerSet( - userId: UserId, - name: String, - title: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition -) = execute( - CreateNewMaskVideoStickerSet(userId, name, title, sticker, emojis, maskPosition) -) - - -suspend fun TelegramBot.createNewMaskVideoStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition -) = createNewMaskVideoStickerSet( - user.id, name, title, sticker, emojis, maskPosition -) - -suspend fun TelegramBot.createNewMaskVideoStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition -) = createNewMaskVideoStickerSet( - user.id, name, title, sticker, emojis, maskPosition -) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularAnimatedStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularAnimatedStickerSet.kt deleted file mode 100644 index 3b64f0ea6d..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularAnimatedStickerSet.kt +++ /dev/null @@ -1,50 +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.* -import dev.inmo.tgbotapi.types.chat.CommonUser -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition - -suspend fun TelegramBot.createNewRegularAnimatedStickerSet( - userId: UserId, - name: String, - title: String, - sticker: FileId, - emojis: String -) = execute( - CreateNewRegularAnimatedStickerSet(userId, name, title, sticker, emojis) -) - -suspend fun TelegramBot.createNewRegularAnimatedStickerSet( - userId: UserId, - name: String, - title: String, - sticker: MultipartFile, - emojis: String -) = execute( - CreateNewRegularAnimatedStickerSet(userId, name, title, sticker, emojis) -) - - -suspend fun TelegramBot.createNewRegularAnimatedStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: FileId, - emojis: String -) = createNewRegularAnimatedStickerSet( - user.id, name, title, sticker, emojis -) - -suspend fun TelegramBot.createNewRegularAnimatedStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: MultipartFile, - emojis: String -) = createNewRegularAnimatedStickerSet( - user.id, name, title, sticker, emojis -) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularStickerSet.kt deleted file mode 100644 index a48a4d2afe..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularStickerSet.kt +++ /dev/null @@ -1,50 +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.* -import dev.inmo.tgbotapi.types.chat.CommonUser -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition - -suspend fun TelegramBot.createNewRegularStickerSet( - userId: UserId, - name: String, - title: String, - sticker: FileId, - emojis: String -) = execute( - CreateNewRegularStickerSet(userId, name, title, sticker, emojis) -) - -suspend fun TelegramBot.createNewRegularStickerSet( - userId: UserId, - name: String, - title: String, - sticker: MultipartFile, - emojis: String -) = execute( - CreateNewRegularStickerSet(userId, name, title, sticker, emojis) -) - - -suspend fun TelegramBot.createNewRegularStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: FileId, - emojis: String -) = createNewRegularStickerSet( - user.id, name, title, sticker, emojis -) - -suspend fun TelegramBot.createNewRegularStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: MultipartFile, - emojis: String -) = createNewRegularStickerSet( - user.id, name, title, sticker, emojis -) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularVideoStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularVideoStickerSet.kt deleted file mode 100644 index a27c7b1e08..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewRegularVideoStickerSet.kt +++ /dev/null @@ -1,50 +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.* -import dev.inmo.tgbotapi.types.chat.CommonUser -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.stickers.MaskPosition - -suspend fun TelegramBot.createNewRegularVideoStickerSet( - userId: UserId, - name: String, - title: String, - sticker: FileId, - emojis: String -) = execute( - CreateNewRegularVideoStickerSet(userId, name, title, sticker, emojis) -) - -suspend fun TelegramBot.createNewRegularVideoStickerSet( - userId: UserId, - name: String, - title: String, - sticker: MultipartFile, - emojis: String -) = execute( - CreateNewRegularVideoStickerSet(userId, name, title, sticker, emojis) -) - - -suspend fun TelegramBot.createNewRegularVideoStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: FileId, - emojis: String -) = createNewRegularVideoStickerSet( - user.id, name, title, sticker, emojis -) - -suspend fun TelegramBot.createNewRegularVideoStickerSet( - user: CommonUser, - name: String, - title: String, - sticker: MultipartFile, - emojis: String -) = createNewRegularVideoStickerSet( - user.id, name, title, sticker, emojis -) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt index dfb21e7942..6caeaa91ce 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt @@ -27,6 +27,7 @@ data class StickerContent( chatId, media.fileId, messageThreadId, + media.emoji, disableNotification, protectContent, replyToMessageId, diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index d6595ef0fa..7010113283 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -14,6 +14,7 @@ import dev.inmo.tgbotapi.abstracts.FromUser import dev.inmo.tgbotapi.abstracts.WithUser import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink import dev.inmo.tgbotapi.requests.send.payments.SendInvoice +import dev.inmo.tgbotapi.requests.stickers.InputSticker import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.ChatIdWithThreadId import dev.inmo.tgbotapi.types.ChatIdentifier @@ -1002,6 +1003,43 @@ public inline fun WithUser.ifMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T): T? = messageGameShortNameCallbackQueryOrNull() ?.let(block) +public inline fun InputSticker.maskOrNull(): InputSticker.Mask? = this as? + dev.inmo.tgbotapi.requests.stickers.InputSticker.Mask + +public inline fun InputSticker.maskOrThrow(): InputSticker.Mask = this as + dev.inmo.tgbotapi.requests.stickers.InputSticker.Mask + +public inline fun InputSticker.ifMask(block: (InputSticker.Mask) -> T): T? = maskOrNull() + ?.let(block) + +public inline fun InputSticker.withKeywordsOrNull(): InputSticker.WithKeywords? = this as? + dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords + +public inline fun InputSticker.withKeywordsOrThrow(): InputSticker.WithKeywords = this as + dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords + +public inline fun InputSticker.ifWithKeywords(block: (InputSticker.WithKeywords) -> T): T? = + withKeywordsOrNull() ?.let(block) + +public inline fun InputSticker.customEmojiOrNull(): InputSticker.WithKeywords.CustomEmoji? = this + as? dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.CustomEmoji + +public inline fun InputSticker.customEmojiOrThrow(): InputSticker.WithKeywords.CustomEmoji = this as + dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.CustomEmoji + +public inline fun + InputSticker.ifCustomEmoji(block: (InputSticker.WithKeywords.CustomEmoji) -> T): T? = + customEmojiOrNull() ?.let(block) + +public inline fun InputSticker.regularOrNull(): InputSticker.WithKeywords.Regular? = this as? + dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.Regular + +public inline fun InputSticker.regularOrThrow(): InputSticker.WithKeywords.Regular = this as + dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.Regular + +public inline fun InputSticker.ifRegular(block: (InputSticker.WithKeywords.Regular) -> T): T? = + regularOrNull() ?.let(block) + public inline fun ChatIdentifier.idChatIdentifierOrNull(): IdChatIdentifier? = this as? dev.inmo.tgbotapi.types.IdChatIdentifier From 6f9f880b79b60bc96091cb1c815cb403ed78c6ff Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 14:59:59 +0600 Subject: [PATCH 18/28] deprecations removing --- CHANGELOG.md | 5 + README.md | 2 +- .../extensions/api/get/GetStickerSet.kt | 7 - .../expectations/WaitContent.kt | 69 -- .../expectations/WaitContentMessage.kt | 70 -- .../expectations/WaitEventAction.kt | 2 +- .../expectations/WaitEventActionMessages.kt | 2 +- .../triggers_handling/EventTriggers.kt | 8 +- .../dev/inmo/tgbotapi/types/files/Sticker.kt | 3 +- .../message/ChatEvents/LeftChatMember.kt | 3 - .../tgbotapi/types/message/ForwardInfo.kt | 15 - .../inmo/tgbotapi/types/message/RawMessage.kt | 5 +- .../tgbotapi/types/stickers/StickerSet.kt | 3 - .../updateshandlers/FlowsUpdatesFilter.kt | 3 - .../tgbotapi/extensions/utils/ClassCasts.kt | 54 +- .../utils/extensions/raw/Message.kt | 4 +- .../utils/formatting/EntitiesBuilder.kt | 639 ------------------ .../utils/formatting/LinksFormatting.kt | 21 - .../utils/shortcuts/EventsShortcuts.kt | 8 +- .../types/buttons/InlineKeyboardBuilder.kt | 15 - .../types/buttons/ReplyKeyboardBuilder.kt | 13 - .../extensions/utils/updates/UpdatesUtils.kt | 17 - 22 files changed, 37 insertions(+), 931 deletions(-) delete mode 100644 tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ae378e21b..15bd48bffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,14 @@ ## 7.0.0 +This update contains support of [Telegram Bot API 6.6](https://core.telegram.org/bots/api-changelog#march-9-2023) + **THIS VERSION CONTAINS BREAKING CHANGES**: +* All previous deprecations have been removed * Fully reworked mechanism of stickers creating and adding + * All separations of stickers types like `Animeted` have been replaces with type `StickerFormat` + * New `InputSticker` type (and all subtypes) as replacements for old raw fields in methods ## 6.1.0 diff --git a/README.md b/README.md index cff3e58404..4050520095 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.5-blue)](https://core.telegram.org/bots/api-changelog#february-3-2023) +# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.6-blue)](https://core.telegram.org/bots/api-changelog#march-9-2023) | Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Bookstack&message=Tutorial&color=blue&logo=bookstack)](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | |:---:|:---:| diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt index 6b73341d94..c4213bf3df 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt @@ -10,13 +10,6 @@ suspend fun TelegramBot.getStickerSet( GetStickerSet(name) ) -@Deprecated("Renamed", ReplaceWith("getStickerSetOrThrow(sticker)", "dev.inmo.tgbotapi.extensions.api.get.getStickerSetOrThrow")) -suspend fun TelegramBot.getStickerSet( - sticker: Sticker -) = getStickerSet( - sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method") -) - suspend fun TelegramBot.getStickerSetOrNull( sticker: Sticker ) = sticker.stickerSetName ?.let { diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index c5e706be4b..007ff4d2cd 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -20,15 +20,6 @@ suspend inline fun BehaviourContext.waitContent( ): Flow = waitContentMessage(initRequest, errorFactory).map { it.content } -@Deprecated( - includeMediaGroupsDeprecationMessage, - ReplaceWith("waitAnyContent(initRequest, errorFactory)", "dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitAnyContent") -) -suspend fun BehaviourContext.waitContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitAnyContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } @@ -69,62 +60,26 @@ suspend fun BehaviourContext.waitVenue( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitAudioMediaGroupContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitDocumentMediaGroupContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitMedia( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitAnyMediaGroupContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitVisualMediaGroupContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitTextedMediaContent( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -133,32 +88,14 @@ suspend fun BehaviourContext.waitAnimation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitAudio( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitAudio( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitDocument( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitDocument( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitPhoto( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitPhoto( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -167,12 +104,6 @@ suspend fun BehaviourContext.waitSticker( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitVideo( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitVideo( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt index 08ccca9aa5..e79ae00a13 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt @@ -13,7 +13,6 @@ import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow -const val includeMediaGroupsDeprecationMessage = "includeMediaGroups is deprecated and its usage will not lead to any changes" typealias CommonMessageToCommonMessageMapper = suspend CommonMessage.() -> CommonMessage? @RiskFeature(lowLevelRiskFeatureMessage) @@ -47,15 +46,6 @@ internal inline fun contentMessageConverter( if (content is T) this as CommonMessage else null } -@Deprecated( - includeMediaGroupsDeprecationMessage, - ReplaceWith("waitAnyContentMessage(initRequest, errorFactory)", "dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitAnyContentMessage") -) -suspend fun BehaviourContext.waitContentMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitAnyContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -96,62 +86,26 @@ suspend fun BehaviourContext.waitVenueMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitMediaMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitMediaMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitTextedMediaContentMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitTextedMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } @@ -160,32 +114,14 @@ suspend fun BehaviourContext.waitAnimationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitAudioMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitAudioMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitDocumentMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitDocumentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitPhotoMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitPhotoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } @@ -194,12 +130,6 @@ suspend fun BehaviourContext.waitStickerMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated(includeMediaGroupsDeprecationMessage) -suspend fun BehaviourContext.waitVideoMessage( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean -) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 2fb21d12f3..1f736a6adf 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -109,7 +109,7 @@ suspend fun BehaviourContext.waitGroupChatCreatedEvents( suspend fun BehaviourContext.waitLeftChatMemberEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEvents(initRequest, errorFactory) +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitNewChatPhotoEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt index 9539f3d2fd..a271ee8b9d 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt @@ -106,7 +106,7 @@ suspend fun BehaviourContext.waitGroupChatCreatedEventsMessages( suspend fun BehaviourContext.waitLeftChatMemberEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEventsMessages(initRequest, errorFactory) +) = waitEventsMessages(initRequest, errorFactory) suspend fun BehaviourContext.waitNewChatPhotoEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 645ac7effb..11e6708abf 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -346,10 +346,10 @@ suspend fun BC.onGroupChatCreated( * data */ suspend fun BC.onLeftChatMember( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** 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 48932491ab..248e1a2e98 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 @@ -213,8 +213,7 @@ data class RegularSimpleSticker( @SerialName(fileSizeField) override val fileSize: Long? = null, ) : RegularSticker -@Deprecated("Renamed", ReplaceWith("SimpleRegularSticker", "dev.inmo.tgbotapi.types.files.SimpleRegularSticker")) -typealias SimpleSticker = RegularSimpleSticker + @Serializable data class RegularAnimatedSticker( @SerialName(fileIdField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt index 4d664fcbd0..f1104ab037 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt @@ -7,6 +7,3 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class LeftChatMemberEvent( override val user: User ) : PublicChatEvent, WithUser - -@Deprecated("Renamed", ReplaceWith("dev.inmo.tgbotapi.types.message.ChatEvents", "LeftChatMemberEvent")) -typealias LeftChatMember = LeftChatMemberEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt index 16eb920f55..58eb633bd6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt @@ -57,18 +57,3 @@ sealed interface ForwardInfo { } } } - -@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByAnonymous", "dev.inmo.tgbotapi.types.message.ForwardInfo")) -typealias AnonymousForwardInfo = ForwardInfo.ByAnonymous - -@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByUser", "dev.inmo.tgbotapi.types.message.ForwardInfo")) -typealias UserForwardInfo = ForwardInfo.ByUser - -@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat", "dev.inmo.tgbotapi.types.message.ForwardInfo")) -typealias ForwardFromPublicChatInfo = ForwardInfo.PublicChat - -@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromChannel", "dev.inmo.tgbotapi.types.message.ForwardInfo")) -typealias ForwardFromChannelInfo = ForwardInfo.PublicChat.FromChannel - -@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromSupergroup", "dev.inmo.tgbotapi.types.message.ForwardInfo")) -typealias ForwardFromSupergroupInfo = ForwardInfo.PublicChat.FromSupergroup diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 684b74757f..eb43475213 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -223,7 +223,7 @@ internal data class RawMessage( private val chatEvent: ChatEvent? by lazy { when { new_chat_members != null -> NewChatMembers(new_chat_members.toList()) - left_chat_member != null -> LeftChatMember(left_chat_member) + left_chat_member != null -> LeftChatMemberEvent(left_chat_member) new_chat_title != null -> NewChatTitle(new_chat_title) new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList()) video_chat_started != null -> video_chat_started @@ -242,12 +242,15 @@ internal data class RawMessage( group_chat_created -> GroupChatCreated( migrate_to_chat_id ) + supergroup_chat_created -> SupergroupChatCreated( migrate_from_chat_id ) + migrate_from_chat_id != null -> MigratedToSupergroup( migrate_from_chat_id ) + channel_chat_created -> ChannelChatCreated() pinned_message != null -> PinnedMessage(pinned_message.asMessage) proximity_alert_triggered != null -> proximity_alert_triggered diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt index e86e5215a2..354d84947a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt @@ -34,9 +34,6 @@ sealed interface StickerSet { @Deprecated("Renamed in telegram bot api") val thumb: PhotoSize? get() = thumbnail - @Deprecated("Will be removed soon due to its redundancy") - val containsMasks: Boolean - get() = this is MaskStickerSet object Serializer : KSerializer { override val descriptor: SerialDescriptor = JsonElement.serializer().descriptor diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt index 2e9c700266..b1e7c195bf 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt @@ -14,9 +14,6 @@ interface FlowsUpdatesFilter : UpdatesFilter { override val allowedUpdates: List get() = ALL_UPDATES_LIST val allUpdatesFlow: Flow - @Deprecated("Since 4.0.0 is not actual", ReplaceWith("allUpdatesFlow")) - val allUpdatesWithoutMediaGroupsGroupingFlow: Flow - get() = allUpdatesFlow val messagesFlow: Flow val messageMediaGroupsFlow: Flow diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 27b1e6f8fa..ccb25f7023 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -30,7 +30,6 @@ import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.media.* import dev.inmo.tgbotapi.types.message.* import dev.inmo.tgbotapi.types.message.ChatEvents.* -import dev.inmo.tgbotapi.types.message.ChatEvents.LeftChatMember import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.* @@ -1943,13 +1942,13 @@ inline fun ChatMember.asKickedChatMember(): KickedChatMember? = this as? KickedC inline fun ChatMember.requireKickedChatMember(): KickedChatMember = this as KickedChatMember @PreviewFeature -inline fun ChatMember.whenLeftChatMember(block: (LeftChatMember) -> T) = asLeftChatMember()?.let(block) +inline fun ChatMember.whenLeftChatMember(block: (LeftChatMemberEvent) -> T) = asLeftChatMember()?.let(block) @PreviewFeature -inline fun ChatMember.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember +inline fun ChatMember.asLeftChatMember(): LeftChatMemberEvent? = this as? LeftChatMemberEvent @PreviewFeature -inline fun ChatMember.requireLeftChatMember(): LeftChatMember = this as LeftChatMember +inline fun ChatMember.requireLeftChatMember(): LeftChatMemberEvent = this as LeftChatMemberEvent @PreviewFeature inline fun ChatMember.whenMemberChatMember(block: (MemberChatMember) -> T) = asMemberChatMember()?.let(block) @@ -2382,15 +2381,6 @@ inline fun TelegramMediaFile.asSticker(): Sticker? = this as? Sticker @PreviewFeature inline fun TelegramMediaFile.requireSticker(): Sticker = this as Sticker -@PreviewFeature -inline fun TelegramMediaFile.whenSimpleSticker(block: (SimpleSticker) -> T) = asSimpleSticker()?.let(block) - -@PreviewFeature -inline fun TelegramMediaFile.asSimpleSticker(): SimpleSticker? = this as? SimpleSticker - -@PreviewFeature -inline fun TelegramMediaFile.requireSimpleSticker(): SimpleSticker = this as SimpleSticker - @PreviewFeature inline fun TelegramMediaFile.whenAnimatedSticker(block: (AnimatedSticker) -> T) = asAnimatedSticker()?.let(block) @@ -2741,10 +2731,12 @@ inline fun ResendableContent.whenAudioMediaGroupContent(block: (AudioMediaGr asAudioMediaGroupContent()?.let(block) @PreviewFeature -inline fun ResendableContent.asAudioMediaGroupContent(): AudioMediaGroupPartContent? = this as? AudioMediaGroupPartContent +inline fun ResendableContent.asAudioMediaGroupContent(): AudioMediaGroupPartContent? = + this as? AudioMediaGroupPartContent @PreviewFeature -inline fun ResendableContent.requireAudioMediaGroupContent(): AudioMediaGroupPartContent = this as AudioMediaGroupPartContent +inline fun ResendableContent.requireAudioMediaGroupContent(): AudioMediaGroupPartContent = + this as AudioMediaGroupPartContent @PreviewFeature inline fun ResendableContent.whenDocumentMediaGroupContent(block: (DocumentMediaGroupPartContent) -> T) = @@ -2815,10 +2807,12 @@ inline fun ResendableContent.whenVisualMediaGroupContent(block: (VisualMedia asVisualMediaGroupContent()?.let(block) @PreviewFeature -inline fun ResendableContent.asVisualMediaGroupContent(): VisualMediaGroupPartContent? = this as? VisualMediaGroupPartContent +inline fun ResendableContent.asVisualMediaGroupContent(): VisualMediaGroupPartContent? = + this as? VisualMediaGroupPartContent @PreviewFeature -inline fun ResendableContent.requireVisualMediaGroupContent(): VisualMediaGroupPartContent = this as VisualMediaGroupPartContent +inline fun ResendableContent.requireVisualMediaGroupContent(): VisualMediaGroupPartContent = + this as VisualMediaGroupPartContent @PreviewFeature inline fun ResendableContent.whenAnimationContent(block: (AnimationContent) -> T) = asAnimationContent()?.let(block) @@ -3165,13 +3159,13 @@ inline fun ChatEvent.asGroupChatCreated(): GroupChatCreated? = this as? GroupCha inline fun ChatEvent.requireGroupChatCreated(): GroupChatCreated = this as GroupChatCreated @PreviewFeature -inline fun ChatEvent.whenLeftChatMember(block: (LeftChatMember) -> T) = asLeftChatMember()?.let(block) +inline fun ChatEvent.whenLeftChatMember(block: (LeftChatMemberEvent) -> T) = asLeftChatMember()?.let(block) @PreviewFeature -inline fun ChatEvent.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember +inline fun ChatEvent.asLeftChatMember(): LeftChatMemberEvent? = this as? LeftChatMemberEvent @PreviewFeature -inline fun ChatEvent.requireLeftChatMember(): LeftChatMember = this as LeftChatMember +inline fun ChatEvent.requireLeftChatMember(): LeftChatMemberEvent = this as LeftChatMemberEvent @PreviewFeature inline fun ChatEvent.whenMessageAutoDeleteTimerChanged(block: (MessageAutoDeleteTimerChanged) -> T) = @@ -3522,26 +3516,6 @@ inline fun ForwardInfo.asForwardFromPublicChatInfo(): ForwardInfo.PublicChat? = @PreviewFeature inline fun ForwardInfo.requireForwardFromPublicChatInfo(): ForwardInfo.PublicChat = this as ForwardInfo.PublicChat -@PreviewFeature -inline fun ForwardInfo.whenForwardFromChannelInfo(block: (ForwardFromChannelInfo) -> T) = - asForwardFromChannelInfo()?.let(block) - -@PreviewFeature -inline fun ForwardInfo.asForwardFromChannelInfo(): ForwardFromChannelInfo? = this as? ForwardFromChannelInfo - -@PreviewFeature -inline fun ForwardInfo.requireForwardFromChannelInfo(): ForwardFromChannelInfo = this as ForwardFromChannelInfo - -@PreviewFeature -inline fun ForwardInfo.whenForwardFromSupergroupInfo(block: (ForwardFromSupergroupInfo) -> T) = - asForwardFromSupergroupInfo()?.let(block) - -@PreviewFeature -inline fun ForwardInfo.asForwardFromSupergroupInfo(): ForwardFromSupergroupInfo? = this as? ForwardFromSupergroupInfo - -@PreviewFeature -inline fun ForwardInfo.requireForwardFromSupergroupInfo(): ForwardFromSupergroupInfo = this as ForwardFromSupergroupInfo - @PreviewFeature inline fun MessageContent.whenTextedInput(block: (TextedInput) -> T) = asTextedInput()?.let(block) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index 2964fe0f57..ca069ef5c4 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -35,10 +35,10 @@ inline val Message.forward_from_chat: Chat? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromPublicChatInfo() ?.chat @RiskFeature(RawFieldsUsageWarning) inline val Message.forward_from_message_id: MessageId? - get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromChannelInfo() ?.messageId + get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.messageId @RiskFeature(RawFieldsUsageWarning) inline val Message.forward_signature: ForwardSignature? - get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromChannelInfo() ?.signature + get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.signature @RiskFeature(RawFieldsUsageWarning) inline val Message.forward_sender_name: ForwardSenderName? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asAnonymousForwardInfo() ?.senderName diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt deleted file mode 100644 index 3c8f597ac9..0000000000 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt +++ /dev/null @@ -1,639 +0,0 @@ -@file:Suppress("NOTHING_TO_INLINE", "unused") - -package dev.inmo.tgbotapi.extensions.utils.formatting - -import dev.inmo.micro_utils.common.joinTo -import dev.inmo.tgbotapi.types.CustomEmojiId -import dev.inmo.tgbotapi.types.chat.User -import dev.inmo.tgbotapi.types.message.textsources.* -import dev.inmo.tgbotapi.utils.EntitiesBuilderBody -import dev.inmo.tgbotapi.utils.RiskFeature - -private const val ReplacedInCoreModuleReason = "Replaced in core module" -private const val CoreModulePackage = "dev.inmo.tgbotapi.utils" - -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilderBody", "$CoreModulePackage.EntitiesBuilderBody")) -typealias EntitiesBuilderBody = EntitiesBuilderBody -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("newLine", "$CoreModulePackage.newLine")) -val newLine = dev.inmo.tgbotapi.utils.newLine - -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities(separator, init)", "$CoreModulePackage.buildEntities")) -inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = dev.inmo.tgbotapi.utils.buildEntities(separator, init) -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities(separator, init)", "$CoreModulePackage.buildEntities")) -inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = dev.inmo.tgbotapi.utils.buildEntities(regular(separator), init) - -/** - * This builder can be used to provide building of [TextSource]s [List] - * - * @see buildEntities - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilder", "$CoreModulePackage.EntitiesBuilder")) -typealias EntitiesBuilder = dev.inmo.tgbotapi.utils.EntitiesBuilder - -/** - * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(parts)", "$CoreModulePackage.bold")) -inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.bold(parts)) -/** - * Version of [EntitiesBuilder.bold] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(parts)", "$CoreModulePackage.boldln")) -inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine -/** - * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(init)", "$CoreModulePackage.bold")) -inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.bold] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(init)", "$CoreModulePackage.boldln")) -inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine -/** - * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(parts)", "$CoreModulePackage.bold")) -inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.bold(*parts)) -/** - * Version of [EntitiesBuilder.bold] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(parts)", "$CoreModulePackage.boldln")) -inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine -/** - * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(text)", "$CoreModulePackage.bold")) -inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.bold(text)) -/** - * Version of [EntitiesBuilder.bold] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(text)", "$CoreModulePackage.boldln")) -inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine - -/** - * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(parts)", "$CoreModulePackage.spoiler")) -inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(parts)) -/** - * Version of [EntitiesBuilder.spoiler] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(parts)", "$CoreModulePackage.spoilerln")) -inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine -/** - * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(init)", "$CoreModulePackage.spoiler")) -inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.spoiler] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(init)", "$CoreModulePackage.spoilerln")) -inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine -/** - * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(parts)", "$CoreModulePackage.spoiler")) -inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(*parts)) -/** - * Version of [EntitiesBuilder.spoiler] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(parts)", "$CoreModulePackage.spoilerln")) -inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine -/** - * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(text)", "$CoreModulePackage.spoiler")) -inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(text)) -/** - * Version of [EntitiesBuilder.spoiler] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(text)", "$CoreModulePackage.spoilerln")) -inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine - - -/** - * Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommand(command)", "$CoreModulePackage.botCommand")) -inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(command)) -/** - * Version of [EntitiesBuilder.botCommand] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommandln(command)", "$CoreModulePackage.botCommandln")) -inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine - - -/** - * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(parts)", "$CoreModulePackage.cashTag")) -inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(parts)) -/** - * Version of [EntitiesBuilder.cashTag] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(parts)", "$CoreModulePackage.cashTagln")) -inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine -/** - * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(init)", "$CoreModulePackage.cashTag")) -inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.cashTag] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(init)", "$CoreModulePackage.cashTagln")) -inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine -/** - * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(parts)", "$CoreModulePackage.cashTag")) -inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(*parts)) -/** - * Version of [EntitiesBuilder.cashTag] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(parts)", "$CoreModulePackage.cashTagln")) -inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine -/** - * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(text)", "$CoreModulePackage.cashTag")) -inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(text)) -/** - * Version of [EntitiesBuilder.cashTag] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(text)", "$CoreModulePackage.cashTagln")) -inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine - - -/** - * Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.code] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("code(code)", "$CoreModulePackage.code")) -inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.message.textsources.code(code)) -/** - * Version of [EntitiesBuilder.code] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("codeln(code)", "$CoreModulePackage.codeln")) -inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine - - -/** - * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(parts)", "$CoreModulePackage.email")) -inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.email(parts)) -/** - * Version of [EntitiesBuilder.email] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(parts)", "$CoreModulePackage.emailln")) -inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine -/** - * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(init)", "$CoreModulePackage.email")) -inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.email] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(init)", "$CoreModulePackage.emailln")) -inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine -/** - * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(parts)", "$CoreModulePackage.email")) -inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.email(*parts)) -/** - * Version of [EntitiesBuilder.email] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(parts)", "$CoreModulePackage.emailln")) -inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine -/** - * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(emailAddress)", "$CoreModulePackage.email")) -inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.message.textsources.email(emailAddress)) -/** - * Version of [EntitiesBuilder.email] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(emailAddress)", "$CoreModulePackage.emailln")) -inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) + newLine - - -/** - * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(parts)", "$CoreModulePackage.hashtag")) -inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(parts)) -/** - * Version of [EntitiesBuilder.hashtag] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(parts)", "$CoreModulePackage.hashtagln")) -inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine -/** - * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(init)", "$CoreModulePackage.hashtag")) -inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.hashtag] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(init)", "$CoreModulePackage.hashtagln")) -inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine -/** - * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(parts)", "$CoreModulePackage.hashtag")) -inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(*parts)) -/** - * Version of [EntitiesBuilder.hashtag] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(parts)", "$CoreModulePackage.hashtagln")) -inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine -/** - * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(hashtag)", "$CoreModulePackage.hashtag")) -inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(hashtag)) -/** - * Version of [EntitiesBuilder.hashtag] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(hashtag)", "$CoreModulePackage.hashtagln")) -inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLine - - -/** - * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(parts)", "$CoreModulePackage.italic")) -inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.italic(parts)) -/** - * Version of [EntitiesBuilder.italic] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(parts)", "$CoreModulePackage.italicln")) -inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine -/** - * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(init)", "$CoreModulePackage.italic")) -inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.italic] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(init)", "$CoreModulePackage.italicln")) -inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine -/** - * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(parts)", "$CoreModulePackage.italic")) -inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.italic(*parts)) -/** - * Version of [EntitiesBuilder.italic] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(parts)", "$CoreModulePackage.italicln")) -inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine -/** - * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(text)", "$CoreModulePackage.italic")) -inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.italic(text)) -/** - * Version of [EntitiesBuilder.italic] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(text)", "$CoreModulePackage.italicln")) -inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine - - -/** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention")) -inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts)) -/** - * Version of [EntitiesBuilder.mention] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts)", "$CoreModulePackage.mentionln")) -inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine -/** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(init)", "$CoreModulePackage.mention")) -inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.mention] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(init)", "$CoreModulePackage.mentionln")) -inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine -/** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention")) -inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.mention(*parts)) -/** - * Version of [EntitiesBuilder.mention] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts)", "$CoreModulePackage.mentionln")) -inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine -/** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(whoToMention)", "$CoreModulePackage.mention")) -inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention)) -/** - * Version of [EntitiesBuilder.mention] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(whoToMention)", "$CoreModulePackage.mentionln")) -inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine -/** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention")) -inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts, user)) -/** - * Version of [EntitiesBuilder.mention] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts, user)", "$CoreModulePackage.mentionln")) -inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = mention(parts) + newLine -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(user, parts)", "$CoreModulePackage.mention")) -inline fun EntitiesBuilder.mention( - user: User, - vararg parts: TextSource -) = add(dev.inmo.tgbotapi.types.message.textsources.mention(user, *parts)) -/** - * Version of [EntitiesBuilder.mention] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(user, parts)", "$CoreModulePackage.mentionln")) -inline fun EntitiesBuilder.mentionln(user: User, vararg parts: TextSource) = mention(user, *parts) + newLine -/** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(text, user)", "$CoreModulePackage.mention")) -inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(text, user)) -/** - * Version of [EntitiesBuilder.mention] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(text, user)", "$CoreModulePackage.mentionln")) -inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text) + newLine - - -/** - * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(parts)", "$CoreModulePackage.phone")) -inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.phone(parts)) -/** - * Version of [EntitiesBuilder.phone] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(parts)", "$CoreModulePackage.phoneln")) -inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine -/** - * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(init)", "$CoreModulePackage.phone")) -inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.phone] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(init)", "$CoreModulePackage.phoneln")) -inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine -/** - * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(parts)", "$CoreModulePackage.phone")) -inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.phone(*parts)) -/** - * Version of [EntitiesBuilder.phone] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(parts)", "$CoreModulePackage.phoneln")) -inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine -/** - * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(number)", "$CoreModulePackage.phone")) -inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.message.textsources.phone(number)) -/** - * Version of [EntitiesBuilder.phone] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(number)", "$CoreModulePackage.phoneln")) -inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine - - -/** - * Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.pre] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("pre(code, language)", "$CoreModulePackage.pre")) -inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.message.textsources.pre(code, language)) -/** - * Version of [EntitiesBuilder.pre] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("preln(code, language)", "$CoreModulePackage.preln")) -inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) + newLine - -/** - * Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] - * - * @see RegularTextSource - * @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regular(text)", "$CoreModulePackage.regular")) -inline fun EntitiesBuilder.regular(text: String) = - add(dev.inmo.tgbotapi.types.message.textsources.regular(text)) -/** - * Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] and "\n" at the end - * - * @see RegularTextSource - * @see dev.inmo.tgbotapi.extensions.utils.formatting.regular - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regularln(text)", "$CoreModulePackage.regularln")) -inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine - - -/** - * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(parts)", "$CoreModulePackage.strikethrough")) -inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(parts)) -/** - * Version of [EntitiesBuilder.strikethrough] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(parts)", "$CoreModulePackage.strikethroughln")) -inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine -/** - * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(init)", "$CoreModulePackage.strikethrough")) -inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.strikethrough] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(init)", "$CoreModulePackage.strikethroughln")) -inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine -/** - * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(parts)", "$CoreModulePackage.strikethrough")) -inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(*parts)) -/** - * Version of [EntitiesBuilder.strikethrough] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(parts)", "$CoreModulePackage.strikethroughln")) -inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine -/** - * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(text)", "$CoreModulePackage.strikethrough")) -inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(text)) -/** - * Version of [EntitiesBuilder.strikethrough] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(text)", "$CoreModulePackage.strikethroughln")) -inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) + newLine - - -/** - * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link(text, url)", "$CoreModulePackage.link")) -inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(text, url)) -/** - * Version of [EntitiesBuilder.link] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln(text, url)", "$CoreModulePackage.linkln")) -inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine -/** - * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link(url)", "$CoreModulePackage.link")) -inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(url)) -/** - * Version of [EntitiesBuilder.link] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln(url)", "$CoreModulePackage.linkln")) -inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine - - -/** - * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(parts)", "$CoreModulePackage.underline")) -inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.underline(parts)) -/** - * Version of [EntitiesBuilder.underline] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(parts)", "$CoreModulePackage.underlineln")) -inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine -/** - * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(init)", "$CoreModulePackage.underline")) -inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline( - buildEntities(separator, init) -)) -/** - * Version of [EntitiesBuilder.underline] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(init)", "$CoreModulePackage.underlineln")) -inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine -/** - * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(parts)", "$CoreModulePackage.underline")) -inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.underline(*parts)) -/** - * Version of [EntitiesBuilder.underline] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(parts)", "$CoreModulePackage.underlineln")) -inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine -/** - * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(text)", "$CoreModulePackage.underline")) -inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.underline(text)) -/** - * Version of [EntitiesBuilder.underline] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(text)", "$CoreModulePackage.underlineln")) -inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine - - -/** - * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, parts)", "$CoreModulePackage.customEmoji")) -inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, parts)) -/** - * Version of [EntitiesBuilder.customEmoji] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, parts)", "$CoreModulePackage.customEmojiln")) -inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine -/** - * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, init)", "$CoreModulePackage.customEmoji")) -inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, buildEntities(separator, init))) -/** - * Version of [EntitiesBuilder.customEmoji] with new line at the end. - * Will reuse separator config from [buildEntities] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, init)", "$CoreModulePackage.customEmojiln")) -inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine -/** - * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, parts)", "$CoreModulePackage.customEmoji")) -inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, *parts)) -/** - * Version of [EntitiesBuilder.customEmoji] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, parts)", "$CoreModulePackage.customEmojiln")) -inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine -/** - * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, text)", "$CoreModulePackage.customEmoji")) -inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, text)) -/** - * Version of [EntitiesBuilder.customEmoji] with new line at the end - */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, text)", "$CoreModulePackage.customEmojiln")) -inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt index bb354096f3..6a8e9d4c30 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt @@ -20,14 +20,8 @@ fun makeUsernameStartattachPrefix(username: String) = "$internalLinkBeginning/$u fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}" inline val Username.usernameLink get() = makeUsernameLink(usernameWithoutAt) -@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.usernameLink", "dev.inmo.tgbotapi.extensions.utils.formatting.usernameLink")) -inline val Username.link - get() = usernameLink val IdChatIdentifier.chatLink: String get() = makeChatLink(chatId, threadId) -@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.chatLink", "dev.inmo.tgbotapi.extensions.utils.formatting.chatLink")) -val IdChatIdentifier.link: String - get() = chatLink fun ChatId.link(threadId: MessageThreadId?) = makeChatLink(chatId, threadId) inline fun Username.link(threadId: MessageThreadId?) = makeUsernameLink(usernameWithoutAt, threadId) inline val Username.deepLinkPrefix @@ -95,13 +89,6 @@ val Message.messageLink: String? messageId ) -/** - * @see makeLinkToMessage - */ -@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.messageLink", "dev.inmo.tgbotapi.extensions.utils.formatting.messageLink")) -val Message.link: String? - get() = messageLink - /** * Link which can be used as by any user to get access to [Chat]. Returns null in case when there are no * known way to build link @@ -120,14 +107,6 @@ val Chat.chatLink: String? return null } -/** - * Link which can be used as by any user to get access to [Chat]. Returns null in case when there are no - * known way to build link - */ -@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.chatLink", "dev.inmo.tgbotapi.extensions.utils.formatting.chatLink")) -val Chat.link: String? - get() = chatLink - private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addstickers" val StickerSetName.stickerSetLink diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt index dbab023d4c..93255bcf59 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -72,8 +72,8 @@ inline fun Flow>.deletedGroupPhotoEvents() = filterGroupEven inline fun FlowsUpdatesFilter.deletedGroupPhotoEvents() = filterGroupEvents() inline fun Flow>.newGroupMembersEvents() = filterGroupEvents() inline fun FlowsUpdatesFilter.newGroupMembersEvents() = filterGroupEvents() -inline fun Flow>.leftGroupMemberEvents() = filterGroupEvents() -inline fun FlowsUpdatesFilter.leftGroupMemberEvents() = filterGroupEvents() +inline fun Flow>.leftGroupMemberEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.leftGroupMemberEvents() = filterGroupEvents() inline fun Flow>.newGroupPhotoEvents() = filterGroupEvents() inline fun FlowsUpdatesFilter.newGroupPhotoEvents() = filterGroupEvents() inline fun Flow>.newGroupTitleEvents() = filterGroupEvents() @@ -97,8 +97,8 @@ inline fun Flow>.deletedSupergroupPhotoEvents() = filterSupe inline fun FlowsUpdatesFilter.deletedSupergroupPhotoEvents() = filterSupergroupEvents() inline fun Flow>.newSupergroupMembersEvents() = filterSupergroupEvents() inline fun FlowsUpdatesFilter.newSupergroupMembersEvents() = filterSupergroupEvents() -inline fun Flow>.leftSupergroupMemberEvents() = filterSupergroupEvents() -inline fun FlowsUpdatesFilter.leftSupergroupMemberEvents() = filterSupergroupEvents() +inline fun Flow>.leftSupergroupMemberEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.leftSupergroupMemberEvents() = filterSupergroupEvents() inline fun Flow>.newSupergroupPhotoEvents() = filterSupergroupEvents() inline fun FlowsUpdatesFilter.newSupergroupPhotoEvents() = filterSupergroupEvents() inline fun Flow>.newSupergroupTitleEvents() = filterSupergroupEvents() diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt index 69037b21e3..06e844e9e1 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt @@ -49,21 +49,6 @@ inline fun flatInlineKeyboard( block: InlineKeyboardRowBuilder.() -> Unit ) = inlineKeyboard { row(block) } -/** - * Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder - * - * @see payButton - * @see dataButton - * @see gameButton - * @see loginButton - * @see inlineQueryInCurrentChatButton - * @see inlineQueryButton - * @see urlButton - */ -@Deprecated("Redundant", ReplaceWith("this.row(block)", "dev.inmo.tgbotapi.utils.row")) -inline fun InlineKeyboardBuilder.row( - block: InlineKeyboardRowBuilder.() -> Unit -) = add(InlineKeyboardRowBuilder().apply(block).row) /** * Creates and put [PayInlineKeyboardButton] diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt index 22acc0e117..3720c54e82 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt @@ -67,19 +67,6 @@ inline fun flatReplyKeyboard( row(block) } -/** - * Creates an [ReplyKeyboardRowBuilder] and [apply] [block] with this builder - * - * @see simpleButton - * @see requestContactButton - * @see requestLocationButton - * @see requestPollButton - */ -@Deprecated("Redundant", ReplaceWith("this.row(block)", "dev.inmo.tgbotapi.utils.row")) -inline fun ReplyKeyboardBuilder.row( - block: ReplyKeyboardRowBuilder.() -> Unit -) = add(ReplyKeyboardRowBuilder().apply(block).row) - /** * Creates and put [SimpleKeyboardButton] * diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt index 83757480d8..add4bcbefe 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt @@ -9,14 +9,6 @@ import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.abstracts.* import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage -/** - * @return If [this] is [SentMediaGroupUpdate] - [Update.updateId] of [last] element, or its own [Update.updateId] - */ -@Deprecated("Redundant", ReplaceWith("updateId")) -fun Update.lastUpdateIdentifier(): UpdateIdentifier { - return updateId -} - /** * @return The biggest [UpdateIdentifier] OR null * @@ -61,12 +53,3 @@ fun List.convertWithMediaGroupUpdates(): List { resultUpdates.sortBy { it.updateId } return resultUpdates } - -/** - * @return [EditMessageMediaGroupUpdate] in case if [this] is [EditMessageUpdate]. When [this] object is - * [EditChannelPostUpdate] instance - will return [EditChannelPostMediaGroupUpdate] - * - * @throws IllegalStateException - */ -@Deprecated("Redundant", ReplaceWith("this")) -fun BaseEditMessageUpdate.toEditMediaGroupUpdate() = this From 9f14eb2ca370c8b669c105acf2c59c33e525cdf5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 15:08:44 +0600 Subject: [PATCH 19/28] update microutils --- CHANGELOG.md | 5 +++++ gradle/libs.versions.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15bd48bffe..8df791012c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ This update contains support of [Telegram Bot API 6.6](https://core.telegram.org * All separations of stickers types like `Animeted` have been replaces with type `StickerFormat` * New `InputSticker` type (and all subtypes) as replacements for old raw fields in methods +Other changes + +* `Versions`: + * `MicroUtils`: `0.17.3` -> `0.17.4` + ## 6.1.0 * `Versions`: diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2187d2ec0f..dfcdf53538 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ ktor = "2.2.4" ksp = "1.8.10-1.0.9" kotlin-poet = "1.12.0" -microutils = "0.17.3" +microutils = "0.17.4" github-release-plugin = "2.4.1" dokka = "1.8.10" From f75df0a425b82133ef32e740016e8b7536cf7192 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 22:34:48 +0600 Subject: [PATCH 20/28] Update microutils --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dfcdf53538..12fe622c56 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ ktor = "2.2.4" ksp = "1.8.10-1.0.9" kotlin-poet = "1.12.0" -microutils = "0.17.4" +microutils = "0.17.5" github-release-plugin = "2.4.1" dokka = "1.8.10" From 988d9995c51e38343a7cd6c6e476611234c58f69 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Mar 2023 00:46:20 +0600 Subject: [PATCH 21/28] add sticker format to sticker object --- .../dev/inmo/tgbotapi/types/files/Sticker.kt | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) 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 248e1a2e98..c95fc364d4 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 @@ -35,6 +35,7 @@ data class StickerSurrogate( sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile { val emoji: String? val stickerSetName: StickerSetName? + val stickerFormat: StickerFormat val isAnimated get() = false @@ -165,6 +166,11 @@ object StickerSerializer : KSerializer { surrogate.emoji, surrogate.set_name, surrogate.file_size, + when { + surrogate.is_animated == true -> StickerFormat.Animated + surrogate.is_video == true -> StickerFormat.Video + else -> StickerFormat.Static + }, json ) } @@ -180,11 +186,17 @@ object StickerSerializer : KSerializer { sealed interface VideoSticker : Sticker { override val isVideo: Boolean get() = true + + override val stickerFormat: StickerFormat + get() = StickerFormat.Video } @Serializable sealed interface AnimatedSticker : Sticker { override val isAnimated: Boolean get() = true + + override val stickerFormat: StickerFormat + get() = StickerFormat.Animated } @Serializable @@ -209,10 +221,14 @@ data class RegularSimpleSticker( @SerialName(stickerSetNameField) override val stickerSetName: StickerSetName? = null, @SerialName(premiumAnimationField) - override val premiumAnimationFile: File?, + override val premiumAnimationFile: File? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, -) : RegularSticker +) : RegularSticker { + @SerialName(stickerFormatField) + @EncodeDefault + override val stickerFormat: StickerFormat = StickerFormat.Static +} @Serializable data class RegularAnimatedSticker( @@ -231,7 +247,7 @@ data class RegularAnimatedSticker( @SerialName(stickerSetNameField) override val stickerSetName: StickerSetName? = null, @SerialName(premiumAnimationField) - override val premiumAnimationFile: File?, + override val premiumAnimationFile: File? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, ) : RegularSticker, AnimatedSticker @@ -252,7 +268,7 @@ data class RegularVideoSticker( @SerialName(stickerSetNameField) override val stickerSetName: StickerSetName? = null, @SerialName(premiumAnimationField) - override val premiumAnimationFile: File?, + override val premiumAnimationFile: File? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, ) : RegularSticker, VideoSticker @@ -282,7 +298,11 @@ data class MaskSimpleSticker( override val stickerSetName: StickerSetName? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, -) : MaskSticker +) : MaskSticker { + @SerialName(stickerFormatField) + @EncodeDefault + override val stickerFormat: StickerFormat = StickerFormat.Static +} @Serializable data class MaskAnimatedSticker( @SerialName(fileIdField) @@ -354,7 +374,11 @@ data class CustomEmojiSimpleSticker( override val fileSize: Long? = null, @SerialName(needsRepaintingField) override val needsRepainting: Boolean = false -) : CustomEmojiSticker +) : CustomEmojiSticker { + @SerialName(stickerFormatField) + @EncodeDefault + override val stickerFormat: StickerFormat = StickerFormat.Static +} @Serializable data class CustomEmojiAnimatedSticker( @SerialName(fileIdField) @@ -420,5 +444,7 @@ data class UnknownSticker( override val stickerSetName: StickerSetName? = null, @SerialName(fileSizeField) override val fileSize: Long? = null, + @SerialName(stickerFormatField) + override val stickerFormat: StickerFormat = StickerFormat.Static, val raw: JsonElement ) : Sticker From 0c24aa1270baaf933c86f992610fccba8b360f53 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Mar 2023 00:53:36 +0600 Subject: [PATCH 22/28] add sticker format to stickerset --- .../tgbotapi/types/stickers/StickerSet.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt index 354d84947a..4f80e71d49 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stickers/StickerSet.kt @@ -25,6 +25,7 @@ sealed interface StickerSet { val name: String val title: String val stickerType: StickerType + val stickerFormat: StickerFormat val stickers: List val isAnimated: Boolean get() = false @@ -124,11 +125,19 @@ sealed interface StickerSet { sealed interface AnimatedStickerSet : StickerSet { 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 @@ -151,6 +160,9 @@ data class RegularSimpleStickerSet( @SerialName(stickerTypeField) @EncodeDefault override val stickerType: StickerType = StickerType.Regular + @SerialName(stickerFormatField) + @EncodeDefault + override val stickerFormat: StickerFormat = StickerFormat.Static } @Serializable @@ -199,6 +211,10 @@ data class MaskSimpleStickerSet( @SerialName(stickerTypeField) @EncodeDefault override val stickerType: StickerType = StickerType.Mask + + @SerialName(stickerFormatField) + @EncodeDefault + override val stickerFormat: StickerFormat = StickerFormat.Static } @Serializable @@ -247,6 +263,10 @@ data class CustomEmojiSimpleStickerSet( @SerialName(stickerTypeField) @EncodeDefault override val stickerType: StickerType = StickerType.CustomEmoji + + @SerialName(stickerFormatField) + @EncodeDefault + override val stickerFormat: StickerFormat = StickerFormat.Static } @Serializable From 3c4f8787a6382e634ee2aaecee41ef0845360d3f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Mar 2023 01:18:39 +0600 Subject: [PATCH 23/28] mask position is nullable in mask stickers and sticker sets --- .../api/stickers/AddStickerToSet.kt | 9 ++++++--- .../requests/stickers/InputSticker.kt | 2 +- .../dev/inmo/tgbotapi/types/files/Sticker.kt | 20 +++++++++---------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt index cc167680ba..275d372f8a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt @@ -33,7 +33,10 @@ suspend fun TelegramBot.addStickerToSet( emojis, keywords ) - StickerType.Mask -> error("Unable to create Mask sticker to the set without maskPosition parameter") + StickerType.Mask -> InputSticker.Mask( + sticker, + emojis + ) StickerType.Regular -> InputSticker.WithKeywords.Regular( sticker, emojis, @@ -48,7 +51,7 @@ suspend fun TelegramBot.addStickerToSet( stickerSet: StickerSet, sticker: InputFile, emojis: List, - maskPosition: MaskPosition + maskPosition: MaskPosition? = null ) = addStickerToSet( userId, stickerSet.name, @@ -87,7 +90,7 @@ suspend fun TelegramBot.addStickerToSet( stickerSet: StickerSet, sticker: InputFile, emojis: List, - maskPosition: MaskPosition + maskPosition: MaskPosition? = null ) = addStickerToSet( user.id, stickerSet, sticker, emojis, maskPosition ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt index aaac6fc0cc..9633b555a7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt @@ -23,7 +23,7 @@ sealed interface InputSticker { @SerialName(emojiListField) override val emojisList: List, @SerialName(maskPositionField) - val maskPosition: MaskPosition + val maskPosition: MaskPosition? = null ) : InputSticker @Serializable 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 c95fc364d4..bd4c1403ee 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 @@ -93,7 +93,7 @@ object StickerSerializer : KSerializer { surrogate.file_unique_id, surrogate.width, surrogate.height, - surrogate.mask_position ?: error("For mask stickers field mask_position should be presented"), + surrogate.mask_position, surrogate.thumb, surrogate.emoji, surrogate.set_name, @@ -104,7 +104,7 @@ object StickerSerializer : KSerializer { surrogate.file_unique_id, surrogate.width, surrogate.height, - surrogate.mask_position ?: error("For mask stickers field mask_position should be presented"), + surrogate.mask_position, surrogate.thumb, surrogate.emoji, surrogate.set_name, @@ -115,7 +115,7 @@ object StickerSerializer : KSerializer { surrogate.file_unique_id, surrogate.width, surrogate.height, - surrogate.mask_position ?: error("For mask stickers field mask_position should be presented"), + surrogate.mask_position, surrogate.thumb, surrogate.emoji, surrogate.set_name, @@ -128,7 +128,7 @@ object StickerSerializer : KSerializer { surrogate.file_unique_id, surrogate.width, surrogate.height, - surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"), + surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"), surrogate.thumb, surrogate.emoji, surrogate.set_name, @@ -139,7 +139,7 @@ object StickerSerializer : KSerializer { surrogate.file_unique_id, surrogate.width, surrogate.height, - surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"), + surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"), surrogate.thumb, surrogate.emoji, surrogate.set_name, @@ -150,7 +150,7 @@ object StickerSerializer : KSerializer { surrogate.file_unique_id, surrogate.width, surrogate.height, - surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"), + surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"), surrogate.thumb, surrogate.emoji, surrogate.set_name, @@ -276,7 +276,7 @@ data class RegularVideoSticker( @Serializable sealed interface MaskSticker : Sticker { - val maskPosition: MaskPosition + val maskPosition: MaskPosition? } @Serializable data class MaskSimpleSticker( @@ -289,7 +289,7 @@ data class MaskSimpleSticker( @SerialName(heightField) override val height: Int, @SerialName(maskPositionField) - override val maskPosition: MaskPosition, + override val maskPosition: MaskPosition? = null, @SerialName(thumbnailField) override val thumbnail: PhotoSize? = null, @SerialName(emojiField) @@ -314,7 +314,7 @@ data class MaskAnimatedSticker( @SerialName(heightField) override val height: Int, @SerialName(maskPositionField) - override val maskPosition: MaskPosition, + override val maskPosition: MaskPosition? = null, @SerialName(thumbnailField) override val thumbnail: PhotoSize? = null, @SerialName(emojiField) @@ -335,7 +335,7 @@ data class MaskVideoSticker( @SerialName(heightField) override val height: Int, @SerialName(maskPositionField) - override val maskPosition: MaskPosition, + override val maskPosition: MaskPosition? = null, @SerialName(thumbnailField) override val thumbnail: PhotoSize? = null, @SerialName(emojiField) From 5992fdd4561d4175ebb30deaf33c6711a28e0555 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Mar 2023 01:30:12 +0600 Subject: [PATCH 24/28] Update Sticker.kt --- .../kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 bd4c1403ee..7331e5d109 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 @@ -27,7 +27,8 @@ data class StickerSurrogate( val premium_animation: File? = null, val mask_position: MaskPosition? = null, val custom_emoji_id: CustomEmojiId? = null, - val file_size: Long? = null + val file_size: Long? = null, + val needs_repainting: Boolean = false ) // TODO:: Serializer @@ -132,7 +133,8 @@ object StickerSerializer : KSerializer { surrogate.thumb, surrogate.emoji, surrogate.set_name, - surrogate.file_size + surrogate.file_size, + surrogate.needs_repainting ) surrogate.is_video == true -> CustomEmojiVideoSticker( surrogate.file_id, @@ -143,7 +145,8 @@ object StickerSerializer : KSerializer { surrogate.thumb, surrogate.emoji, surrogate.set_name, - surrogate.file_size + surrogate.file_size, + surrogate.needs_repainting ) else -> CustomEmojiSimpleSticker( surrogate.file_id, @@ -154,7 +157,8 @@ object StickerSerializer : KSerializer { surrogate.thumb, surrogate.emoji, surrogate.set_name, - surrogate.file_size + surrogate.file_size, + surrogate.needs_repainting ) } is StickerType.Unknown -> UnknownSticker( From 810b2ab5a125c456b2311f00c3c7f4e5215f6865 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Mar 2023 17:39:02 +0600 Subject: [PATCH 25/28] add Sticker#asInputSticker --- ...icStickerSet.kt => CreateNewStickerSet.kt} | 9 +++--- .../dev/inmo/tgbotapi/types/files/Sticker.kt | 29 ++++++++++++++++++- 2 files changed, 32 insertions(+), 6 deletions(-) rename tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/{CreateNewStaticStickerSet.kt => CreateNewStickerSet.kt} (78%) 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() + ) +} From 6722ab5f5089609fefd813de0f077cd5c3c7aad7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Mar 2023 17:58:48 +0600 Subject: [PATCH 26/28] add several extensions for addStickerToSet --- .../api/stickers/AddStickerToSet.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt index 275d372f8a..18cb4d47af 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSet.kt @@ -18,6 +18,16 @@ suspend fun TelegramBot.addStickerToSet( AddStickerToSet(userId, stickerSetName, inputSticker) ) +suspend fun TelegramBot.addStickerToSet( + userId: UserId, + stickerSet: StickerSet, + sticker: InputSticker +) = addStickerToSet( + userId, + stickerSet.name, + sticker +) + suspend fun TelegramBot.addStickerToSet( userId: UserId, stickerSet: StickerSet, @@ -26,7 +36,7 @@ suspend fun TelegramBot.addStickerToSet( keywords: List = emptyList() ) = addStickerToSet( userId, - stickerSet.name, + stickerSet, when (stickerSet.stickerType) { StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji( sticker, @@ -75,6 +85,16 @@ suspend fun TelegramBot.addStickerToSet( } ) +suspend fun TelegramBot.addStickerToSet( + user: CommonUser, + stickerSet: StickerSet, + sticker: InputSticker +) = addStickerToSet( + user.id, + stickerSet.name, + sticker +) + suspend fun TelegramBot.addStickerToSet( user: CommonUser, stickerSet: StickerSet, From e5a48e968487e66143d5ff5124fee1b2e78e5b41 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Mar 2023 21:17:59 +0600 Subject: [PATCH 27/28] rework of multipart files with fixes in new sticker sets --- gradle/libs.versions.toml | 1 + .../api/files/DownloadFileToFile.kt | 3 +- .../api/files/DownloadFileToTempFile.kt | 14 ++- tgbotapi.core/build.gradle | 1 + .../tgbotapi/requests/abstracts/InputFile.kt | 8 +- .../requests/send/media/SendAnimation.kt | 31 +++--- .../tgbotapi/requests/send/media/SendAudio.kt | 31 +++--- .../requests/send/media/SendDocument.kt | 31 +++--- .../requests/send/media/SendMediaGroup.kt | 10 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 32 ++++--- .../requests/send/media/SendSticker.kt | 27 ++---- .../tgbotapi/requests/send/media/SendVideo.kt | 31 +++--- .../requests/send/media/SendVideoNote.kt | 17 ++-- .../tgbotapi/requests/send/media/SendVoice.kt | 17 ++-- .../requests/stickers/CreateNewStickerSet.kt | 94 +++++++++++++++++-- .../requests/stickers/InputSticker.kt | 71 +++++++++++++- .../types/message/content/Abstracts.kt | 12 +++ .../message/content/MediaGroupContent.kt | 3 +- 18 files changed, 295 insertions(+), 139 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 12fe622c56..f5379f8392 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -45,6 +45,7 @@ microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.re microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" } microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" } microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", version.ref = "microutils" } +microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization.mapper", version.ref = "microutils" } microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" } microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" } microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" } diff --git a/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt b/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt index 05ed333073..1174d1162d 100644 --- a/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt +++ b/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt @@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.message.content.MediaContent import io.ktor.util.cio.use import io.ktor.util.cio.writeChannel +import io.ktor.utils.io.copyAndClose import io.ktor.utils.io.copyTo import kotlinx.coroutines.job import java.io.File @@ -25,7 +26,7 @@ suspend fun TelegramBot.downloadFile( doOutsideOfCoroutine { destFile.createNewFile() } destFile.writeChannel(coroutineContext.job).use { - readChannel.copyTo(this) + readChannel.copyAndClose(this) } return destFile diff --git a/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToTempFile.kt b/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToTempFile.kt index 299e9d1ddd..5f8f6fd75f 100644 --- a/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToTempFile.kt +++ b/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToTempFile.kt @@ -30,11 +30,17 @@ suspend fun TelegramBot.downloadFileToTemp( suspend fun TelegramBot.downloadFileToTemp( pathedFile: PathedFile -) = downloadFileToTemp( +): File = downloadFileToTemp( pathedFile.filePath -).apply { - runCatching { - renameTo(File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}")) +).run { + val newFile = File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}") + val success = runCatching { + renameTo(newFile) + }.getOrElse { false } + if (success) { + newFile + } else { + this@run } } diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index dac5a707a4..e8448b7c47 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -26,6 +26,7 @@ kotlin { api libs.microutils.serialization.base64 api libs.microutils.serialization.encapsulator api libs.microutils.serialization.typedSerializer + api libs.microutils.serialization.mapper api libs.microutils.ktor.common api libs.microutils.languageCodes diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt index afd6df3640..67b126c235 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt @@ -36,8 +36,10 @@ sealed class InputFile { } } +internal const val attachPrefix = "attach://" + internal inline val InputFile.attachFileId - get() = "attach://$fileId" + get() = "$attachPrefix$fileId" internal inline val InputFile.fileIdToSend get() = when (this) { is FileId -> fileId @@ -60,8 +62,8 @@ fun String.toInputFile() = FileId(this) @RiskFeature object InputFileSerializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING) - override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId) - override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString()) + override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileIdToSend) + override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString().removePrefix(attachPrefix)) } // TODO:: add checks for files size diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt index ae61f5c46d..d1a51fed56 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* @@ -22,7 +23,7 @@ import kotlinx.serialization.* fun SendAnimation( chatId: ChatIdentifier, animation: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, @@ -36,15 +37,13 @@ fun SendAnimation( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val animationAsFileId = (animation as? FileId) ?.fileId val animationAsFile = animation as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendAnimationData( chatId, - animationAsFileId, - thumbAsFileId, + animation, + thumbnail ?.fileId, text, parseMode, null, @@ -63,9 +62,9 @@ fun SendAnimation( return if (animationAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendAnimationFiles(animationAsFile, thumbAsFile) + listOfNotNull(animationAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -73,7 +72,7 @@ fun SendAnimation( fun SendAnimation( chatId: ChatIdentifier, animation: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, entities: TextSourcesList, spoilered: Boolean = false, duration: Long? = null, @@ -86,15 +85,13 @@ fun SendAnimation( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val animationAsFileId = (animation as? FileId) ?.fileId val animationAsFile = animation as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendAnimationData( chatId, - animationAsFileId, - thumbAsFileId, + animation, + thumbnail ?.fileId, entities.makeString(), null, entities.toRawMessageEntities(), @@ -113,9 +110,9 @@ fun SendAnimation( return if (animationAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendAnimationFiles(animationAsFile, thumbAsFile) + listOfNotNull(animationAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -128,7 +125,7 @@ data class SendAnimationData internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(animationField) - val animation: String? = null, + val animation: InputFile, @SerialName(thumbnailField) override val thumbnail: String? = null, @SerialName(captionField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt index dcb1d268f5..b2399f9fed 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.abstracts.Performerable import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* @@ -23,7 +24,7 @@ import kotlinx.serialization.* fun SendAudio( chatId: ChatIdentifier, audio: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, @@ -36,15 +37,13 @@ fun SendAudio( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val audioAsFileId = (audio as? FileId) ?.fileId val audioAsFile = audio as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendAudioData( chatId, - audioAsFileId, - thumbAsFileId, + audio, + thumbnail ?.fileId, text, parseMode, null, @@ -62,9 +61,9 @@ fun SendAudio( return if (audioAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendAudioFiles(audioAsFile, thumbAsFile) + listOfNotNull(audioAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -72,7 +71,7 @@ fun SendAudio( fun SendAudio( chatId: ChatIdentifier, audio: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, entities: List, duration: Long? = null, performer: String? = null, @@ -84,15 +83,13 @@ fun SendAudio( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val audioAsFileId = (audio as? FileId) ?.fileId val audioAsFile = audio as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendAudioData( chatId, - audioAsFileId, - thumbAsFileId, + audio, + thumbnail ?.fileId, entities.makeString(), null, entities.toRawMessageEntities(), @@ -110,9 +107,9 @@ fun SendAudio( return if (audioAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendAudioFiles(audioAsFile, thumbAsFile) + listOfNotNull(audioAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -125,7 +122,7 @@ data class SendAudioData internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(audioField) - val audio: String? = null, + val audio: InputFile, @SerialName(thumbnailField) override val thumbnail: String? = null, @SerialName(captionField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt index 8ff04c4aca..98bc374dac 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* @@ -31,7 +32,7 @@ import kotlinx.serialization.* fun SendDocument( chatId: ChatIdentifier, document: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, threadId: MessageThreadId? = chatId.threadId, @@ -42,15 +43,13 @@ fun SendDocument( replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ): Request> { - val documentAsFileId = (document as? FileId) ?.fileId val documentAsFile = document as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendDocumentData( chatId, - documentAsFileId, - thumbAsFileId, + document, + thumbnail ?.fileId, text, parseMode, null, @@ -66,9 +65,9 @@ fun SendDocument( return if (documentAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendDocumentFiles(documentAsFile, thumbAsFile) + listOfNotNull(documentAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -85,7 +84,7 @@ fun SendDocument( fun SendDocument( chatId: ChatIdentifier, document: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, entities: TextSourcesList, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, @@ -95,15 +94,13 @@ fun SendDocument( replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ): Request> { - val documentAsFileId = (document as? FileId) ?.fileId val documentAsFile = document as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendDocumentData( chatId, - documentAsFileId, - thumbAsFileId, + document, + thumbnail ?.fileId, entities.makeString(), null, entities.toRawMessageEntities(), @@ -119,9 +116,9 @@ fun SendDocument( return if (documentAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendDocumentFiles(documentAsFile, thumbAsFile) + listOfNotNull(documentAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -143,7 +140,7 @@ data class SendDocumentData internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(documentField) - val document: String? = null, + val document: InputFile, @SerialName(thumbnailField) override val thumbnail: String? = null, @SerialName(captionField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt index afb914b770..ff2ace3d9e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt @@ -2,10 +2,12 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.requests.abstracts.MultipartFile import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.* +import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent @@ -37,7 +39,7 @@ fun SendMediaGroup( protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -): Request>> { +): Request>> { if (media.size !in mediaCountInMediaGroup) { throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size) } @@ -66,11 +68,11 @@ fun SendMediaGroup( return (if (files.isEmpty()) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendMediaGroupFiles(files) + files.associateBy { it.fileId } ) - }) as Request>> + }) as Request>> } /** diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt index 0c54d063e5..d030d66cba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* @@ -33,7 +34,7 @@ fun SendPhoto( ): Request> { val data = SendPhotoData( chatId, - (photo as? FileId) ?.fileId, + photo, text, parseMode, null, @@ -45,12 +46,14 @@ fun SendPhoto( allowSendingWithoutReply, replyMarkup ) - return data.photo ?.let { + return if (photo is MultipartFile) { + CommonMultipartFileRequest( + data, + listOf(photo).associateBy { it.fileId } + ) + } else { data - } ?: MultipartRequestImpl( - data, - SendPhotoFiles(photo as MultipartFile) - ) + } } fun SendPhoto( @@ -67,7 +70,7 @@ fun SendPhoto( ): Request> { val data = SendPhotoData( chatId, - (photo as? FileId)?.fileId, + photo, entities.makeString(), null, entities.toRawMessageEntities(), @@ -79,12 +82,15 @@ fun SendPhoto( allowSendingWithoutReply, replyMarkup ) - return data.photo ?.let { + + return if (photo is MultipartFile) { + CommonMultipartFileRequest( + data, + listOf(photo).associateBy { it.fileId } + ) + } else { data - } ?: MultipartRequestImpl( - data, - SendPhotoFiles(photo as MultipartFile) - ) + } } private val commonResultDeserializer: DeserializationStrategy> @@ -95,7 +101,7 @@ data class SendPhotoData internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(photoField) - val photo: String? = null, + val photo: InputFile, @SerialName(captionField) override val text: String? = null, @SerialName(parseModeField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt index 3de84286d7..46897671d6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.types.* @@ -28,7 +29,7 @@ fun SendSticker( replyMarkup: KeyboardMarkup? = null ): Request> = SendStickerByFileId( chatId, - sticker as? FileId, + sticker, threadId, disableNotification, protectContent, @@ -37,7 +38,10 @@ fun SendSticker( replyMarkup ).let { when (sticker) { - is MultipartFile -> SendStickerByFile(it, sticker, emoji) + is MultipartFile -> CommonMultipartFileRequest( + it, + listOf(sticker).associateBy { it.fileId } + ) is FileId -> it } } @@ -50,7 +54,7 @@ data class SendStickerByFileId internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(stickerField) - val sticker: FileId? = null, + val sticker: InputFile, @SerialName(messageThreadIdField) override val threadId: MessageThreadId? = chatId.threadId, @SerialName(disableNotificationField) @@ -70,20 +74,3 @@ data class SendStickerByFileId internal constructor( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -data class SendStickerByFile internal constructor( - @Transient - private val sendStickerByFileId: SendStickerByFileId, - val sticker: MultipartFile, - val emoji: String? -) : MultipartRequest>, Request> by sendStickerByFileId { - override val mediaMap: Map = mapOf(stickerField to sticker) - override val paramsJson: JsonObject - get() { - return JsonObject( - mapOfNotNull( - emojiField to emoji ?.let { JsonPrimitive(it) } - ) + sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer()) - ) - } -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt index e427c4f10a..815e784969 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* @@ -22,7 +23,7 @@ import kotlinx.serialization.* fun SendVideo( chatId: ChatIdentifier, video: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, @@ -37,15 +38,13 @@ fun SendVideo( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val videoAsFileId = (video as? FileId) ?.fileId val videoAsFile = video as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendVideoData( chatId, - videoAsFileId, - thumbAsFileId, + video, + thumbnail ?.fileId, text, parseMode, null, @@ -65,9 +64,9 @@ fun SendVideo( return if (videoAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendVideoFiles(videoAsFile, thumbAsFile) + listOfNotNull(videoAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -75,7 +74,7 @@ fun SendVideo( fun SendVideo( chatId: ChatIdentifier, video: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, entities: TextSourcesList, spoilered: Boolean = false, duration: Long? = null, @@ -89,15 +88,13 @@ fun SendVideo( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val videoAsFileId = (video as? FileId) ?.fileId val videoAsFile = video as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendVideoData( chatId, - videoAsFileId, - thumbAsFileId, + video, + thumbnail ?.fileId, entities.makeString(), null, entities.toRawMessageEntities(), @@ -117,9 +114,9 @@ fun SendVideo( return if (videoAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendVideoFiles(videoAsFile, thumbAsFile) + listOfNotNull(videoAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -132,7 +129,7 @@ data class SendVideoData internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(videoField) - val video: String? = null, + val video: InputFile, @SerialName(thumbnailField) override val thumbnail: String? = null, @SerialName(captionField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt index 914e50eafa..0c840feed0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* @@ -14,7 +15,7 @@ import kotlinx.serialization.* fun SendVideoNote( chatId: ChatIdentifier, videoNote: InputFile, - thumb: InputFile? = null, + thumbnail: InputFile? = null, duration: Long? = null, size: Int? = null, // in documentation - length (size of video side) threadId: MessageThreadId? = chatId.threadId, @@ -24,15 +25,13 @@ fun SendVideoNote( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val videoNoteAsFileId = (videoNote as? FileId) ?.fileId val videoNoteAsFile = videoNote as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile + val thumbAsFile = thumbnail as? MultipartFile val data = SendVideoNoteData( chatId, - videoNoteAsFileId, - thumbAsFileId, + videoNote, + thumbnail ?.fileId, duration, size, threadId, @@ -46,9 +45,9 @@ fun SendVideoNote( return if (videoNoteAsFile == null && thumbAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendVideoNoteFiles(videoNoteAsFile, thumbAsFile) + listOfNotNull(videoNoteAsFile, thumbAsFile).associateBy { it.fileId } ) } } @@ -61,7 +60,7 @@ data class SendVideoNoteData internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(videoNoteField) - val videoNote: String? = null, + val videoNote: InputFile, @SerialName(thumbnailField) override val thumbnail: String? = null, @SerialName(durationField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt index 0b914246fb..1bad25a36a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* @@ -32,12 +33,11 @@ fun SendVoice( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val voiceAsFileId = (voice as? FileId) ?.fileId val voiceAsFile = voice as? MultipartFile val data = SendVoiceData( chatId, - voiceAsFileId, + voice, text, parseMode, null, @@ -53,9 +53,9 @@ fun SendVoice( return if (voiceAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendVoiceFiles(voiceAsFile) + listOfNotNull(voiceAsFile).associateBy { it.fileId } ) } } @@ -72,12 +72,11 @@ fun SendVoice( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): Request> { - val voiceAsFileId = (voice as? FileId) ?.fileId val voiceAsFile = voice as? MultipartFile val data = SendVoiceData( chatId, - voiceAsFileId, + voice, entities.makeString(), null, entities.toRawMessageEntities(), @@ -93,9 +92,9 @@ fun SendVoice( return if (voiceAsFile == null) { data } else { - MultipartRequestImpl( + CommonMultipartFileRequest( data, - SendVoiceFiles(voiceAsFile) + listOfNotNull(voiceAsFile).associateBy { it.fileId } ) } } @@ -108,7 +107,7 @@ data class SendVoiceData internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(voiceField) - val voice: String? = null, + val voice: InputFile, @SerialName(captionField) override val text: String? = null, @SerialName(parseModeField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt index 7895e7ef93..5cf4afa885 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt @@ -1,11 +1,15 @@ package dev.inmo.tgbotapi.requests.stickers +import dev.inmo.micro_utils.serialization.mapper.MapperSerializer 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.types.* import dev.inmo.tgbotapi.types.stickers.MaskPosition import kotlinx.serialization.* +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder /** * Will create one of [CreateNewStickerSet] types based on the first element of [stickers] @@ -26,18 +30,30 @@ fun CreateNewStickerSet( is InputSticker.WithKeywords.CustomEmoji -> CreateNewStickerSet.CustomEmoji(userId, name, title, stickersFormat, stickers.filterIsInstance(), needsRepainting) is InputSticker.WithKeywords.Regular -> CreateNewStickerSet.Regular(userId, name, title, stickersFormat, stickers.filterIsInstance()) } - val multipartParts = stickers.mapNotNull { (it.sticker as? MultipartFile) } + val multipartParts = stickers.mapNotNull { + (it.sticker as? MultipartFile) + } return if (multipartParts.isNotEmpty()) { - CommonMultipartFileRequest( - data, - multipartParts.associateBy { it.fileId } - ) + when (data) { // cratch for exact determining of common multipart data type + is CreateNewStickerSet.CustomEmoji -> CommonMultipartFileRequest( + data, + multipartParts.associateBy { it.fileId } + ) + is CreateNewStickerSet.Mask -> CommonMultipartFileRequest( + data, + multipartParts.associateBy { it.fileId } + ) + is CreateNewStickerSet.Regular -> CommonMultipartFileRequest( + data, + multipartParts.associateBy { it.fileId } + ) + } } else { data } } -@Serializable +@Serializable(CreateNewStickerSetSerializer::class) sealed interface CreateNewStickerSet : CreateStickerSetAction { val stickerType: StickerType val stickers: List @@ -101,4 +117,70 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction { override val stickerType: StickerType get() = StickerType.CustomEmoji } + + @Serializable + data class SurrogateCreateNewSticker internal constructor( + @SerialName(userIdField) + override val userId: UserId, + @SerialName(nameField) + override val name: String, + @SerialName(titleField) + override val title: String, + @SerialName(stickerFormatField) + val stickersFormat: StickerFormat, + @SerialName(stickersField) + val stickers: List, + @SerialName(stickerTypeField) + val stickerType: StickerType, + @SerialName(needsRepaintingField) + val needsRepainting: Boolean? = null + ) : CreateStickerSetAction { + override val requestSerializer: SerializationStrategy<*> + get() = CreateNewStickerSet.serializer() + + override fun method(): String = "createNewStickerSet" + } } + +object CreateNewStickerSetSerializer : KSerializer, + MapperSerializer( + CreateNewStickerSet.SurrogateCreateNewSticker.serializer(), + { + CreateNewStickerSet.SurrogateCreateNewSticker( + it.userId, + it.name, + it.title, + it.stickersFormat, + it.stickers, + it.stickerType, + (it as? CreateNewStickerSet.CustomEmoji)?.needsRepainting + ) + }, + { + when (it.stickerType) { + StickerType.CustomEmoji -> CreateNewStickerSet.CustomEmoji( + it.userId, + it.name, + it.title, + it.stickersFormat, + it.stickers.filterIsInstance(), + it.needsRepainting + ) + StickerType.Mask -> CreateNewStickerSet.Mask( + it.userId, + it.name, + it.title, + it.stickersFormat, + it.stickers.filterIsInstance(), + ) + StickerType.Regular -> CreateNewStickerSet.Regular( + it.userId, + it.name, + it.title, + it.stickersFormat, + it.stickers.filterIsInstance(), + ) + is StickerType.Unknown -> error("Unable to create new sticker set due to error in type format: ${it.stickerType}") + } + } + ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt index 9633b555a7..874fff6676 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt @@ -1,17 +1,20 @@ package dev.inmo.tgbotapi.requests.stickers +import dev.inmo.micro_utils.serialization.mapper.MapperSerializer import dev.inmo.tgbotapi.requests.abstracts.InputFile +import dev.inmo.tgbotapi.types.StickerType 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.KSerializer import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @ClassCastsIncluded -@Serializable +@Serializable(InputStickerSerializer::class) sealed interface InputSticker { val sticker: InputFile val emojisList: List @@ -51,3 +54,69 @@ sealed interface InputSticker { ) : WithKeywords } } + +object InputStickerSerializer : KSerializer, MapperSerializer( + SurrogateInputSticker.serializer(), + { + when (it) { + is InputSticker.Mask -> SurrogateInputSticker( + it.sticker, + it.emojisList, + emptyList(), + it.maskPosition, + StickerType.Mask + ) + is InputSticker.WithKeywords.CustomEmoji -> SurrogateInputSticker( + it.sticker, + it.emojisList, + it.keywords, + null, + StickerType.CustomEmoji + ) + is InputSticker.WithKeywords.Regular -> SurrogateInputSticker( + it.sticker, + it.emojisList, + it.keywords, + null, + StickerType.Regular + ) + } + }, + { + when (it.internalType) { + StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji( + it.sticker, + it.emojisList, + it.keywords + ) + StickerType.Mask -> InputSticker.Mask( + it.sticker, + it.emojisList, + it.maskPosition + ) + StickerType.Regular -> InputSticker.WithKeywords.Regular( + it.sticker, + it.emojisList, + it.keywords + ) + is StickerType.Unknown -> InputSticker.WithKeywords.Regular( + it.sticker, + it.emojisList, + it.keywords + ) + } + }, +) { + @Serializable + data class SurrogateInputSticker internal constructor( + @SerialName(stickerField) + val sticker: InputFile, + @SerialName(emojiListField) + val emojisList: List, + @SerialName(keywordsField) + val keywords: List = emptyList(), + @SerialName(maskPositionField) + val maskPosition: MaskPosition? = null, + internal val internalType: StickerType = StickerType.Unknown() + ) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt index 89b9ad92d0..9d21571e14 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt @@ -118,6 +118,18 @@ sealed interface MediaCollectionContent: MessageContent, M sealed interface MediaContent: MessageContent { val media: TelegramMediaFile fun asTelegramMedia(): TelegramMedia + + override fun createResend( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, + disableNotification: Boolean, + protectContent: Boolean, + replyToMessageId: MessageId?, + allowSendingWithoutReply: Boolean?, + replyMarkup: KeyboardMarkup? + ): Request> { + TODO("Not yet implemented") + } } sealed interface SpoilerableMediaContent : MediaContent, SpoilerableData diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt index 8af2a53a34..1b0c05cb53 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt @@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.media.TelegramMedia +import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.textsources.TextSource import kotlinx.serialization.Serializable @@ -38,7 +39,7 @@ data class MediaGroupContent( replyToMessageId: MessageId?, allowSendingWithoutReply: Boolean?, replyMarkup: KeyboardMarkup? - ): Request = SendMediaGroup( + ): Request>> = SendMediaGroup( chatId, group.map { it.content.toMediaGroupMemberTelegramMedia() }, threadId, From 69683a4e6a716dcab55d3813d64140bd40b95c9e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Mar 2023 22:38:09 +0600 Subject: [PATCH 28/28] upfill changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8df791012c..4e3c688fcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,12 @@ This update contains support of [Telegram Bot API 6.6](https://core.telegram.org * Fully reworked mechanism of stickers creating and adding * All separations of stickers types like `Animeted` have been replaces with type `StickerFormat` * New `InputSticker` type (and all subtypes) as replacements for old raw fields in methods +* Reworked mechanism of files uploading Other changes * `Versions`: - * `MicroUtils`: `0.17.3` -> `0.17.4` + * `MicroUtils`: `0.17.3` -> `0.17.5` ## 6.1.0