1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00

temporal update

This commit is contained in:
InsanusMokrassar 2020-08-20 17:35:26 +06:00
parent 046402454f
commit 94a35349aa
3 changed files with 21 additions and 11 deletions

View File

@ -6,6 +6,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField
import kotlinx.serialization.*
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
internal const val photoInputMediaType = "photo"
@ -27,8 +29,7 @@ data class InputMediaPhoto(
}
@Transient
@Deprecated("Marked as deprecated for removal in future updates", level = DeprecationLevel.ERROR)
override val arguments: Map<String, Any?> = error("Unsupported operation")
override val arguments: JsonElement = buildArguments(serializer())
}
fun PhotoSize.toInputMediaPhoto(

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField
import kotlinx.serialization.*
import kotlinx.serialization.properties.Properties
import kotlinx.serialization.json.JsonElement
internal const val videoInputMediaType = "video"
@ -24,13 +24,13 @@ data class InputMediaVideo(
override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this)
@Transient
override val arguments: JsonElement = buildArguments(serializer())
@SerialName(mediaField)
val media: String = when (file) {
is FileId -> file.fileId
is MultipartFile -> file.fileId.toInputMediaFileAttachmentName()
}
@Transient
@Deprecated("Marked as deprecated for removal in future updates", level = DeprecationLevel.ERROR)
override val arguments: Map<String, Any?> = error("Unsupported operation")
}

View File

@ -1,12 +1,21 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import kotlinx.serialization.Serializable
import kotlinx.serialization.StringFormat
import kotlinx.serialization.*
import kotlinx.serialization.json.*
internal val argumentsFormatter by lazy {
Json {
encodeDefaults = true
}
}
internal fun <T> T.buildArguments(withSerializer: SerializationStrategy<T>) = argumentsFormatter.encodeToJsonElement(
withSerializer,
this
)
@Serializable(MediaGroupMemberInputMediaSerializer::class)
interface MediaGroupMemberInputMedia : InputMedia, CaptionedOutput {
fun serialize(format: StringFormat): String
@Deprecated("Marked as deprecated for removal in future updates", level = DeprecationLevel.ERROR)
val arguments: Map<String, Any?>
val arguments: JsonElement
}