From 1963432bc8c9dc1bba20ffe4945738ca798803ef Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 7 Feb 2019 13:55:29 +0800 Subject: [PATCH] add Venue InlineQueryResult + fix titles in all results --- .../CommonAbstracts/CommonVenueData.kt | 4 +- .../TelegramBotAPI/CommonAbstracts/Titled.kt | 5 ++ .../InlineQueryResultAudioImpl.kt | 5 +- .../InlineQueryResultDocumentCachedImpl.kt | 3 +- .../InlineQueryResultDocumentImpl.kt | 5 +- .../InlineQueryResultLocation.kt | 5 +- .../InlineQueryResultVenue.kt | 56 +++++++++++++++++++ .../InlineQueryResultVideoCachedImpl.kt | 3 +- .../InlineQueryResultVideoImpl.kt | 5 +- .../InlineQueryResultVoiceCachedImpl.kt | 3 +- .../InlineQueryResultVoiceImpl.kt | 5 +- .../OptionallyTitledInlineQueryResult.kt | 6 +- .../abstracts/TitledInlineQueryResult.kt | 2 +- .../results/gif/InlineQueryResultGifCommon.kt | 2 +- .../InlineQueryResultMpeg4GifCommon.kt | 2 +- .../photo/InlineQueryResultPhotoCommon.kt | 2 +- 16 files changed, 82 insertions(+), 31 deletions(-) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/Titled.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/CommonVenueData.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/CommonVenueData.kt index c8dd1501d6..fa5dbd0cf2 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/CommonVenueData.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/CommonVenueData.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts -interface CommonVenueData { - val title: String +interface CommonVenueData : Titled { + override val title: String val address: String val foursquareId: String? val foursquareType: String? // TODO:: Rewrite with enum or interface diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/Titled.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/Titled.kt new file mode 100644 index 0000000000..e7532355a4 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/Titled.kt @@ -0,0 +1,5 @@ +package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts + +interface Titled { + val title: String? +} \ No newline at end of file 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 c91156d653..64bbcdb2d4 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 @@ -16,15 +16,14 @@ data class InlineQueryResultAudioImpl( override val id: String, @SerialName(audioUrlField) override val url: String, + @SerialName(titleField) + override val title: String, @SerialName(performerField) @Optional override val performer: String? = null, @SerialName(audioDurationField) @Optional override val duration: Int? = null, - @SerialName(titleField) - @Optional - override val title: String? = null, @SerialName(captionField) @Optional override val caption: String? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt index cc3abb6e06..349fb8f357 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt @@ -19,8 +19,7 @@ data class InlineQueryResultDocumentCachedImpl( @SerialName(documentFileIdField) override val fileId: FileId, @SerialName(titleField) - @Optional - override val title: String? = null, + override val title: String, @SerialName(descriptionField) @Optional override val description: String? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt index 1edbadc009..a0a5edb3ed 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt @@ -16,6 +16,8 @@ data class InlineQueryResultDocumentImpl( override val id: String, @SerialName(documentUrlField) override val url: String, + @SerialName(titleField) + override val title: String, @SerialName(thumbUrlField) @Optional override val thumbUrl: String? = null, @@ -27,9 +29,6 @@ data class InlineQueryResultDocumentImpl( override val thumbHeight: Int? = null, @SerialName(mimeTypeField) override val mimeType: String? = null, - @SerialName(titleField) - @Optional - override val title: String? = null, @SerialName(descriptionField) @Optional override val description: String? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt index ac9b23b390..a2aab02c1b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt @@ -20,6 +20,8 @@ data class InlineQueryResultLocation( override val latitude: Double, @SerialName(longitudeField) override val longitude: Double, + @SerialName(titleField) + override val title: String, @SerialName(livePeriodField) @Optional override val livePeriod: Int? = null, @@ -32,9 +34,6 @@ data class InlineQueryResultLocation( @SerialName(thumbHeightField) @Optional override val thumbHeight: Int? = null, - @SerialName(titleField) - @Optional - override val title: String? = null, @SerialName(replyMarkupField) @Optional override val replyMarkup: InlineKeyboardMarkup? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt new file mode 100644 index 0000000000..dd5cdb2984 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt @@ -0,0 +1,56 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult + +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.* +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.* +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.mimeTypeField +import kotlinx.serialization.Optional +import kotlinx.serialization.SerialName + +data class InlineQueryResultVenue( + @SerialName(idField) + override val id: String, + @SerialName(latitudeField) + override val latitude: Double, + @SerialName(longitudeField) + override val longitude: Double, + @SerialName(titleField) + override val title: String, + @SerialName(addressField) + override val address: String, + @SerialName(foursquareIdField) + @Optional + override val foursquareId: String? = null, + @SerialName(foursquareTypeField) + @Optional + override val foursquareType: String? = null, + @SerialName(thumbUrlField) + @Optional + override val thumbUrl: String? = null, + @SerialName(thumbWidthField) + @Optional + override val thumbWidth: Int? = null, + @SerialName(thumbHeightField) + @Optional + override val thumbHeight: Int? = null, + @SerialName(replyMarkupField) + @Optional + override val replyMarkup: InlineKeyboardMarkup? = null, + @SerialName(inputMessageContentField) + @Optional + override val inputMessageContent: InputMessageContent? = null +) : InlineQueryResult, + Locationed, + CommonVenueData, + TitledInlineQueryResult, + WithInputMessageContentInlineQueryResult, + ThumbedInlineQueryResult, + ThumbSizedInlineQueryResult +{ + override val type: String = "venue" +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt index df26bd3ebd..beecc7ea4a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt @@ -18,8 +18,7 @@ data class InlineQueryResultVideoCachedImpl( @SerialName(videoFileIdField) override val fileId: FileId, @SerialName(titleField) - @Optional - override val title: String? = null, + override val title: String, @SerialName(descriptionField) @Optional override val description: String? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt index 57895b0326..c5207f0fa7 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt @@ -19,6 +19,8 @@ data class InlineQueryResultVideoImpl( override val thumbUrl: String, @SerialName(mimeTypeField) override val mimeType: String? = null, + @SerialName(titleField) + override val title: String, @SerialName(videoWidthField) @Optional override val width: Int? = null, @@ -28,9 +30,6 @@ data class InlineQueryResultVideoImpl( @SerialName(videoDurationField) @Optional override val duration: Int? = null, - @SerialName(titleField) - @Optional - override val title: String? = null, @SerialName(descriptionField) @Optional override val description: String? = 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 index 5de6efcc0b..59ff27efa1 100644 --- 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 @@ -17,8 +17,7 @@ data class InlineQueryResultVoiceCachedImpl( @SerialName(voiceFileIdField) override val fileId: FileId, @SerialName(titleField) - @Optional - override val title: String? = null, + override val title: String, @SerialName(captionField) @Optional override val caption: String? = null, 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 index 2fe6d985df..1f0812df48 100644 --- 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 @@ -14,12 +14,11 @@ data class InlineQueryResultVoiceImpl( override val id: String, @SerialName(voiceUrlField) override val url: String, + @SerialName(titleField) + override val title: 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, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/OptionallyTitledInlineQueryResult.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/OptionallyTitledInlineQueryResult.kt index cf20f42c64..7669699c45 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/OptionallyTitledInlineQueryResult.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/OptionallyTitledInlineQueryResult.kt @@ -1,7 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts -interface OptionallyTitledInlineQueryResult : InlineQueryResult { - val title: String? +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Titled - -} +interface OptionallyTitledInlineQueryResult : InlineQueryResult, Titled diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/TitledInlineQueryResult.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/TitledInlineQueryResult.kt index 965d6c085b..ff5781c058 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/TitledInlineQueryResult.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/TitledInlineQueryResult.kt @@ -1,5 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts interface TitledInlineQueryResult : OptionallyTitledInlineQueryResult { - override val title: String? + override val title: String } diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt index de8e0b1037..13c8ca3e6f 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt @@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* interface InlineQueryResultGifCommon : InlineQueryResult, - TitledInlineQueryResult, + OptionallyTitledInlineQueryResult, Captioned, WithInputMessageContentInlineQueryResult { diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt index 0e0f86c3c7..68f2073d6f 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt @@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* interface InlineQueryResultMpeg4GifCommon : InlineQueryResult, - TitledInlineQueryResult, + OptionallyTitledInlineQueryResult, Captioned, WithInputMessageContentInlineQueryResult { diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt index fbf85345a4..601ac1cfac 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt @@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* interface InlineQueryResultPhotoCommon : InlineQueryResult, - TitledInlineQueryResult, + OptionallyTitledInlineQueryResult, DescribedInlineQueryResult, Captioned, WithInputMessageContentInlineQueryResult