1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-21 15:53:47 +00:00

fixes in send paid media

This commit is contained in:
InsanusMokrassar 2024-07-10 16:53:16 +06:00
parent 6f64ed1032
commit fb1ff6e4fd
4 changed files with 30 additions and 6 deletions

View File

@ -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 <init> (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 <init> (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

View File

@ -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.*

View File

@ -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<MultipartFile> = 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<MultipartFile> = 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

View File

@ -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)