mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +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
|
package dev.inmo.tgbotapi.types.message.payments
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMedia
|
import dev.inmo.tgbotapi.types.media.*
|
||||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMediaPhoto
|
|
||||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMediaVideo
|
|
||||||
|
|
||||||
fun PaidMedia.toTelegramPaidMediaOrNull(): TelegramPaidMedia? = when (this) {
|
fun PaidMedia.toTelegramPaidMediaOrNull(): TelegramPaidMedia? = when (this) {
|
||||||
is PaidMedia.Photo -> TelegramPaidMediaPhoto(
|
is PaidMedia.Photo -> toTelegramMediaPhoto()
|
||||||
file = this.photo.biggest.fileId
|
is PaidMedia.Video -> toTelegramPaidMediaVideo()
|
||||||
)
|
|
||||||
is PaidMedia.Video -> TelegramPaidMediaPhoto(
|
|
||||||
file = this.video.fileId
|
|
||||||
)
|
|
||||||
is PaidMedia.Preview, is PaidMedia.Unknown -> null
|
is PaidMedia.Preview, is PaidMedia.Unknown -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = TelegramPaidMediaVideo(
|
fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = this.video.toTelegramPaidMediaVideo()
|
||||||
file = this.video.fileId,
|
|
||||||
duration = this.video.duration,
|
|
||||||
width = this.video.width,
|
|
||||||
height = this.video.height,
|
|
||||||
thumb = this.video.thumbnail?.fileId
|
|
||||||
)
|
|
||||||
|
|
||||||
fun PaidMedia.Photo.toTelegramMediaPhoto(): TelegramPaidMediaPhoto = TelegramPaidMediaPhoto(
|
fun PaidMedia.Photo.toTelegramMediaPhoto(): TelegramPaidMediaPhoto = this.photo.biggest.toTelegramPaidMediaPhoto()
|
||||||
file = this.photo.fileId
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user