hotfix for inputmedias

This commit is contained in:
InsanusMokrassar 2019-04-15 19:30:09 +08:00
parent 723868a4f0
commit 1f8c27c756
6 changed files with 17 additions and 31 deletions

View File

@ -58,7 +58,6 @@ private val serializer = ArrayListSerializer(RawMessage.serializer())
data class SendMediaGroupData internal constructor(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@Transient
val media: List<MediaGroupMemberInputMedia> = emptyList(),
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,

View File

@ -8,15 +8,13 @@ import kotlinx.serialization.*
@Serializable
data class InputMediaAnimation(
@Transient
override val file: InputFile = throw IllegalStateException("Must be created with file"),
override val file: InputFile,
override val caption: String? = null,
@SerialName(parseModeField)
override val parseMode: ParseMode? = null,
override val width: Int? = null,
override val height: Int? = null,
override val duration: Long? = null,
@Transient
override val thumb: InputFile? = null
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia {
override val type: String = "animation"

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class InputMediaAudio(
override val file: InputFile = throw IllegalStateException("Must be created with file"),
override val file: InputFile,
override val caption: String? = null,
@SerialName(parseModeField)
override val parseMode: ParseMode? = null,

View File

@ -8,12 +8,10 @@ import kotlinx.serialization.*
@Serializable
data class InputMediaDocument(
@Transient
override val file: InputFile = throw IllegalStateException("Must be created with file"),
override val file: InputFile,
override val caption: String? = null,
@SerialName(parseModeField)
override val parseMode: ParseMode? = null,
@Transient
override val thumb: InputFile? = null
) : InputMedia, ThumbedInputMedia, CaptionedInputMedia {
override val type: String = "document"

View File

@ -9,8 +9,7 @@ import kotlinx.serialization.*
@Serializable
data class InputMediaPhoto(
@Transient
override val file: InputFile = throw IllegalStateException("Must be created with file"),
override val file: InputFile,
override val caption: String? = null,
@SerialName(parseModeField)
override val parseMode: ParseMode? = null
@ -19,17 +18,14 @@ data class InputMediaPhoto(
override fun serialize(format: StringFormat): String = format.stringify(serializer(), this)
@SerialName(mediaField)
val media: String = when (file) {
is FileId -> file.fileId
is MultipartFile -> inputMediaFileAttachmentNameTemplate.format(file.fileId)
}
@Transient
override val arguments: Map<String, Any?> = Mapper.mapNullable(serializer(), this)
@SerialName(mediaField)
val media: String
get() = file.let {
when (it) {
is FileId -> it.fileId
is MultipartFile -> inputMediaFileAttachmentNameTemplate.format(it.fileId)
}
}
}
fun PhotoSize.toInputMediaPhoto(

View File

@ -8,30 +8,25 @@ import kotlinx.serialization.*
@Serializable
data class InputMediaVideo(
@Transient
override val file: InputFile = throw IllegalStateException("Must be created with file"),
override val file: InputFile,
override val caption: String? = null,
@SerialName(parseModeField)
override val parseMode: ParseMode? = null,
override val width: Int? = null,
override val height: Int? = null,
override val duration: Long? = null,
@Transient
override val thumb: InputFile? = null
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia, MediaGroupMemberInputMedia {
override val type: String = "video"
override fun serialize(format: StringFormat): String = format.stringify(serializer(), this)
@SerialName(mediaField)
val media: String = when (file) {
is FileId -> file.fileId
is MultipartFile -> inputMediaFileAttachmentNameTemplate.format(file.fileId)
}
@Transient
override val arguments: Map<String, Any?> = Mapper.mapNullable(serializer(), this)
@SerialName(mediaField)
val media: String
get() = file.let {
when (it) {
is FileId -> it.fileId
is MultipartFile -> inputMediaFileAttachmentNameTemplate.format(it.fileId)
}
}
}