diff --git a/tgbotapi.core/api/tgbotapi.core.api b/tgbotapi.core/api/tgbotapi.core.api index 0db680840d..37fff023f2 100644 --- a/tgbotapi.core/api/tgbotapi.core.api +++ b/tgbotapi.core/api/tgbotapi.core.api @@ -18203,7 +18203,7 @@ public final class dev/inmo/tgbotapi/types/media/TelegramPaidMediaPhotoKt { public static final fun toTelegramPaidMediaPhoto (Ldev/inmo/tgbotapi/types/files/PhotoSize;)Ldev/inmo/tgbotapi/types/media/TelegramPaidMediaPhoto; } -public final class dev/inmo/tgbotapi/types/media/TelegramPaidMediaVideo : dev/inmo/tgbotapi/types/media/DuratedTelegramMedia, dev/inmo/tgbotapi/types/media/SizedTelegramMedia, dev/inmo/tgbotapi/types/media/TelegramPaidMedia, dev/inmo/tgbotapi/types/media/ThumbedTelegramMedia, dev/inmo/tgbotapi/types/media/VisualTelegramPaidMedia { +public final class dev/inmo/tgbotapi/types/media/TelegramPaidMediaVideo : dev/inmo/tgbotapi/types/media/DuratedTelegramMedia, dev/inmo/tgbotapi/types/media/SizedTelegramMedia, dev/inmo/tgbotapi/types/media/ThumbedTelegramMedia, dev/inmo/tgbotapi/types/media/VisualTelegramPaidMedia { public static final field Companion Ldev/inmo/tgbotapi/types/media/TelegramPaidMediaVideo$Companion; public fun (Ldev/inmo/tgbotapi/requests/abstracts/InputFile;Ldev/inmo/tgbotapi/requests/abstracts/InputFile;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Long;Z)V public synthetic fun (Ldev/inmo/tgbotapi/requests/abstracts/InputFile;Ldev/inmo/tgbotapi/requests/abstracts/InputFile;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Long;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory.kt index 9a633f38a5..ee90d69256 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory.kt @@ -15,6 +15,7 @@ import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import io.ktor.client.HttpClient import io.ktor.client.plugins.timeout import io.ktor.client.request.* +import io.ktor.client.request.forms.* import io.ktor.client.statement.bodyAsText import io.ktor.http.ContentType import io.ktor.http.content.* diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPaidMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPaidMedia.kt index 13582dd3d4..6933fcda9a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPaidMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPaidMedia.kt @@ -12,6 +12,7 @@ import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia import dev.inmo.tgbotapi.types.message.* import dev.inmo.tgbotapi.types.message.RawMessageEntity import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -51,10 +52,21 @@ fun SendPaidMedia( replyMarkup = replyMarkup ) - return if (media.any { it.file is MultipartFile }) { + val files: List = media.flatMap { + listOfNotNull( + it.file as? MultipartFile, + if (it is ThumbedTelegramMedia) { + it.thumb as? MultipartFile + } else { + null + } + ) + } + + return if (files.isNotEmpty()) { CommonMultipartFileRequest( data, - media.mapNotNull { it.media to (it.file as? MultipartFile ?: return@mapNotNull null) }.toMap() + files.associateBy { it.fileId } ) } else { data @@ -90,10 +102,21 @@ fun SendPaidMedia( replyMarkup = replyMarkup ) - return if (media.any { it.file is MultipartFile }) { + val files: List = media.flatMap { + listOfNotNull( + it.file as? MultipartFile, + if (it is ThumbedTelegramMedia) { + it.thumb as? MultipartFile + } else { + null + } + ) + } + + return if (files.isNotEmpty()) { CommonMultipartFileRequest( data, - media.mapNotNull { it.media to (it.file as? MultipartFile ?: return@mapNotNull null) }.toMap() + files.associateBy { it.fileId } ) } else { data 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 4968f9b21e..01c6f73a12 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 @@ -18,7 +18,7 @@ data class TelegramPaidMediaVideo ( override val duration: Long? = null, @SerialName(supportsStreamingField) val supportsStreaming: Boolean = false, -) : TelegramPaidMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, VisualTelegramPaidMedia { +) : VisualTelegramPaidMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia { override val type: String = videoTelegramPaidMediaType @SerialName(mediaField)