From 05341be534369d58cc1a48b2c74f8ae91793ad51 Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 15:33:14 +0300 Subject: [PATCH 1/8] Implemented paid media reply extension --- .../api/send/RepliesWithChatsAndMessages.kt | 43 +++++++++++++++++++ .../payments/PaidMediaToTelegramPaidMedia.kt | 25 +++++++++++ 2 files changed, 68 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt 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 78a5205637..af5874b388 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 @@ -26,6 +26,9 @@ import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.* +import dev.inmo.tgbotapi.types.message.payments.PaidMedia +import dev.inmo.tgbotapi.types.message.payments.toTelegramMediaPhoto +import dev.inmo.tgbotapi.types.message.payments.toTelegramPaidMediaVideo import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.polls.* @@ -2045,3 +2048,43 @@ suspend fun TelegramBot.reply( ) } } + +suspend fun TelegramBot.reply( + toChatId: IdChatIdentifier, + toMessageId: MessageId, + content: PaidMediaInfoContent, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, + replyInBusinessConnectionId: BusinessConnectionId? = replyInChatId.businessConnectionId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + parseMode: ParseMode? = null, + replyMarkup: KeyboardMarkup? = null +) { + val media = content.paidMediaInfo.media.mapNotNull { + when (it) { + is PaidMedia.Video -> it.toTelegramPaidMediaVideo() + is PaidMedia.Photo -> it.toTelegramMediaPhoto() + is PaidMedia.Preview, is PaidMedia.Unknown -> null + } + } + sendPaidMedia( + chatId = replyInChatId, + starCount = content.paidMediaInfo.stars, + media = media, + text = content.text, + parseMode = parseMode, + showCaptionAboveMedia = content.showCaptionAboveMedia, + threadId = replyInThreadId, + businessConnectionId = replyInBusinessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyMarkup = replyMarkup, + replyParameters = ReplyParameters( + messageId = toMessageId, + chatIdentifier = toChatId, + allowSendingWithoutReply = allowSendingWithoutReply + ) + ) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt new file mode 100644 index 0000000000..84be904eb6 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt @@ -0,0 +1,25 @@ +package dev.inmo.tgbotapi.types.message.payments + +import dev.inmo.tgbotapi.types.media.TelegramMediaPhoto +import dev.inmo.tgbotapi.types.media.TelegramPaidMedia +import dev.inmo.tgbotapi.types.media.TelegramPaidMediaPhoto +import dev.inmo.tgbotapi.types.media.TelegramPaidMediaVideo + +fun PaidMedia.toTelegramPaidMedia(): TelegramPaidMedia? = when (this) { + is PaidMedia.Photo -> TelegramPaidMediaPhoto( + file = this.photo.biggest.fileId + ) + is PaidMedia.Video -> TelegramPaidMediaPhoto( + file = this.video.fileId + ) + is PaidMedia.Preview, is PaidMedia.Unknown -> null +} + +fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = TelegramPaidMediaVideo( + file = this.video.fileId, + duration = this.video.duration + ) + +fun PaidMedia.Photo.toTelegramMediaPhoto(): TelegramPaidMediaPhoto = TelegramPaidMediaPhoto( + file = this.photo.fileId +) From f89849218ad0922764ff045c42166ce64bb6aae6 Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 16:39:52 +0300 Subject: [PATCH 2/8] Added `to: AccessibleMessage` overload --- .../api/send/RepliesWithChatsAndMessages.kt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) 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 af5874b388..8284cc65ec 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 @@ -2049,6 +2049,45 @@ suspend fun TelegramBot.reply( } } +suspend fun TelegramBot.reply( + to: AccessibleMessage, + content: PaidMediaInfoContent, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, + replyInBusinessConnectionId: BusinessConnectionId? = replyInChatId.businessConnectionId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + parseMode: ParseMode? = null, + replyMarkup: KeyboardMarkup? = null +) { + val media = content.paidMediaInfo.media.mapNotNull { + when (it) { + is PaidMedia.Video -> it.toTelegramPaidMediaVideo() + is PaidMedia.Photo -> it.toTelegramMediaPhoto() + is PaidMedia.Preview, is PaidMedia.Unknown -> null + } + } + sendPaidMedia( + chatId = replyInChatId, + starCount = content.paidMediaInfo.stars, + media = media, + text = content.text, + parseMode = parseMode, + showCaptionAboveMedia = content.showCaptionAboveMedia, + threadId = replyInThreadId, + businessConnectionId = replyInBusinessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyMarkup = replyMarkup, + replyParameters = ReplyParameters( + messageId = to.messageId, + chatIdentifier = to.chat.id, + allowSendingWithoutReply = allowSendingWithoutReply + ) + ) +} + suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, @@ -2088,3 +2127,4 @@ suspend fun TelegramBot.reply( ) ) } + From 613f6de483342c9927e9e7677471ab822ffa7d23 Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 16:53:18 +0300 Subject: [PATCH 3/8] Renamed extension function to reflect its functionality --- .../types/message/payments/PaidMediaToTelegramPaidMedia.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt index 84be904eb6..df1cd4d90a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt @@ -1,11 +1,10 @@ package dev.inmo.tgbotapi.types.message.payments -import dev.inmo.tgbotapi.types.media.TelegramMediaPhoto import dev.inmo.tgbotapi.types.media.TelegramPaidMedia import dev.inmo.tgbotapi.types.media.TelegramPaidMediaPhoto import dev.inmo.tgbotapi.types.media.TelegramPaidMediaVideo -fun PaidMedia.toTelegramPaidMedia(): TelegramPaidMedia? = when (this) { +fun PaidMedia.toTelegramPaidMediaOrNull(): TelegramPaidMedia? = when (this) { is PaidMedia.Photo -> TelegramPaidMediaPhoto( file = this.photo.biggest.fileId ) From 32db4a19d2a372ff737fdb863618b8ededf2683d Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 16:54:26 +0300 Subject: [PATCH 4/8] Moved to-overload to intended place --- .../tgbotapi/extensions/api/send/Replies.kt | 32 +++++++++++++++ .../api/send/RepliesWithChatsAndMessages.kt | 39 ------------------- 2 files changed, 32 insertions(+), 39 deletions(-) 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 fc3b589fdb..8d460942c9 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 @@ -2234,3 +2234,35 @@ suspend fun TelegramBot.reply( ) } } + +suspend fun TelegramBot.reply( + to: AccessibleMessage, + starCount: Int, + media: List, + entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, + threadId: MessageThreadId? = to.chat.id.threadId, + businessConnectionId: BusinessConnectionId? = to.chat.id.businessConnectionId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) { + sendPaidMedia( + chatId = to.chat.id, + starCount = starCount, + media = media, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyMarkup = replyMarkup, + replyParameters = ReplyParameters( + messageId = to.messageId, + chatIdentifier = to.chat.id, + allowSendingWithoutReply = allowSendingWithoutReply + ) + ) +} \ No newline at end of file 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 8284cc65ec..5b8dc824e2 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 @@ -2049,45 +2049,6 @@ suspend fun TelegramBot.reply( } } -suspend fun TelegramBot.reply( - to: AccessibleMessage, - content: PaidMediaInfoContent, - replyInChatId: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChatId.threadId, - replyInBusinessConnectionId: BusinessConnectionId? = replyInChatId.businessConnectionId, - disableNotification: Boolean = false, - protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - parseMode: ParseMode? = null, - replyMarkup: KeyboardMarkup? = null -) { - val media = content.paidMediaInfo.media.mapNotNull { - when (it) { - is PaidMedia.Video -> it.toTelegramPaidMediaVideo() - is PaidMedia.Photo -> it.toTelegramMediaPhoto() - is PaidMedia.Preview, is PaidMedia.Unknown -> null - } - } - sendPaidMedia( - chatId = replyInChatId, - starCount = content.paidMediaInfo.stars, - media = media, - text = content.text, - parseMode = parseMode, - showCaptionAboveMedia = content.showCaptionAboveMedia, - threadId = replyInThreadId, - businessConnectionId = replyInBusinessConnectionId, - disableNotification = disableNotification, - protectContent = protectContent, - replyMarkup = replyMarkup, - replyParameters = ReplyParameters( - messageId = to.messageId, - chatIdentifier = to.chat.id, - allowSendingWithoutReply = allowSendingWithoutReply - ) - ) -} - suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, From f2fae9184f2bbab5e5fa55044b6eb28d08976b1c Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 16:55:24 +0300 Subject: [PATCH 5/8] Fixed wrongly specified parameters --- .../api/send/RepliesWithChatsAndMessages.kt | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) 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 5b8dc824e2..05cabac9f6 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 @@ -2052,32 +2052,25 @@ suspend fun TelegramBot.reply( suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, - content: PaidMediaInfoContent, - replyInChatId: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChatId.threadId, - replyInBusinessConnectionId: BusinessConnectionId? = replyInChatId.businessConnectionId, + starCount: Int, + media: List, + entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, + threadId: MessageThreadId? = toChatId.threadId, + businessConnectionId: BusinessConnectionId? = toChatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, - parseMode: ParseMode? = null, replyMarkup: KeyboardMarkup? = null ) { - val media = content.paidMediaInfo.media.mapNotNull { - when (it) { - is PaidMedia.Video -> it.toTelegramPaidMediaVideo() - is PaidMedia.Photo -> it.toTelegramMediaPhoto() - is PaidMedia.Preview, is PaidMedia.Unknown -> null - } - } sendPaidMedia( - chatId = replyInChatId, - starCount = content.paidMediaInfo.stars, + chatId = toChatId, + starCount = starCount, media = media, - text = content.text, - parseMode = parseMode, - showCaptionAboveMedia = content.showCaptionAboveMedia, - threadId = replyInThreadId, - businessConnectionId = replyInBusinessConnectionId, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + threadId = threadId, + businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, replyMarkup = replyMarkup, @@ -2088,4 +2081,3 @@ suspend fun TelegramBot.reply( ) ) } - From 26b864a314cd457328c701600570f882e67eba02 Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 18:31:08 +0300 Subject: [PATCH 6/8] updated PaidMedia.Video.toTelegramPaidMediaVideo() converter function --- .../types/message/payments/PaidMediaToTelegramPaidMedia.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt index df1cd4d90a..f9222f6af9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt @@ -16,7 +16,10 @@ fun PaidMedia.toTelegramPaidMediaOrNull(): TelegramPaidMedia? = when (this) { fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = TelegramPaidMediaVideo( file = this.video.fileId, - duration = this.video.duration + duration = this.video.duration, + width = this.video.width, + height = this.video.height, + thumb = this.video.thumbnail?.fileId ) fun PaidMedia.Photo.toTelegramMediaPhoto(): TelegramPaidMediaPhoto = TelegramPaidMediaPhoto( From 982b401b28578d858a0a314e82c73cbd2e70b856 Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 18:34:43 +0300 Subject: [PATCH 7/8] Added overloads with text and custom parsing mode instead of entities --- .../tgbotapi/extensions/api/send/Replies.kt | 34 ++++++++++++++++++ .../api/send/RepliesWithChatsAndMessages.kt | 35 +++++++++++++++++++ 2 files changed, 69 insertions(+) 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 8d460942c9..a35f8bbeff 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 @@ -2265,4 +2265,38 @@ suspend fun TelegramBot.reply( allowSendingWithoutReply = allowSendingWithoutReply ) ) +} + +suspend fun TelegramBot.reply( + to: AccessibleMessage, + starCount: Int, + media: List, + text: String? = null, + parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, + threadId: MessageThreadId? = to.chat.id.threadId, + businessConnectionId: BusinessConnectionId? = to.chat.id.businessConnectionId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) { + sendPaidMedia( + chatId = to.chat.id, + starCount = starCount, + media = media, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyMarkup = replyMarkup, + replyParameters = ReplyParameters( + messageId = to.messageId, + chatIdentifier = to.chat.id, + allowSendingWithoutReply = allowSendingWithoutReply + ) + ) } \ No newline at end of file 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 05cabac9f6..b2b17673eb 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 @@ -2081,3 +2081,38 @@ suspend fun TelegramBot.reply( ) ) } + +suspend fun TelegramBot.reply( + toChatId: IdChatIdentifier, + toMessageId: MessageId, + starCount: Int, + media: List, + text: String? = null, + parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, + threadId: MessageThreadId? = toChatId.threadId, + businessConnectionId: BusinessConnectionId? = toChatId.businessConnectionId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) { + sendPaidMedia( + chatId = toChatId, + starCount = starCount, + media = media, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyMarkup = replyMarkup, + replyParameters = ReplyParameters( + messageId = toMessageId, + chatIdentifier = toChatId, + allowSendingWithoutReply = allowSendingWithoutReply + ) + ) +} From 9fa17c1360d020e0e4fcade68a9f291beeac4eb3 Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 18:54:30 +0300 Subject: [PATCH 8/8] Reused existing code in converters --- .../payments/PaidMediaToTelegramPaidMedia.kt | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt index f9222f6af9..fe35555b2f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/PaidMediaToTelegramPaidMedia.kt @@ -1,27 +1,13 @@ package dev.inmo.tgbotapi.types.message.payments -import dev.inmo.tgbotapi.types.media.TelegramPaidMedia -import dev.inmo.tgbotapi.types.media.TelegramPaidMediaPhoto -import dev.inmo.tgbotapi.types.media.TelegramPaidMediaVideo +import dev.inmo.tgbotapi.types.media.* fun PaidMedia.toTelegramPaidMediaOrNull(): TelegramPaidMedia? = when (this) { - is PaidMedia.Photo -> TelegramPaidMediaPhoto( - file = this.photo.biggest.fileId - ) - is PaidMedia.Video -> TelegramPaidMediaPhoto( - file = this.video.fileId - ) + is PaidMedia.Photo -> toTelegramMediaPhoto() + is PaidMedia.Video -> toTelegramPaidMediaVideo() is PaidMedia.Preview, is PaidMedia.Unknown -> null } -fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = TelegramPaidMediaVideo( - file = this.video.fileId, - duration = this.video.duration, - width = this.video.width, - height = this.video.height, - thumb = this.video.thumbnail?.fileId - ) +fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = this.video.toTelegramPaidMediaVideo() -fun PaidMedia.Photo.toTelegramMediaPhoto(): TelegramPaidMediaPhoto = TelegramPaidMediaPhoto( - file = this.photo.fileId -) +fun PaidMedia.Photo.toTelegramMediaPhoto(): TelegramPaidMediaPhoto = this.photo.biggest.toTelegramPaidMediaPhoto()