diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 0142e95a6b..fc3b589fdb 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -855,7 +855,7 @@ suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.reply( to: AccessibleMessage, - photo: Photo, + photo: PhotoFile, text: String? = null, parseMode: ParseMode? = null, showCaptionAboveMedia: Boolean = false, @@ -947,7 +947,7 @@ suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.reply( to: AccessibleMessage, - photo: Photo, + photo: PhotoFile, entities: TextSourcesList, showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 5ebd5a5175..78a5205637 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -806,7 +806,7 @@ suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, - photo: Photo, + photo: PhotoFile, text: String? = null, parseMode: ParseMode? = null, showCaptionAboveMedia: Boolean = false, @@ -860,7 +860,7 @@ suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, - photo: Photo, + photo: PhotoFile, entities: TextSourcesList, showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt index 07ce2f0508..e5a98f7791 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt @@ -726,7 +726,7 @@ suspend fun TelegramBot.send( */ suspend fun TelegramBot.send( chatId: ChatIdentifier, - photo: Photo, + photo: PhotoFile, text: String? = null, parseMode: ParseMode? = null, showCaptionAboveMedia: Boolean = false, @@ -747,7 +747,7 @@ suspend fun TelegramBot.send( */ suspend fun TelegramBot.send( chat: Chat, - photo: Photo, + photo: PhotoFile, text: String? = null, parseMode: ParseMode? = null, showCaptionAboveMedia: Boolean = false, @@ -810,7 +810,7 @@ suspend fun TelegramBot.send( */ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, - photo: Photo, + photo: PhotoFile, entities: TextSourcesList, showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, @@ -830,7 +830,7 @@ suspend inline fun TelegramBot.send( */ suspend inline fun TelegramBot.send( chat: Chat, - photo: Photo, + photo: PhotoFile, entities: TextSourcesList, showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt index 944d47c7ce..b86be33f9e 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt @@ -87,7 +87,7 @@ suspend fun TelegramBot.sendPhoto( */ suspend fun TelegramBot.sendPhoto( chatId: ChatIdentifier, - photo: Photo, + photo: PhotoFile, text: String? = null, parseMode: ParseMode? = null, showCaptionAboveMedia: Boolean = false, @@ -121,7 +121,7 @@ suspend fun TelegramBot.sendPhoto( */ suspend fun TelegramBot.sendPhoto( chat: Chat, - photo: Photo, + photo: PhotoFile, text: String? = null, parseMode: ParseMode? = null, showCaptionAboveMedia: Boolean = false, @@ -290,7 +290,7 @@ suspend inline fun TelegramBot.sendPhoto( */ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, - photo: Photo, + photo: PhotoFile, entities: TextSourcesList, showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, @@ -322,7 +322,7 @@ suspend inline fun TelegramBot.sendPhoto( */ suspend inline fun TelegramBot.sendPhoto( chat: Chat, - photo: Photo, + photo: PhotoFile, entities: TextSourcesList, showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 6fa5e357b5..98b33a2611 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -606,6 +606,8 @@ const val additionalChatCountField = "additional_chat_count" const val unclaimedPrizeCountField = "unclaimed_prize_count" const val wasRefundedField = "was_refunded" const val isManualField = "is_manual" +const val starCountField = "star_count" +const val paidMediaField = "paid_media" const val businessConnectionIdField = "business_connection_id" const val businessIntroField = "business_intro" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt index 445749a753..fbef4dbbd8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt @@ -92,7 +92,7 @@ sealed interface ReplyInfo { private val animation: AnimationFile? = null, private val game: RawGame? = null, @Serializable(PhotoSerializer::class) - private val photo: Photo? = null, + private val photo: PhotoFile? = null, private val sticker: Sticker? = null, private val video: VideoFile? = null, private val voice: VoiceFile? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UserProfilePhotos.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UserProfilePhotos.kt index 2b677b27e7..bce5e91391 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UserProfilePhotos.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UserProfilePhotos.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types -import dev.inmo.tgbotapi.types.files.Photo +import dev.inmo.tgbotapi.types.files.PhotoFile import dev.inmo.tgbotapi.types.files.PhotoSerializer import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* @@ -11,10 +11,10 @@ data class UserProfilePhotos ( @SerialName("total_count") val count: Int, @Serializable(UserProfilePhotosPhotosSerializer::class) - val photos: List + val photos: List ) @RiskFeature -object UserProfilePhotosPhotosSerializer : KSerializer> by ListSerializer( +object UserProfilePhotosPhotosSerializer : KSerializer> by ListSerializer( PhotoSerializer ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PaidMediaInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PaidMediaInfo.kt new file mode 100644 index 0000000000..87b7a92117 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PaidMediaInfo.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.types.files + +import dev.inmo.tgbotapi.types.message.payments.PaidMedia +import dev.inmo.tgbotapi.types.paidMediaField +import dev.inmo.tgbotapi.types.starCountField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class PaidMediaInfo( + @SerialName(starCountField) + val stars: Int, + @SerialName(paidMediaField) + val media: List +) \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt index 3fe521be27..e6ec6e806c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt @@ -8,7 +8,7 @@ import kotlin.jvm.JvmInline @Serializable @JvmInline -value class Photo( +value class PhotoFile( val photos: List ) : List by photos, MediaContentVariant, UsefulAsPaidMediaFile { val biggest: PhotoSize @@ -27,12 +27,14 @@ value class Photo( } } -fun Photo.biggest(): PhotoSize? = maxByOrNull { +typealias Photo = PhotoFile + +fun PhotoFile.biggest(): PhotoSize? = maxByOrNull { it.resolution } @RiskFeature -object PhotoSerializer : KSerializer by Photo.serializer() +object PhotoSerializer : KSerializer by PhotoFile.serializer() @Serializable data class PhotoSize( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt index c2e9d15275..4c8bad9a9a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt @@ -5,14 +5,14 @@ import dev.inmo.tgbotapi.abstracts.Titled import dev.inmo.tgbotapi.types.ReplyInfo import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.files.AnimationFile -import dev.inmo.tgbotapi.types.files.Photo +import dev.inmo.tgbotapi.types.files.PhotoFile import kotlinx.serialization.Serializable @Serializable data class Game( override val title: String, val description: String, - val photo: Photo, + val photo: PhotoFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList(), val animation: AnimationFile? = null diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt index 1c676c8aec..28faab99a5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt @@ -14,7 +14,7 @@ internal data class RawGame( private val description: String, @Serializable(PhotoSerializer::class) @SerialName(photoField) - private val photo: Photo, + private val photo: PhotoFile, @SerialName(textField) private val text: String? = null, @SerialName(textEntitiesField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramPaidMediaVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramPaidMediaVideo.kt index 576a7a52b6..bc048dc062 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramPaidMediaVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramPaidMediaVideo.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.files.VideoFile +import dev.inmo.tgbotapi.types.message.payments.PaidMedia import kotlinx.serialization.* internal const val videoTelegramPaidMediaType = "video" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt index 9b89ff7702..83dce481f8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types.message.ChatEvents -import dev.inmo.tgbotapi.types.files.Photo +import dev.inmo.tgbotapi.types.files.PhotoFile import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class NewChatPhoto( - val photo: Photo + val photo: PhotoFile ): PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index d369a13ae3..b2abf991ee 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -71,10 +71,11 @@ internal data class RawMessage( private val story: Story? = null, private val audio: AudioFile? = null, private val document: DocumentFile? = null, + private val paid_media: PaidMediaInfoContent? = null, private val animation: AnimationFile? = null, private val game: RawGame? = null, @Serializable(PhotoSerializer::class) - private val photo: Photo? = null, + private val photo: PhotoFile? = null, private val sticker: Sticker? = null, private val video: VideoFile? = null, private val voice: VoiceFile? = null, @@ -87,7 +88,7 @@ internal data class RawMessage( private val left_chat_member: User? = null, private val new_chat_title: String? = null, @Serializable(PhotoSerializer::class) - private val new_chat_photo: Photo? = null, + private val new_chat_photo: PhotoFile? = null, private val delete_chat_photo: Boolean = false, private val group_chat_created: Boolean = false, private val supergroup_chat_created: Boolean = false, @@ -198,6 +199,12 @@ internal data class RawMessage( adaptedCaptionEntities, quote ) + paid_media != null -> PaidMediaInfoContent( + document, + caption, + adaptedCaptionEntities, + quote + ) voice != null -> VoiceContent( voice, caption, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PaidMediaInfoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PaidMediaInfoContent.kt index fc02655356..95af5e536d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PaidMediaInfoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PaidMediaInfoContent.kt @@ -6,25 +6,27 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.* -import dev.inmo.tgbotapi.types.media.PaidMedia -import dev.inmo.tgbotapi.types.media.TelegramPaidMedia -import dev.inmo.tgbotapi.types.media.toTelegramMediaPhoto +import dev.inmo.tgbotapi.types.files.toTelegramPaidMediaVideo +import dev.inmo.tgbotapi.types.media.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage +import dev.inmo.tgbotapi.types.message.payments.PaidMedia import kotlinx.serialization.Serializable @Serializable data class PaidMediaInfoContent( - override val mediaCollection: List, + val paidMediaInfo: PaidMediaInfo, override val text: String? = null, override val textSources: TextSourcesList = emptyList(), override val quote: TextQuote? = null, override val showCaptionAboveMedia: Boolean = false -) : MediaCollectionContent, TextedMediaContent, WithCustomizedCaptionMediaContent { - override val media: UsefulAsPaidMediaFile - get() = mediaCollection.first() - override fun asTelegramMedia(): TelegramPaidMedia = when (val media = media) { - is VideoFile -> media.toTelegramPaidMediaVideo() - is Photo -> media.biggest.toTelegramMediaPhoto() +) : TextedMediaContent, WithCustomizedCaptionMediaContent { + override val media: TelegramMediaFile + get() = paidMediaInfo.media.fir + override fun asTelegramMedia(): TelegramMediaFile = when (val media = media) { + is PaidMedia.Photo -> media.photo.biggest.toTelegramPaidMediaPhoto() + is PaidMedia.Preview, + is PaidMedia.Unknown -> error("Unable to create telegram media out of $media") + is PaidMedia.Video -> media.video.toTelegramPaidMediaVideo() } override fun createResend( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt index 2a45078ffd..9d8a1da96d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt @@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable @Serializable data class PhotoContent( - override val mediaCollection: Photo, + override val mediaCollection: PhotoFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList(), override val spoilered: Boolean = false, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/PaidMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMedia.kt similarity index 92% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/PaidMedia.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMedia.kt index 0c98d4893b..00a7d69597 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/PaidMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMedia.kt @@ -1,6 +1,8 @@ -package dev.inmo.tgbotapi.types.media +package dev.inmo.tgbotapi.types.message.payments import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.files.PhotoFile +import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.utils.decodeDataAndJson import kotlinx.serialization.EncodeDefault @@ -13,7 +15,9 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.JsonElement @Serializable(PaidMedia.Companion::class) -sealed interface PaidMedia : TelegramMedia { +sealed interface PaidMedia { + val type: String + @Serializable data class Preview( @SerialName(widthField) @@ -35,7 +39,7 @@ sealed interface PaidMedia : TelegramMedia { @Serializable data class Photo( @SerialName(photoField) - val photo: Photo + val photo: PhotoFile ) : PaidMedia { @EncodeDefault @SerialName(typeField) @@ -79,9 +83,9 @@ sealed interface PaidMedia : TelegramMedia { @SerialName(durationField) val duration: Int? = null, @SerialName(photoField) - val photo: Photo? = null, + val photo: PhotoFile? = null, @SerialName(videoField) - val video: Video? = null + val video: VideoFile? = null ) override val descriptor: SerialDescriptor diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/ChatShared.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/ChatShared.kt index 0e793c92c8..354cc8bea9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/ChatShared.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/ChatShared.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.request import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.files.Photo +import dev.inmo.tgbotapi.types.files.PhotoFile import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -16,5 +16,5 @@ data class ChatShared( @SerialName(usernameField) val username: Username? = null, @SerialName(photoField) - val photo: Photo? = null + val photo: PhotoFile? = null ) : ChatSharedRequest diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/SharedUser.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/SharedUser.kt index 08d168cb22..b7b861e3b7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/SharedUser.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/SharedUser.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.request import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.files.Photo +import dev.inmo.tgbotapi.types.files.PhotoFile import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -16,5 +16,5 @@ data class SharedUser( @SerialName(usernameField) val username: Username? = null, @SerialName(photoField) - val photo: Photo? = null, + val photo: PhotoFile? = null, ) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/SimpleInputFilesTest.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/SimpleInputFilesTest.kt index 559317c294..4a7546aa41 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/SimpleInputFilesTest.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/SimpleInputFilesTest.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi import dev.inmo.tgbotapi.requests.abstracts.toInputFile import dev.inmo.tgbotapi.types.TgFileUniqueId -import dev.inmo.tgbotapi.types.files.Photo +import dev.inmo.tgbotapi.types.files.PhotoFile import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramFreeMediaSerializer import dev.inmo.tgbotapi.types.files.PhotoSize import dev.inmo.tgbotapi.types.message.content.PhotoContent @@ -22,7 +22,7 @@ class SimpleInputFilesTest { @Test fun test_that_creating_of_photo_and_converting_to_input_media_working_correctly() { val photoContent = PhotoContent( - Photo( + PhotoFile( listOf( PhotoSize("example_file_id".toInputFile(), TgFileUniqueId("example_unique_file_id"), 100, 100, 100) ) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index ba7dcb4aa8..5815150494 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -193,7 +193,7 @@ import dev.inmo.tgbotapi.types.files.MediaContentVariant import dev.inmo.tgbotapi.types.files.MimedMediaFile import dev.inmo.tgbotapi.types.files.PassportFile import dev.inmo.tgbotapi.types.files.PathedFile -import dev.inmo.tgbotapi.types.files.Photo +import dev.inmo.tgbotapi.types.files.PhotoFile import dev.inmo.tgbotapi.types.files.PhotoSize import dev.inmo.tgbotapi.types.files.PlayableMediaFile import dev.inmo.tgbotapi.types.files.RegularAnimatedSticker @@ -2707,13 +2707,13 @@ public inline fun TelegramMediaFile.pathedFileOrThrow(): PathedFile = this as public inline fun TelegramMediaFile.ifPathedFile(block: (PathedFile) -> T): T? = pathedFileOrNull() ?.let(block) -public inline fun TelegramMediaFile.photoOrNull(): Photo? = this as? - dev.inmo.tgbotapi.types.files.Photo +public inline fun TelegramMediaFile.photoOrNull(): PhotoFile? = this as? + dev.inmo.tgbotapi.types.files.PhotoFile -public inline fun TelegramMediaFile.photoOrThrow(): Photo = this as - dev.inmo.tgbotapi.types.files.Photo +public inline fun TelegramMediaFile.photoOrThrow(): PhotoFile = this as + dev.inmo.tgbotapi.types.files.PhotoFile -public inline fun TelegramMediaFile.ifPhoto(block: (Photo) -> T): T? = photoOrNull() +public inline fun TelegramMediaFile.ifPhoto(block: (PhotoFile) -> T): T? = photoOrNull() ?.let(block) public inline fun TelegramMediaFile.photoSizeOrNull(): PhotoSize? = this as? diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index d8865bc84a..eff8b72812 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -103,7 +103,7 @@ inline val Message.animation: AnimationFile? inline val Message.game: Game? get() = asContentMessage() ?.content ?.asGameContent() ?.game @RiskFeature(RawFieldsUsageWarning) -inline val Message.photo: Photo? +inline val Message.photo: PhotoFile? get() = asContentMessage() ?.content ?.asPhotoContent() ?.mediaCollection @RiskFeature(RawFieldsUsageWarning) inline val Message.sticker: Sticker? @@ -145,7 +145,7 @@ inline val Message.left_chat_member: User? inline val Message.new_chat_title: String? get() = asChatEventMessage() ?.chatEvent ?.asNewChatTitle() ?.title @RiskFeature(RawFieldsUsageWarning) -inline val Message.new_chat_photo: Photo? +inline val Message.new_chat_photo: PhotoFile? get() = asChatEventMessage() ?.chatEvent ?.asNewChatPhoto() ?.photo @RiskFeature(RawFieldsUsageWarning) inline val Message.delete_chat_photo: Boolean