1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00
This commit is contained in:
InsanusMokrassar 2022-04-17 18:15:24 +06:00
parent 721b82f912
commit 643f8e577e
62 changed files with 313 additions and 281 deletions

View File

@ -3,7 +3,9 @@
## 1.0.0
* `Core`:
* Constructor of `UnknownInlineKeyboardButton` is not internal and can be created with any `json`
* Constructor of `UnknownInlineKeyboardButton` is not internal and can be created with any `json` ([#563](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/563))
* All the interfaces from `dev.inmo.tgbotapi.types.files.abstracts` have been replaced to `dev.inmo.tgbotapi.types.files` and converted to sealed ([#550](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/550))
* `PassportFile` has been replaced to `dev.inmo.tgbotapi.types.files`
## 0.38.13

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
import dev.inmo.tgbotapi.requests.DownloadFile
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.files.PathedFile
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
suspend fun TelegramBot.downloadFile(

View File

@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.files.PathedFile
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
suspend fun TelegramBot.downloadFileStream(

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
import dev.inmo.tgbotapi.requests.DownloadFileStream
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.files.PathedFile
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
suspend fun TelegramBot.downloadFileStreamAllocator(

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.requests.get.GetFile
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
suspend fun TelegramBot.getFileAdditionalInfo(

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.get.GetStickerSet
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.Sticker
suspend fun TelegramBot.getStickerSet(
name: String

View File

@ -18,12 +18,11 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import dev.inmo.tgbotapi.types.message.content.media.*
import dev.inmo.tgbotapi.types.payments.LabeledPrice

View File

@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.Sticker
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or

View File

@ -3,7 +3,7 @@ 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.stickers.DeleteStickerFromSet
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.Sticker
suspend fun TelegramBot.deleteStickerFromSet(
sticker: FileId

View File

@ -3,7 +3,7 @@ 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.stickers.SetStickerPositionInSet
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.Sticker
suspend fun TelegramBot.setStickerPositionInSet(
sticker: FileId,

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.files.PathedFile
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import io.ktor.util.cio.use
import io.ktor.util.cio.writeChannel

View File

@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
import dev.inmo.tgbotapi.extensions.utils.whenCommonMessage
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.content.abstracts.*

View File

@ -22,7 +22,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByC
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
import dev.inmo.tgbotapi.extensions.utils.asEditMessageUpdate
import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.content.abstracts.*

View File

@ -2,8 +2,8 @@ package dev.inmo.tgbotapi.requests.get
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.fileIdField
import dev.inmo.tgbotapi.types.files.PathedFile
import dev.inmo.tgbotapi.types.files.abstracts.fileIdField
import kotlinx.serialization.*
@Serializable

View File

@ -189,6 +189,13 @@ const val requestContactField = "request_contact"
const val requestLocationField = "request_location"
const val requestPollField = "request_poll"
const val fileNameField = "file_name"
const val mimeTypeField = "mime_type"
const val fileIdField = "file_id"
const val fileSizeField = "file_size"
const val fileDateField = "file_date"
const val filePathField = "file_path"
const val requestWriteAccessField = "request_write_access"

View File

@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.files.abstracts.mimeTypeField
import dev.inmo.tgbotapi.utils.MimeType
import dev.inmo.tgbotapi.utils.extensions.makeString
import kotlinx.serialization.SerialName

View File

@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.files.abstracts.mimeTypeField
import dev.inmo.tgbotapi.utils.MimeType
import dev.inmo.tgbotapi.utils.extensions.makeString
import kotlinx.serialization.SerialName

View File

@ -1,9 +1,8 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.utils.MimeType
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.CommonAbstracts.Performerable
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.utils.MimeType
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.types.files
sealed interface CustomNamedMediaFile {
val fileName: String?
}

View File

@ -1,10 +1,8 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.types.message.content.media.DocumentContent
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.utils.MimeType
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -1,9 +1,8 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -0,0 +1,6 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.CommonAbstracts.MimeTyped
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
sealed interface MimedMediaFile : TelegramMediaFile, MimeTyped

View File

@ -0,0 +1,22 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format
* when decrypted and don't exceed 10MB.
*/
@Serializable
data class PassportFile(
@SerialName(fileIdField)
override val fileId: FileId,
@SerialName(fileUniqueIdField)
override val fileUniqueId: FileUniqueId,
@SerialName(fileDateField)
val uploadingDate: TelegramDate,
@SerialName(fileSizeField)
override val fileSize: Long? = null
) : TelegramMediaFile

View File

@ -1,9 +1,7 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.*
import kotlinx.serialization.*

View File

@ -1,9 +1,8 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer

View File

@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
sealed interface PlayableMediaFile : TelegramMediaFile {
val duration: Long?
}

View File

@ -0,0 +1,8 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
sealed interface SizedMediaFile : TelegramMediaFile {
val width: Int
val height: Int
}

View File

@ -1,6 +1,156 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.*
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
@Deprecated("Replaced", ReplaceWith("Sticker", "dev.inmo.tgbotapi.types.files.sticker.Sticker"))
typealias Sticker = Sticker
@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

View File

@ -1,17 +1,12 @@
package dev.inmo.tgbotapi.types.files.abstracts
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
internal const val fileIdField = "file_id"
internal const val fileSizeField = "file_size"
internal const val fileDateField = "file_date"
internal const val filePathField = "file_path"
/**
* Declare common part of media files in Telegram. Note: it is not representation of JVM `File` type
*/
interface TelegramMediaFile {
sealed interface TelegramMediaFile {
val fileId: FileId
val fileUniqueId: FileUniqueId
val fileSize: Long?

View File

@ -0,0 +1,8 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.types.files.PhotoSize
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
sealed interface ThumbedMediaFile : TelegramMediaFile {
val thumb: PhotoSize?
}

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.types.files
sealed interface TitledMediaFile {
val title: String?
}

View File

@ -5,7 +5,6 @@ import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.utils.MimeType
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -1,9 +1,8 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.utils.MimeType
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.types.files.abstracts
internal const val fileNameField = "file_name"
interface CustomNamedMediaFile {
val fileName: String?
}

View File

@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.types.files.abstracts
import dev.inmo.tgbotapi.CommonAbstracts.MimeTyped
internal const val mimeTypeField = "mime_type"
interface MimedMediaFile : TelegramMediaFile, MimeTyped

View File

@ -0,0 +1,22 @@
package dev.inmo.tgbotapi.types.files.abstracts
@Deprecated("Renamed", ReplaceWith("CustomNamedMediaFile", "dev.inmo.tgbotapi.types.files.CustomNamedMediaFile"))
typealias CustomNamedMediaFile = dev.inmo.tgbotapi.types.files.CustomNamedMediaFile
@Deprecated("Replaced", ReplaceWith("MimedMediaFile", "dev.inmo.tgbotapi.types.files.MimedMediaFile"))
typealias MimedMediaFile = dev.inmo.tgbotapi.types.files.MimedMediaFile
@Deprecated("Replaced", ReplaceWith("PlayableMediaFile", "dev.inmo.tgbotapi.types.files.PlayableMediaFile"))
typealias PlayableMediaFile = dev.inmo.tgbotapi.types.files.PlayableMediaFile
@Deprecated("Replaced", ReplaceWith("SizedMediaFile", "dev.inmo.tgbotapi.types.files.SizedMediaFile"))
typealias SizedMediaFile = dev.inmo.tgbotapi.types.files.SizedMediaFile
@Deprecated("Replaced", ReplaceWith("TelegramMediaFile", "dev.inmo.tgbotapi.types.files.TelegramMediaFile"))
typealias TelegramMediaFile = dev.inmo.tgbotapi.types.files.TelegramMediaFile
@Deprecated("Replaced", ReplaceWith("ThumbedMediaFile", "dev.inmo.tgbotapi.types.files.ThumbedMediaFile"))
typealias ThumbedMediaFile = dev.inmo.tgbotapi.types.files.ThumbedMediaFile
@Deprecated("Replaced", ReplaceWith("TitledMediaFile", "dev.inmo.tgbotapi.types.files.TitledMediaFile"))
typealias TitledMediaFile = dev.inmo.tgbotapi.types.files.TitledMediaFile

View File

@ -1,5 +0,0 @@
package dev.inmo.tgbotapi.types.files.abstracts
interface PlayableMediaFile : TelegramMediaFile {
val duration: Long?
}

View File

@ -1,6 +0,0 @@
package dev.inmo.tgbotapi.types.files.abstracts
interface SizedMediaFile : TelegramMediaFile {
val width: Int
val height: Int
}

View File

@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.types.files.abstracts
import dev.inmo.tgbotapi.types.files.PhotoSize
interface ThumbedMediaFile : TelegramMediaFile {
val thumb: PhotoSize?
}

View File

@ -1,5 +0,0 @@
package dev.inmo.tgbotapi.types.files.abstracts
interface TitledMediaFile {
val title: String?
}

View File

@ -1,158 +1,19 @@
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
@Deprecated("Replaced", ReplaceWith("StickerSurrogate", "dev.inmo.tgbotapi.types.files.StickerSurrogate"))
typealias StickerSurrogate = dev.inmo.tgbotapi.types.files.StickerSurrogate
@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
)
@Deprecated("Replaced", ReplaceWith("Sticker", "dev.inmo.tgbotapi.types.files.Sticker"))
typealias Sticker = dev.inmo.tgbotapi.types.files.Sticker
// TODO:: Serializer
@Serializable(StickerSerializer::class)
sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile {
val emoji: String?
val maskPosition: MaskPosition?
val stickerSetName: StickerSetName?
@Deprecated("Replaced", ReplaceWith("StickerSerializer", "dev.inmo.tgbotapi.types.files.StickerSerializer"))
typealias StickerSerializer = dev.inmo.tgbotapi.types.files.StickerSerializer
val isAnimated
get() = this is AnimatedSticker
val isVideo
get() = this is VideoSticker
@Deprecated("Replaced", ReplaceWith("SimpleSticker", "dev.inmo.tgbotapi.types.files.SimpleSticker"))
typealias SimpleSticker = dev.inmo.tgbotapi.types.files.SimpleSticker
companion object {
fun serializer(): KSerializer<Sticker> = StickerSerializer
}
}
@Deprecated("Replaced", ReplaceWith("AnimatedSticker", "dev.inmo.tgbotapi.types.files.AnimatedSticker"))
typealias AnimatedSticker = dev.inmo.tgbotapi.types.files.AnimatedSticker
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
@Deprecated("Replaced", ReplaceWith("VideoSticker", "dev.inmo.tgbotapi.types.files.VideoSticker"))
typealias VideoSticker = dev.inmo.tgbotapi.types.files.VideoSticker

View File

@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.abstracts.*
import dev.inmo.tgbotapi.types.dice.Dice
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.games.RawGame
import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.message.ChatEvents.*

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.message.content.abstracts
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
interface MediaCollectionContent<T: TelegramMediaFile>: MessageContent, MediaContent {
val mediaCollection: List<T>

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.message.content.abstracts
import dev.inmo.tgbotapi.types.InputMedia.InputMedia
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
interface MediaContent: MessageContent {
val media: TelegramMediaFile

View File

@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument
import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import kotlinx.serialization.Serializable

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.passport.encrypted
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.PassportFile
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.passport.encrypted
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.PassportFile
import dev.inmo.tgbotapi.types.passport.credentials.EncryptedData
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
import kotlinx.serialization.SerialName

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.passport.encrypted
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.PassportFile
import dev.inmo.tgbotapi.types.passport.credentials.EncryptedData
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
import kotlinx.serialization.SerialName

View File

@ -1,23 +1,4 @@
package dev.inmo.tgbotapi.types.passport.encrypted
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.abstracts.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format
* when decrypted and don't exceed 10MB.
*/
@Serializable
data class PassportFile(
@SerialName(fileIdField)
override val fileId: FileId,
@SerialName(fileUniqueIdField)
override val fileUniqueId: FileUniqueId,
@SerialName(fileDateField)
val uploadingDate: TelegramDate,
@SerialName(fileSizeField)
override val fileSize: Long? = null
) : TelegramMediaFile
@Deprecated("Replaced", ReplaceWith("PassportFile", "dev.inmo.tgbotapi.types.files.PassportFile"))
typealias PassportFile = dev.inmo.tgbotapi.types.files.PassportFile

View File

@ -1,10 +1,10 @@
package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
import dev.inmo.tgbotapi.types.passport.encrypted.PassportFile
import dev.inmo.tgbotapi.types.files.PassportFile
import kotlinx.serialization.Serializable
@Serializable(EncryptedElementSerializer::class)
interface EncryptedPassportElementTranslatable : EncryptedPassportElement {
val translations: List<PassportFile>
}
}

View File

@ -1,10 +1,10 @@
package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
import dev.inmo.tgbotapi.types.passport.encrypted.PassportFile
import dev.inmo.tgbotapi.types.files.PassportFile
import kotlinx.serialization.Serializable
@Serializable(EncryptedElementSerializer::class)
interface EncryptedPassportElementWithFilesCollection : EncryptedPassportElement {
val files: List<PassportFile>
}
}

View File

@ -1,10 +1,10 @@
package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
import dev.inmo.tgbotapi.types.passport.encrypted.PassportFile
import dev.inmo.tgbotapi.types.files.PassportFile
import kotlinx.serialization.Serializable
@Serializable(EncryptedElementSerializer::class)
interface EncryptedPassportElementWithFrontSide : EncryptedPassportElement {
val frontSide: PassportFile?
}
}

View File

@ -1,10 +1,10 @@
package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
import dev.inmo.tgbotapi.types.passport.encrypted.PassportFile
import dev.inmo.tgbotapi.types.files.PassportFile
import kotlinx.serialization.Serializable
@Serializable(EncryptedElementSerializer::class)
interface EncryptedPassportElementWithReverseSide : EncryptedPassportElement {
val reverseSide: PassportFile?
}
}

View File

@ -1,10 +1,10 @@
package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
import dev.inmo.tgbotapi.types.passport.encrypted.PassportFile
import dev.inmo.tgbotapi.types.files.PassportFile
import kotlinx.serialization.Serializable
@Serializable(EncryptedElementSerializer::class)
interface EncryptedPassportElementWithSelfie : EncryptedPassportElement {
val selfie: PassportFile?
}
}

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.stickers
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.PhotoSize
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.Sticker
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.DownloadFile
import dev.inmo.tgbotapi.requests.get.GetFile
import dev.inmo.tgbotapi.types.passport.credentials.*
import dev.inmo.tgbotapi.types.passport.encrypted.PassportFile
import dev.inmo.tgbotapi.types.files.PassportFile
fun EndDataCredentials.decryptData(
bytes: EncryptedData

View File

@ -30,9 +30,9 @@ import dev.inmo.tgbotapi.types.chat.abstracts.*
import dev.inmo.tgbotapi.types.chat.abstracts.extended.*
import dev.inmo.tgbotapi.types.dice.*
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.types.files.sticker.*
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.types.message.ChatEvents.*

View File

@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.dice.Dice
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.message.ChatEvents.*

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.extensions.raw
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.sticker.*
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.stickers.MaskPosition
inline val Sticker.file_id: FileId

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.DownloadFileStream
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.requests.get.GetFile
import dev.inmo.tgbotapi.types.files.PathedFile
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import dev.inmo.tgbotapi.utils.*