From 1633b9baafd132039a53110e5ef7be32d1c21acd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 11:18:37 +0600 Subject: [PATCH] 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() +}