mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 07:09:23 +00:00
add setStickerSetThumb
This commit is contained in:
@@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
@@ -35,7 +36,7 @@ data class AddAnimatedStickerToSet internal constructor(
|
||||
val sticker: FileId? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
||||
) : StickerSetAction {
|
||||
) : StandardStickerSetAction {
|
||||
init {
|
||||
if(emojis.isEmpty()) {
|
||||
throw IllegalArgumentException("Emojis must not be empty")
|
||||
|
@@ -2,10 +2,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun AddStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
@@ -53,7 +55,7 @@ data class AddStaticStickerToSet internal constructor(
|
||||
val sticker: FileId? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
||||
) : StickerSetAction {
|
||||
) : StandardStickerSetAction {
|
||||
init {
|
||||
if(emojis.isEmpty()) {
|
||||
throw IllegalArgumentException("Emojis must not be empty")
|
||||
|
@@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
@@ -39,7 +40,7 @@ data class CreateNewAnimatedStickerSet internal constructor(
|
||||
val containsMasks: Boolean? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
||||
) : StickerSetAction {
|
||||
) : StandardStickerSetAction {
|
||||
init {
|
||||
if(emojis.isEmpty()) {
|
||||
throw IllegalArgumentException("Emojis must not be empty")
|
||||
|
@@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
@@ -54,7 +55,7 @@ data class CreateNewStaticStickerSet internal constructor(
|
||||
val containsMasks: Boolean? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
||||
) : StickerSetAction {
|
||||
) : StandardStickerSetAction {
|
||||
init {
|
||||
if(emojis.isEmpty()) {
|
||||
throw IllegalArgumentException("Emojis must not be empty")
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||
|
||||
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 kotlinx.serialization.*
|
||||
|
||||
fun SetStickerSetThumb(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: InputFile
|
||||
): Request<Boolean> {
|
||||
val data = SetStickerSetThumb(userId, stickerSetName, sticker as? FileId)
|
||||
return when (sticker) {
|
||||
is MultipartFile -> CommonMultipartFileRequest(
|
||||
data,
|
||||
mapOf(thumbField to sticker)
|
||||
)
|
||||
is FileId -> data
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class SetStickerSetThumb internal constructor(
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
override val name: StickerSetName,
|
||||
@SerialName(thumbField)
|
||||
val thumb: FileId? = null
|
||||
) : StickerSetAction {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = "setStickerSetThumb"
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
|
||||
interface StandardStickerSetAction : StickerSetAction {
|
||||
val emojis: String // must be more than one
|
||||
val maskPosition: MaskPosition?
|
||||
}
|
@@ -9,8 +9,6 @@ import kotlinx.serialization.builtins.serializer
|
||||
interface StickerSetAction : SimpleRequest<Boolean> {
|
||||
val userId: UserId
|
||||
val name: String
|
||||
val emojis: String // must be more than one
|
||||
val maskPosition: MaskPosition?
|
||||
|
||||
override val resultDeserializer: KSerializer<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
|
Reference in New Issue
Block a user