From c3978f2dabbf8d060255c4486cf2d878df490a37 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 20 Aug 2020 15:58:11 +0600 Subject: [PATCH] try to fix problem with arguments in InputMedia --- .../TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt | 3 +-- .../TelegramBotAPI/types/InputMedia/InputMediaVideo.kt | 3 +-- .../types/InputMedia/MediaGroupMemberInputMedia.kt | 10 +++++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt index 5fed0893a7..392cc3be77 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt @@ -27,8 +27,7 @@ data class InputMediaPhoto( } @Transient - @Deprecated("Marked as deprecated for removal in future updates", level = DeprecationLevel.ERROR) - override val arguments: Map = error("Unsupported operation") + override val arguments: Map = buildArguments(serializer()) } fun PhotoSize.toInputMediaPhoto( diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt index aa1626ae2a..db2f87ec4a 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt @@ -31,6 +31,5 @@ data class InputMediaVideo( } @Transient - @Deprecated("Marked as deprecated for removal in future updates", level = DeprecationLevel.ERROR) - override val arguments: Map = error("Unsupported operation") + override val arguments: Map = buildArguments(serializer()) } diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMedia.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMedia.kt index ed211ca949..2a42073f32 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMedia.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMedia.kt @@ -1,12 +1,16 @@ 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.properties.Properties + +internal fun T.buildArguments(withSerializer: SerializationStrategy) = Properties.encodeToMap( + 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 }