mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
support of Telegram Bot API 5.7
This commit is contained in:
parent
eee9fe439f
commit
0c2fe6bce7
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
## 0.38.4
|
## 0.38.4
|
||||||
|
|
||||||
|
__This update contains including of [Telegram Bot API 5.7](https://core.telegram.org/bots/api-changelog#january-31-2022)__
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Support of new fields `Sticker`
|
||||||
|
* Support of new fields `StickerSet`
|
||||||
|
* Support of new fields in creating of sticker set and sticker
|
||||||
* `Utils`:
|
* `Utils`:
|
||||||
* Rename `PathedFile` to avoid clash with core file (fix of [#529](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/529))
|
* Rename `PathedFile` to avoid clash with core file (fix of [#529](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/529))
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-5.6-blue)](https://core.telegram.org/bots/api-changelog#december-30-2021)
|
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-5.7-blue)](https://core.telegram.org/bots/api-changelog#january-31-2022)
|
||||||
|
|
||||||
| [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://github.com/InsanusMokrassar/TelegramBotAPI/workflows/Build/badge.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [![Small survey](https://img.shields.io/static/v1?label=Google&message=Survey&color=blue)](https://forms.gle/2Hex2ynbHWHhi1KY7) [![Chat in Telegram](https://img.shields.io/static/v1?label=Telegram&message=Chat&color=blue)](https://t.me/InMoTelegramBotAPI) |
|
| [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://github.com/InsanusMokrassar/TelegramBotAPI/workflows/Build/badge.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [![Small survey](https://img.shields.io/static/v1?label=Google&message=Survey&color=blue)](https://forms.gle/2Hex2ynbHWHhi1KY7) [![Chat in Telegram](https://img.shields.io/static/v1?label=Telegram&message=Chat&color=blue)](https://t.me/InMoTelegramBotAPI) |
|
||||||
|:---:|
|
|:---:|
|
||||||
|
@ -12,7 +12,7 @@ klock_version=2.4.12
|
|||||||
uuid_version=0.4.0
|
uuid_version=0.4.0
|
||||||
ktor_version=1.6.7
|
ktor_version=1.6.7
|
||||||
|
|
||||||
micro_utils_version=0.9.2
|
micro_utils_version=0.9.4
|
||||||
|
|
||||||
javax_activation_version=1.1.1
|
javax_activation_version=1.1.1
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.get
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.get.GetStickerSet
|
import dev.inmo.tgbotapi.requests.get.GetStickerSet
|
||||||
import dev.inmo.tgbotapi.types.files.Sticker
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
|
|
||||||
suspend fun TelegramBot.getStickerSet(
|
suspend fun TelegramBot.getStickerSet(
|
||||||
name: String
|
name: String
|
||||||
|
@ -16,6 +16,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
|
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
|
||||||
import dev.inmo.tgbotapi.types.files.*
|
import dev.inmo.tgbotapi.types.files.*
|
||||||
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
import dev.inmo.tgbotapi.types.games.Game
|
import dev.inmo.tgbotapi.types.games.Game
|
||||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
import dev.inmo.tgbotapi.types.location.StaticLocation
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
|
|||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||||
import dev.inmo.tgbotapi.types.files.Sticker
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.AddVideoStickerToSet
|
||||||
|
import dev.inmo.tgbotapi.types.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addVideoStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addVideoStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addVideoStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addVideoStickerToSet(
|
||||||
|
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addVideoStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addVideoStickerToSet(
|
||||||
|
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addVideoStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addVideoStickerToSet(
|
||||||
|
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addVideoStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addVideoStickerToSet(
|
||||||
|
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addVideoStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addVideoStickerToSet(
|
||||||
|
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addVideoStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addVideoStickerToSet(
|
||||||
|
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
@ -0,0 +1,54 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.CreateNewVideoStickerSet
|
||||||
|
import dev.inmo.tgbotapi.types.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
|
||||||
|
suspend fun TelegramBot.createNewVideoStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CreateNewVideoStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.createNewVideoStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CreateNewVideoStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun TelegramBot.createNewVideoStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = createNewVideoStickerSet(
|
||||||
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.createNewVideoStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = createNewVideoStickerSet(
|
||||||
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
|
)
|
@ -3,7 +3,7 @@ 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.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.requests.stickers.DeleteStickerFromSet
|
import dev.inmo.tgbotapi.requests.stickers.DeleteStickerFromSet
|
||||||
import dev.inmo.tgbotapi.types.files.Sticker
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
|
|
||||||
suspend fun TelegramBot.deleteStickerFromSet(
|
suspend fun TelegramBot.deleteStickerFromSet(
|
||||||
sticker: FileId
|
sticker: FileId
|
||||||
|
@ -3,7 +3,7 @@ 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.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||||
import dev.inmo.tgbotapi.types.files.Sticker
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
|
|
||||||
suspend fun TelegramBot.setStickerPositionInSet(
|
suspend fun TelegramBot.setStickerPositionInSet(
|
||||||
sticker: FileId,
|
sticker: FileId,
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
fun AddVideoStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
): Request<Boolean> {
|
||||||
|
val data = AddVideoStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
||||||
|
return when (sticker) {
|
||||||
|
is MultipartFile -> CommonMultipartFileRequest(
|
||||||
|
data,
|
||||||
|
mapOf(pngStickerField to sticker)
|
||||||
|
)
|
||||||
|
is FileId -> data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class AddVideoStickerToSet internal constructor(
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
override val name: String,
|
||||||
|
@SerialName(emojisField)
|
||||||
|
override val emojis: String,
|
||||||
|
@SerialName(webmStickerField)
|
||||||
|
val sticker: FileId? = null,
|
||||||
|
@SerialName(maskPositionField)
|
||||||
|
override val maskPosition: MaskPosition? = null
|
||||||
|
) : StandardStickerSetAction {
|
||||||
|
init {
|
||||||
|
if(emojis.isEmpty()) {
|
||||||
|
throw IllegalArgumentException("Emojis must not be empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
override fun method(): String = "addStickerToSet"
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
fun CreateNewVideoStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
): Request<Boolean> {
|
||||||
|
val data = CreateNewVideoStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition)
|
||||||
|
return when (sticker) {
|
||||||
|
is MultipartFile -> CommonMultipartFileRequest(
|
||||||
|
data,
|
||||||
|
mapOf(pngStickerField to sticker)
|
||||||
|
)
|
||||||
|
is FileId -> data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CreateNewVideoStickerSet internal constructor(
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
override val name: String,
|
||||||
|
@SerialName(emojisField)
|
||||||
|
override val emojis: String,
|
||||||
|
@SerialName(webmStickerField)
|
||||||
|
val sticker: FileId? = null,
|
||||||
|
@SerialName(containsMasksField)
|
||||||
|
val containsMasks: Boolean? = null,
|
||||||
|
@SerialName(maskPositionField)
|
||||||
|
override val maskPosition: MaskPosition? = null
|
||||||
|
) : StandardStickerSetAction {
|
||||||
|
init {
|
||||||
|
if(emojis.isEmpty()) {
|
||||||
|
throw IllegalArgumentException("Emojis must not be empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
override fun method(): String = "createNewStickerSet"
|
||||||
|
}
|
@ -168,6 +168,7 @@ const val botUsernameField = "bot_username"
|
|||||||
const val switchInlineQueryCurrentChatField = "switch_inline_query_current_chat"
|
const val switchInlineQueryCurrentChatField = "switch_inline_query_current_chat"
|
||||||
const val switchInlineQueryField = "switch_inline_query"
|
const val switchInlineQueryField = "switch_inline_query"
|
||||||
const val isAnimatedField = "is_animated"
|
const val isAnimatedField = "is_animated"
|
||||||
|
const val isVideoField = "is_video"
|
||||||
const val inviteLinkField = "invite_link"
|
const val inviteLinkField = "invite_link"
|
||||||
const val pinnedMessageField = "pinned_message"
|
const val pinnedMessageField = "pinned_message"
|
||||||
const val customTitleField = "custom_title"
|
const val customTitleField = "custom_title"
|
||||||
@ -265,6 +266,7 @@ const val canManageVoiceChatsField = "can_manage_voice_chats"
|
|||||||
const val canManageChatField = "can_manage_chat"
|
const val canManageChatField = "can_manage_chat"
|
||||||
const val pngStickerField = "png_sticker"
|
const val pngStickerField = "png_sticker"
|
||||||
const val tgsStickerField = "tgs_sticker"
|
const val tgsStickerField = "tgs_sticker"
|
||||||
|
const val webmStickerField = "webm_sticker"
|
||||||
const val oldChatMemberField = "old_chat_member"
|
const val oldChatMemberField = "old_chat_member"
|
||||||
const val newChatMemberField = "new_chat_member"
|
const val newChatMemberField = "new_chat_member"
|
||||||
|
|
||||||
|
@ -1,32 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types.files
|
package dev.inmo.tgbotapi.types.files
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.files.abstracts.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Deprecated("Replaced", ReplaceWith("Sticker", "dev.inmo.tgbotapi.types.files.sticker.Sticker"))
|
||||||
data class Sticker(
|
typealias Sticker = Sticker
|
||||||
@SerialName(fileIdField)
|
|
||||||
override val fileId: FileId,
|
|
||||||
@SerialName(fileUniqueIdField)
|
|
||||||
override val fileUniqueId: FileUniqueId,
|
|
||||||
@SerialName(widthField)
|
|
||||||
override val width: Int,
|
|
||||||
@SerialName(heightField)
|
|
||||||
override val height: Int,
|
|
||||||
@SerialName(thumbField)
|
|
||||||
override val thumb: PhotoSize? = null,
|
|
||||||
@SerialName(emojiField)
|
|
||||||
val emoji: String? = null,
|
|
||||||
@SerialName(stickerSetNameField)
|
|
||||||
val stickerSetName: StickerSetName? = null,
|
|
||||||
@SerialName(isAnimatedField)
|
|
||||||
val isAnimated: Boolean = false,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
val maskPosition: MaskPosition? = null,
|
|
||||||
@SerialName(fileSizeField)
|
|
||||||
override val fileSize: Long? = null
|
|
||||||
) : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile
|
|
||||||
|
@ -0,0 +1,158 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.files.sticker
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.files.PhotoSize
|
||||||
|
import dev.inmo.tgbotapi.types.files.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
@RiskFeature("This class is used for serialization/deserialization of Sticker interface")
|
||||||
|
data class StickerSurrogate(
|
||||||
|
val file_id: FileId,
|
||||||
|
val file_unique_id: FileUniqueId,
|
||||||
|
val width: Int,
|
||||||
|
val height: Int,
|
||||||
|
val is_animated: Boolean? = null,
|
||||||
|
val is_video: Boolean? = null,
|
||||||
|
val thumb: PhotoSize? = null,
|
||||||
|
val emoji: String? = null,
|
||||||
|
val set_name: StickerSetName? = null,
|
||||||
|
val mask_position: MaskPosition? = null,
|
||||||
|
val file_size: Long? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO:: Serializer
|
||||||
|
@Serializable(StickerSerializer::class)
|
||||||
|
sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile {
|
||||||
|
val emoji: String?
|
||||||
|
val maskPosition: MaskPosition?
|
||||||
|
val stickerSetName: StickerSetName?
|
||||||
|
|
||||||
|
val isAnimated
|
||||||
|
get() = this is AnimatedSticker
|
||||||
|
val isVideo
|
||||||
|
get() = this is VideoSticker
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun serializer(): KSerializer<Sticker> = StickerSerializer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object StickerSerializer : KSerializer<Sticker> {
|
||||||
|
override val descriptor: SerialDescriptor = StickerSurrogate.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): Sticker {
|
||||||
|
val surrogate = StickerSurrogate.serializer().deserialize(decoder)
|
||||||
|
|
||||||
|
return when {
|
||||||
|
surrogate.is_animated == true -> AnimatedSticker(
|
||||||
|
surrogate.file_id,
|
||||||
|
surrogate.file_unique_id,
|
||||||
|
surrogate.width,
|
||||||
|
surrogate.height,
|
||||||
|
surrogate.thumb,
|
||||||
|
surrogate.emoji,
|
||||||
|
surrogate.set_name,
|
||||||
|
surrogate.mask_position,
|
||||||
|
surrogate.file_size
|
||||||
|
)
|
||||||
|
surrogate.is_video == true -> VideoSticker(
|
||||||
|
surrogate.file_id,
|
||||||
|
surrogate.file_unique_id,
|
||||||
|
surrogate.width,
|
||||||
|
surrogate.height,
|
||||||
|
surrogate.thumb,
|
||||||
|
surrogate.emoji,
|
||||||
|
surrogate.set_name,
|
||||||
|
surrogate.mask_position,
|
||||||
|
surrogate.file_size
|
||||||
|
)
|
||||||
|
else -> SimpleSticker(
|
||||||
|
surrogate.file_id,
|
||||||
|
surrogate.file_unique_id,
|
||||||
|
surrogate.width,
|
||||||
|
surrogate.height,
|
||||||
|
surrogate.thumb,
|
||||||
|
surrogate.emoji,
|
||||||
|
surrogate.set_name,
|
||||||
|
surrogate.mask_position,
|
||||||
|
surrogate.file_size
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: Sticker) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SimpleSticker(
|
||||||
|
@SerialName(fileIdField)
|
||||||
|
override val fileId: FileId,
|
||||||
|
@SerialName(fileUniqueIdField)
|
||||||
|
override val fileUniqueId: FileUniqueId,
|
||||||
|
@SerialName(widthField)
|
||||||
|
override val width: Int,
|
||||||
|
@SerialName(heightField)
|
||||||
|
override val height: Int,
|
||||||
|
@SerialName(thumbField)
|
||||||
|
override val thumb: PhotoSize? = null,
|
||||||
|
@SerialName(emojiField)
|
||||||
|
override val emoji: String? = null,
|
||||||
|
@SerialName(stickerSetNameField)
|
||||||
|
override val stickerSetName: StickerSetName? = null,
|
||||||
|
@SerialName(maskPositionField)
|
||||||
|
override val maskPosition: MaskPosition? = null,
|
||||||
|
@SerialName(fileSizeField)
|
||||||
|
override val fileSize: Long? = null,
|
||||||
|
) : Sticker
|
||||||
|
@Serializable
|
||||||
|
data class AnimatedSticker(
|
||||||
|
@SerialName(fileIdField)
|
||||||
|
override val fileId: FileId,
|
||||||
|
@SerialName(fileUniqueIdField)
|
||||||
|
override val fileUniqueId: FileUniqueId,
|
||||||
|
@SerialName(widthField)
|
||||||
|
override val width: Int,
|
||||||
|
@SerialName(heightField)
|
||||||
|
override val height: Int,
|
||||||
|
@SerialName(thumbField)
|
||||||
|
override val thumb: PhotoSize? = null,
|
||||||
|
@SerialName(emojiField)
|
||||||
|
override val emoji: String? = null,
|
||||||
|
@SerialName(stickerSetNameField)
|
||||||
|
override val stickerSetName: StickerSetName? = null,
|
||||||
|
@SerialName(maskPositionField)
|
||||||
|
override val maskPosition: MaskPosition? = null,
|
||||||
|
@SerialName(fileSizeField)
|
||||||
|
override val fileSize: Long? = null,
|
||||||
|
) : Sticker
|
||||||
|
@Serializable
|
||||||
|
data class VideoSticker(
|
||||||
|
@SerialName(fileIdField)
|
||||||
|
override val fileId: FileId,
|
||||||
|
@SerialName(fileUniqueIdField)
|
||||||
|
override val fileUniqueId: FileUniqueId,
|
||||||
|
@SerialName(widthField)
|
||||||
|
override val width: Int,
|
||||||
|
@SerialName(heightField)
|
||||||
|
override val height: Int,
|
||||||
|
@SerialName(thumbField)
|
||||||
|
override val thumb: PhotoSize? = null,
|
||||||
|
@SerialName(emojiField)
|
||||||
|
override val emoji: String? = null,
|
||||||
|
@SerialName(stickerSetNameField)
|
||||||
|
override val stickerSetName: StickerSetName? = null,
|
||||||
|
@SerialName(maskPositionField)
|
||||||
|
override val maskPosition: MaskPosition? = null,
|
||||||
|
@SerialName(fileSizeField)
|
||||||
|
override val fileSize: Long? = null,
|
||||||
|
) : Sticker
|
@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|||||||
import dev.inmo.tgbotapi.types.chat.abstracts.*
|
import dev.inmo.tgbotapi.types.chat.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.dice.Dice
|
import dev.inmo.tgbotapi.types.dice.Dice
|
||||||
import dev.inmo.tgbotapi.types.files.*
|
import dev.inmo.tgbotapi.types.files.*
|
||||||
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
import dev.inmo.tgbotapi.types.games.RawGame
|
import dev.inmo.tgbotapi.types.games.RawGame
|
||||||
import dev.inmo.tgbotapi.types.location.Location
|
import dev.inmo.tgbotapi.types.location.Location
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||||
|
@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
|
|||||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument
|
import dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.files.Sticker
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.stickers
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.files.PhotoSize
|
import dev.inmo.tgbotapi.types.files.PhotoSize
|
||||||
import dev.inmo.tgbotapi.types.files.Sticker
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@ -16,6 +16,8 @@ data class StickerSet(
|
|||||||
val stickers: List<Sticker>,
|
val stickers: List<Sticker>,
|
||||||
@SerialName(isAnimatedField)
|
@SerialName(isAnimatedField)
|
||||||
val isAnimated: Boolean = false,
|
val isAnimated: Boolean = false,
|
||||||
|
@SerialName(isVideoField)
|
||||||
|
val isVideo: Boolean = false,
|
||||||
@SerialName(containsMasksField)
|
@SerialName(containsMasksField)
|
||||||
val containsMasks: Boolean = false,
|
val containsMasks: Boolean = false,
|
||||||
@SerialName(thumbField)
|
@SerialName(thumbField)
|
||||||
|
@ -31,6 +31,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.extended.*
|
|||||||
import dev.inmo.tgbotapi.types.dice.*
|
import dev.inmo.tgbotapi.types.dice.*
|
||||||
import dev.inmo.tgbotapi.types.files.*
|
import dev.inmo.tgbotapi.types.files.*
|
||||||
import dev.inmo.tgbotapi.types.files.abstracts.*
|
import dev.inmo.tgbotapi.types.files.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
import dev.inmo.tgbotapi.types.location.*
|
import dev.inmo.tgbotapi.types.location.*
|
||||||
import dev.inmo.tgbotapi.types.message.*
|
import dev.inmo.tgbotapi.types.message.*
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||||
|
@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
|||||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||||
import dev.inmo.tgbotapi.types.dice.Dice
|
import dev.inmo.tgbotapi.types.dice.Dice
|
||||||
import dev.inmo.tgbotapi.types.files.*
|
import dev.inmo.tgbotapi.types.files.*
|
||||||
|
import dev.inmo.tgbotapi.types.files.sticker.Sticker
|
||||||
import dev.inmo.tgbotapi.types.games.Game
|
import dev.inmo.tgbotapi.types.games.Game
|
||||||
import dev.inmo.tgbotapi.types.location.Location
|
import dev.inmo.tgbotapi.types.location.Location
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||||
|
Loading…
Reference in New Issue
Block a user