mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 12:08:43 +00:00
update uploadStickerFile
This commit is contained in:
parent
1b4d13e452
commit
4390c12180
@ -3,19 +3,22 @@ package dev.inmo.tgbotapi.extensions.api.stickers
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
|
import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
|
||||||
|
import dev.inmo.tgbotapi.types.StickerFormat
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
|
||||||
suspend fun TelegramBot.uploadStickerFile(
|
suspend fun TelegramBot.uploadStickerFile(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
sticker: MultipartFile
|
sticker: MultipartFile,
|
||||||
|
stickerFormat: StickerFormat
|
||||||
) = execute(
|
) = execute(
|
||||||
UploadStickerFile(userId, sticker)
|
UploadStickerFile(userId, sticker, stickerFormat)
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.uploadStickerFile(
|
suspend fun TelegramBot.uploadStickerFile(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
sticker: MultipartFile
|
sticker: MultipartFile,
|
||||||
|
stickerFormat: StickerFormat
|
||||||
) = execute(
|
) = execute(
|
||||||
UploadStickerFile(user.id, sticker)
|
UploadStickerFile(user.id, sticker, stickerFormat)
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,9 @@ data class UploadStickerFile(
|
|||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
val userId: UserId,
|
val userId: UserId,
|
||||||
@Transient
|
@Transient
|
||||||
val sticker: MultipartFile = throw IllegalStateException("Detected autocreating try: this class can't be deserialized")
|
val sticker: MultipartFile = throw IllegalStateException("Detected autocreating try: this class can't be deserialized"),
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
val stickerFormat: StickerFormat
|
||||||
): MultipartRequest<File> {
|
): MultipartRequest<File> {
|
||||||
init {
|
init {
|
||||||
// TODO:: add check of width/height of image and type of file - it must be png with max side length is 512px
|
// TODO:: add check of width/height of image and type of file - it must be png with max side length is 512px
|
||||||
@ -21,7 +23,7 @@ data class UploadStickerFile(
|
|||||||
|
|
||||||
override fun method(): String = "uploadStickerFile"
|
override fun method(): String = "uploadStickerFile"
|
||||||
@Transient
|
@Transient
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(pngStickerField to sticker)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
||||||
@Transient
|
@Transient
|
||||||
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
|
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
|
||||||
override val resultDeserializer: DeserializationStrategy<File>
|
override val resultDeserializer: DeserializationStrategy<File>
|
||||||
|
Loading…
Reference in New Issue
Block a user