mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 07:09:23 +00:00
addAnimatedStickerToSet
This commit is contained in:
@@ -6,15 +6,14 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.St
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun AddStickerToSet(
|
||||
fun AddAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: InputFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
): Request<Boolean> {
|
||||
val data = AddStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
||||
val data = AddAnimatedStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
||||
return when (sticker) {
|
||||
is MultipartFile -> CommonMultipartFileRequest(
|
||||
data,
|
||||
@@ -25,14 +24,14 @@ fun AddStickerToSet(
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class AddStickerToSet internal constructor(
|
||||
data class AddAnimatedStickerToSet internal constructor(
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
override val name: String,
|
||||
@SerialName(emojisField)
|
||||
override val emojis: String,
|
||||
@SerialName(pngStickerField)
|
||||
@SerialName(tgsStickerField)
|
||||
val sticker: FileId? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
@@ -0,0 +1,67 @@
|
||||
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 AddStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: InputFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
): Request<Boolean> {
|
||||
val data = AddStaticStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
||||
return when (sticker) {
|
||||
is MultipartFile -> CommonMultipartFileRequest(
|
||||
data,
|
||||
mapOf(pngStickerField to sticker)
|
||||
)
|
||||
is FileId -> data
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Renamed",
|
||||
ReplaceWith("AddStaticStickerToSet", "com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.AddStaticStickerToSet")
|
||||
)
|
||||
fun AddStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: InputFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
|
||||
@Deprecated(
|
||||
"Renamed",
|
||||
ReplaceWith("AddStaticStickerToSet", "com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.AddStaticStickerToSet")
|
||||
)
|
||||
typealias AddStickerToSet = AddStaticStickerToSet
|
||||
|
||||
@Serializable
|
||||
data class AddStaticStickerToSet 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 val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = "addStickerToSet"
|
||||
}
|
Reference in New Issue
Block a user