2020-10-04 11:06:30 +00:00
|
|
|
package dev.inmo.tgbotapi.types.InputMedia
|
2018-12-26 08:07:24 +00:00
|
|
|
|
2021-04-28 13:59:30 +00:00
|
|
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
2020-11-05 18:12:14 +00:00
|
|
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
|
|
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
2020-11-05 10:53:26 +00:00
|
|
|
import dev.inmo.tgbotapi.types.*
|
|
|
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
2020-10-04 11:06:30 +00:00
|
|
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
|
|
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
2018-12-26 08:07:24 +00:00
|
|
|
import kotlinx.serialization.*
|
|
|
|
|
2020-05-10 09:26:07 +00:00
|
|
|
internal const val videoInputMediaType = "video"
|
|
|
|
|
2020-11-05 10:53:26 +00:00
|
|
|
fun InputMediaVideo(
|
|
|
|
file: InputFile,
|
|
|
|
text: String? = null,
|
|
|
|
parseMode: ParseMode? = null,
|
|
|
|
width: Int? = null,
|
|
|
|
height: Int? = null,
|
|
|
|
duration: Long? = null,
|
|
|
|
thumb: InputFile? = null
|
|
|
|
) = InputMediaVideo(file, text, parseMode, null, width, height, duration, thumb)
|
|
|
|
|
|
|
|
fun InputMediaVideo(
|
|
|
|
file: InputFile,
|
2021-05-29 08:23:25 +00:00
|
|
|
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
2020-11-05 10:53:26 +00:00
|
|
|
width: Int? = null,
|
|
|
|
height: Int? = null,
|
|
|
|
duration: Long? = null,
|
|
|
|
thumb: InputFile? = null
|
|
|
|
) = InputMediaVideo(file, entities.makeString(), null, entities.toRawMessageEntities(), width, height, duration, thumb)
|
|
|
|
|
2018-12-26 08:07:24 +00:00
|
|
|
@Serializable
|
2020-11-05 10:53:26 +00:00
|
|
|
data class InputMediaVideo internal constructor (
|
2019-04-15 11:30:09 +00:00
|
|
|
override val file: InputFile,
|
2020-11-05 10:53:26 +00:00
|
|
|
@SerialName(captionField)
|
|
|
|
override val text: String? = null,
|
2018-12-26 08:07:24 +00:00
|
|
|
@SerialName(parseModeField)
|
|
|
|
override val parseMode: ParseMode? = null,
|
2020-11-05 10:53:26 +00:00
|
|
|
@SerialName(captionEntitiesField)
|
|
|
|
private val rawEntities: List<RawMessageEntity>? = null,
|
2018-12-26 08:07:24 +00:00
|
|
|
override val width: Int? = null,
|
|
|
|
override val height: Int? = null,
|
2019-01-21 02:22:51 +00:00
|
|
|
override val duration: Long? = null,
|
2018-12-26 08:07:24 +00:00
|
|
|
override val thumb: InputFile? = null
|
2020-11-02 06:02:12 +00:00
|
|
|
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia {
|
2020-05-10 09:26:07 +00:00
|
|
|
override val type: String = videoInputMediaType
|
2021-05-29 08:23:25 +00:00
|
|
|
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy {
|
2021-04-28 13:54:57 +00:00
|
|
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
2020-11-05 10:53:26 +00:00
|
|
|
}
|
2018-12-26 08:07:24 +00:00
|
|
|
|
2020-08-18 06:50:11 +00:00
|
|
|
override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this)
|
2018-12-26 08:07:24 +00:00
|
|
|
|
2019-04-15 11:30:09 +00:00
|
|
|
@SerialName(mediaField)
|
2020-08-29 06:08:37 +00:00
|
|
|
override val media: String
|
2020-11-02 07:51:20 +00:00
|
|
|
init { media = file.fileIdToSend } // crutch until js compiling will be fixed
|
2018-12-26 08:07:24 +00:00
|
|
|
}
|