mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-06-29 12:57:48 +00:00
50 lines
1.6 KiB
Kotlin
50 lines
1.6 KiB
Kotlin
|
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 com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||
|
import kotlinx.serialization.*
|
||
|
|
||
|
fun AddStickerToSet(
|
||
|
userId: UserId,
|
||
|
stickerSetName: String,
|
||
|
sticker: InputFile,
|
||
|
emojis: String,
|
||
|
maskPosition: MaskPosition? = null
|
||
|
): Request<Boolean> {
|
||
|
val data = AddStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
||
|
return when (sticker) {
|
||
|
is MultipartFile -> CommonMultipartFileRequest(
|
||
|
data,
|
||
|
mapOf(pngStickerField to sticker)
|
||
|
)
|
||
|
is FileId -> data
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Serializable
|
||
|
data class AddStickerToSet internal constructor(
|
||
|
@SerialName(userIdField)
|
||
|
override val userId: UserId,
|
||
|
@SerialName(nameField)
|
||
|
override val name: String,
|
||
|
@SerialName(emojisField)
|
||
|
override val emojis: String,
|
||
|
@SerialName(pngStickerField)
|
||
|
@Optional
|
||
|
val sticker: FileId? = null,
|
||
|
@SerialName(maskPositionField)
|
||
|
@Optional
|
||
|
override val maskPosition: MaskPosition? = null
|
||
|
) : StickerSetAction {
|
||
|
init {
|
||
|
if(emojis.isEmpty()) {
|
||
|
throw IllegalArgumentException("Emojis must not be empty")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
override fun method(): String = "addStickerToSet"
|
||
|
}
|