From 99c3f9b742406e7c9ed62d4a98461e4aba0cce3b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 7 Feb 2019 13:10:15 +0800 Subject: [PATCH] add Voice InlineQueryResult + a little fix of Audio result --- .../TelegramBotAPI/types/Common.kt | 4 +++ .../InlineQueryResultAudioImpl.kt | 3 +- .../InlineQueryResultVoiceCachedImpl.kt | 34 ++++++++++++++++++ .../InlineQueryResultVoiceImpl.kt | 35 +++++++++++++++++++ .../results/voice/InlineQueryResultVoice.kt | 6 ++++ .../voice/InlineQueryResultVoiceCached.kt | 5 +++ .../voice/InlineQueryResultVoiceCommon.kt | 14 ++++++++ 7 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoice.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCached.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt index dafdcd418a..53ba540945 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt @@ -89,6 +89,10 @@ const val audioUrlField = "audio_url" const val audioFileIdField = "audio_file_id" const val audioDurationField = "audio_duration" +const val voiceUrlField = "voice_url" +const val voiceFileIdField = "voice_file_id" +const val voiceDurationField = "voice_duration" + const val gameShortNameField = "game_short_name" const val thumbUrlField = "thumb_url" diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt index ddf4432bdc..c91156d653 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt @@ -17,7 +17,8 @@ data class InlineQueryResultAudioImpl( @SerialName(audioUrlField) override val url: String, @SerialName(performerField) - override val performer: String?, + @Optional + override val performer: String? = null, @SerialName(audioDurationField) @Optional override val duration: Int? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt new file mode 100644 index 0000000000..5de6efcc0b --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt @@ -0,0 +1,34 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult + +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField +import kotlinx.serialization.Optional +import kotlinx.serialization.SerialName + +data class InlineQueryResultVoiceCachedImpl( + @SerialName(idField) + override val id: String, + @SerialName(voiceFileIdField) + override val fileId: FileId, + @SerialName(titleField) + @Optional + override val title: String? = null, + @SerialName(captionField) + @Optional + override val caption: String? = null, + @SerialName(parseModeField) + @Optional + override val parseMode: ParseMode? = null, + @SerialName(replyMarkupField) + @Optional + override val replyMarkup: InlineKeyboardMarkup? = null, + @SerialName(inputMessageContentField) + @Optional + override val inputMessageContent: InputMessageContent? = null +) : InlineQueryResultVoiceCached diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt new file mode 100644 index 0000000000..2fe6d985df --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt @@ -0,0 +1,35 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult + +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField +import kotlinx.serialization.Optional +import kotlinx.serialization.SerialName + +data class InlineQueryResultVoiceImpl( + @SerialName(idField) + override val id: String, + @SerialName(voiceUrlField) + override val url: String, + @SerialName(voiceDurationField) + @Optional + override val duration: Int? = null, + @SerialName(titleField) + @Optional + override val title: String? = null, + @SerialName(captionField) + @Optional + override val caption: String? = null, + @SerialName(parseModeField) + @Optional + override val parseMode: ParseMode? = null, + @SerialName(replyMarkupField) + @Optional + override val replyMarkup: InlineKeyboardMarkup? = null, + @SerialName(inputMessageContentField) + @Optional + override val inputMessageContent: InputMessageContent? = null +) : InlineQueryResultVoice diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoice.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoice.kt new file mode 100644 index 0000000000..b400854bc7 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoice.kt @@ -0,0 +1,6 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice + +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* + +interface InlineQueryResultVoice : InlineQueryResultVoiceCommon, UrlInlineQueryResult, DuratedInlineResultQuery \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCached.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCached.kt new file mode 100644 index 0000000000..9977b5f6b6 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCached.kt @@ -0,0 +1,5 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice + +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* + +interface InlineQueryResultVoiceCached : InlineQueryResultVoiceCommon, WithFileIdInlineQueryResult diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt new file mode 100644 index 0000000000..1d9332244a --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt @@ -0,0 +1,14 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice + +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.MimeTyped +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* + +interface InlineQueryResultVoiceCommon : InlineQueryResult, + Captioned, + WithInputMessageContentInlineQueryResult, + TitledInlineQueryResult +{ + override val type: String + get() = "audio" +} \ No newline at end of file