49 lines
1.6 KiB
Kotlin
49 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.SerialName
|
|
import kotlinx.serialization.Serializable
|
|
|
|
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)
|
|
val sticker: FileId? = null,
|
|
@SerialName(maskPositionField)
|
|
override val maskPosition: MaskPosition? = null
|
|
) : StickerSetAction {
|
|
init {
|
|
if(emojis.isEmpty()) {
|
|
throw IllegalArgumentException("Emojis must not be empty")
|
|
}
|
|
}
|
|
|
|
override fun method(): String = "addStickerToSet"
|
|
}
|