mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-08 09:23:47 +00:00
fixes in send paid media
This commit is contained in:
parent
6f64ed1032
commit
fb1ff6e4fd
@ -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
|
||||
|
@ -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.*
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user