From 945dd05cfda7c0712df6500731ac5bc11282606c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 6 Feb 2020 23:54:14 +0600 Subject: [PATCH] add add sticker to set and set sticker position in set extensions --- .../requests/stickers/AddStickerToSet.kt | 89 +++++++++++++++++++ .../stickers/SetStickerPositionInSet.kt | 20 +++++ 2 files changed, 109 insertions(+) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/AddStickerToSet.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/AddStickerToSet.kt index 113ad5966e..ac09f673fd 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/AddStickerToSet.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/AddStickerToSet.kt @@ -1,10 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers +import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition +import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet import kotlinx.serialization.* fun AddStickerToSet( @@ -48,3 +50,90 @@ data class AddStickerToSet internal constructor( override fun method(): String = "addStickerToSet" } + +suspend fun RequestsExecutor.addStickerToSet( + userId: UserId, + stickerSetName: String, + sticker: FileId, + emojis: String, + maskPosition: MaskPosition? = null +) = execute( + AddStickerToSet( + userId, stickerSetName, emojis, sticker, maskPosition + ) +) + +suspend fun RequestsExecutor.addStickerToSet( + userId: UserId, + stickerSetName: String, + sticker: MultipartFile, + emojis: String, + maskPosition: MaskPosition? = null +) = execute( + CommonMultipartFileRequest( + AddStickerToSet( + userId, stickerSetName, emojis, null, maskPosition + ), + mapOf(pngStickerField to sticker) + ) +) + +suspend fun RequestsExecutor.addStickerToSet( + user: CommonUser, + stickerSetName: String, + sticker: FileId, + emojis: String, + maskPosition: MaskPosition? = null +) = addStickerToSet( + user.id, stickerSetName, sticker, emojis, maskPosition +) + +suspend fun RequestsExecutor.addStickerToSet( + user: CommonUser, + stickerSetName: String, + sticker: MultipartFile, + emojis: String, + maskPosition: MaskPosition? = null +) = addStickerToSet( + user.id, stickerSetName, sticker, emojis, maskPosition +) + +suspend fun RequestsExecutor.addStickerToSet( + userId: UserId, + stickerSet: StickerSet, + sticker: FileId, + emojis: String, + maskPosition: MaskPosition? = null +) = addStickerToSet( + userId, stickerSet.name, sticker, emojis, maskPosition +) + +suspend fun RequestsExecutor.addStickerToSet( + userId: UserId, + stickerSet: StickerSet, + sticker: MultipartFile, + emojis: String, + maskPosition: MaskPosition? = null +) = addStickerToSet( + userId, stickerSet.name, sticker, emojis, maskPosition +) + +suspend fun RequestsExecutor.addStickerToSet( + user: CommonUser, + stickerSet: StickerSet, + sticker: FileId, + emojis: String, + maskPosition: MaskPosition? = null +) = addStickerToSet( + user.id, stickerSet.name, sticker, emojis, maskPosition +) + +suspend fun RequestsExecutor.addStickerToSet( + user: CommonUser, + stickerSet: StickerSet, + sticker: MultipartFile, + emojis: String, + maskPosition: MaskPosition? = null +) = addStickerToSet( + user.id, stickerSet.name, sticker, emojis, maskPosition +) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt index cf2fcd7150..90484177cf 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt @@ -1,7 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers +import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest +import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker import com.github.insanusmokrassar.TelegramBotAPI.types.positionField import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField import kotlinx.serialization.* @@ -26,3 +28,21 @@ data class SetStickerPositionInSet( override val requestSerializer: SerializationStrategy<*> get() = serializer() } + +suspend fun RequestsExecutor.setStickerPositionInSet( + sticker: FileId, + position: Int +) = execute( + SetStickerPositionInSet( + sticker, + position + ) +) + +suspend fun RequestsExecutor.setStickerPositionInSet( + sticker: Sticker, + position: Int +) = setStickerPositionInSet( + sticker.fileId, + position +)