mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 03:28:44 +00:00
Reused existing code in converters
This commit is contained in:
parent
982b401b28
commit
9fa17c1360
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user