From e4f305b3ecd8a8830070d6b91bc01f39faa43cf5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 20 Sep 2020 20:11:27 +0600 Subject: [PATCH 1/8] start 0.28.3 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fede4902aa..d7f23f35f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ * `HttpClient#loadFile` * `PathedFile#download` +### 0.28.3 + ### 0.28.2 * `TelegramBotAPI-extensions-utils`: diff --git a/gradle.properties b/gradle.properties index 9ec7484d83..89d3e9ce4e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,6 @@ ktor_version=1.4.0 javax_activation_version=1.1.1 library_group=com.github.insanusmokrassar -library_version=0.28.2 +library_version=0.28.3 gradle_bintray_plugin_version=1.8.5 From 89dc7a4b2aec379a2be2889ad3829a53e9a6d683 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 20 Sep 2020 20:16:14 +0600 Subject: [PATCH 2/8] InlineQueryResult#id type change --- CHANGELOG.md | 4 ++++ .../InlineQueryResult/InlineQueryResultArticle.kt | 2 +- .../InlineQueryResult/InlineQueryResultAudioCachedImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultAudioImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultContact.kt | 2 +- .../InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultDocumentImpl.kt | 2 +- .../InlineQueries/InlineQueryResult/InlineQueryResultGame.kt | 3 ++- .../InlineQueryResult/InlineQueryResultGifCachedImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultGifImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultLocation.kt | 2 +- .../InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultPhotoImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultStickerCached.kt | 2 +- .../InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt | 2 +- .../InlineQueryResult/InlineQueryResultVideoCachedImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultVideoImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt | 2 +- .../InlineQueryResult/InlineQueryResultVoiceImpl.kt | 2 +- .../InlineQueryResult/abstracts/InlineQueryResult.kt | 3 ++- 22 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7f23f35f2..6bd72d8e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ ### 0.28.3 +* `TelegramBotAPI-core`: + * All `InlineQueryResult` has changed their type of id for more obvious relation between `InlineQueryResult#id` and + `ChosenInlineResult#resultId`: `String` -> `InlineQueryIdentifier` + ### 0.28.2 * `TelegramBotAPI-extensions-utils`: diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt index 54d8a925de..3fbe736f22 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable class InlineQueryResultArticle( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(titleField) override val title: String, @SerialName(inputMessageContentField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioCachedImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioCachedImpl.kt index 478def39fd..e1d6899200 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioCachedImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioCachedImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultAudioCachedImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(audioFileIdField) override val fileId: FileId, @SerialName(captionField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt index 96ffba4ef9..0607d17ee3 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt @@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultAudioImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(audioUrlField) override val url: String, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt index a3165cf313..be39cc720b 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultContact( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(phoneNumberField) override val phoneNumber: String, @SerialName(firstNameField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt index 43580e2d99..28fcc63300 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultDocumentCachedImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(documentFileIdField) override val fileId: FileId, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt index 269a3cd9b9..cd021cfa73 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt @@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultDocumentImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(documentUrlField) override val url: String, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGame.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGame.kt index 2f45277614..eb2b4265fe 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGame.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGame.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueryIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.gameShortNameField import kotlinx.serialization.SerialName @@ -8,7 +9,7 @@ import kotlinx.serialization.Serializable @Serializable class InlineQueryResultGame( - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(gameShortNameField) val gameShortName: String, override val replyMarkup: InlineKeyboardMarkup? = null diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt index 6ed362aaef..c6227515e3 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultGifCachedImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(gifFileIdField) override val fileId: FileId, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt index 97e23a5d23..b94c6e9fd2 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultGifImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(gifUrlField) override val url: String, @SerialName(thumbUrlField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt index 73bea7a975..eaa9327238 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultLocation( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(latitudeField) override val latitude: Double, @SerialName(longitudeField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt index 3a38ad7a8c..2b23a7c1ba 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultMpeg4GifCachedImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(mpeg4GifFileIdField) override val fileId: FileId, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt index 6456378bf9..260787fc27 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultMpeg4GifImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(mpeg4GifUrlField) override val url: String, @SerialName(thumbUrlField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt index c6c44cd893..3394e926aa 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultPhotoCachedImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(photoFileIdField) override val fileId: FileId, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt index cb3289ec80..c91d7a0548 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt @@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultPhotoImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(photoUrlField) override val url: String, @SerialName(thumbUrlField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultStickerCached.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultStickerCached.kt index ceb2a2de25..acb9a9a37f 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultStickerCached.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultStickerCached.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultStickerCached( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(stickerFileIdField) override val fileId: FileId, @SerialName(replyMarkupField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt index 59824d1ca5..3c8def6d1c 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultVenue( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(latitudeField) override val latitude: Double, @SerialName(longitudeField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt index 98bfe63f58..f43ab55624 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultVideoCachedImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(videoFileIdField) override val fileId: FileId, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt index fce72b9817..2c7667d8d5 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt @@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultVideoImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(videoUrlField) override val url: String, @SerialName(thumbUrlField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt index 0ecca9f32d..7c6c414ca8 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultVoiceCachedImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(voiceFileIdField) override val fileId: FileId, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt index 9090e0bfb1..c9916096fd 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt @@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable @Serializable data class InlineQueryResultVoiceImpl( @SerialName(idField) - override val id: String, + override val id: InlineQueryIdentifier, @SerialName(voiceUrlField) override val url: String, @SerialName(titleField) diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt index 65204864ea..1e3406e967 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt @@ -1,12 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueryIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import kotlinx.serialization.Serializable @Serializable(InlineQueryResultSerializer::class) interface InlineQueryResult { val type: String - val id: String + val id: InlineQueryIdentifier val replyMarkup: InlineKeyboardMarkup? } \ No newline at end of file From 46c33d5ec477186e7be1144fb0c4550cdff2210e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 22 Sep 2020 11:33:47 +0600 Subject: [PATCH 3/8] update dependencies --- CHANGELOG.md | 5 +++++ TelegramBotAPI-core/build.gradle | 2 +- .../com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt | 1 + .../insanusmokrassar/TelegramBotAPI/SimpleInputFilesTest.kt | 1 + .../insanusmokrassar/TelegramBotAPI/TestsJsonFormat.kt | 4 +++- .../TelegramBotAPI/extensions/api/JsonUtils.kt | 1 + .../TelegramBotAPI/extensions/utils/JsonFormat.kt | 1 + gradle.properties | 4 ++-- 8 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bd72d8e75..e7ea38cb3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,11 @@ ### 0.28.3 +* Common`: + * Version updates: + * `Klock`: `0.12.0` -> `0.12.1` + * `Kotlin serialization`: `1.0.0-RC` -> `1.0.0-RC2` (dependency `kotlinx-serialization-core` was replaced with + `kotlinx-serialization-json` due to [kotlinx.serialization library update](https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md#100-rc2--2020-09-21)) * `TelegramBotAPI-core`: * All `InlineQueryResult` has changed their type of id for more obvious relation between `InlineQueryResult#id` and `ChosenInlineResult#resultId`: `String` -> `InlineQueryIdentifier` diff --git a/TelegramBotAPI-core/build.gradle b/TelegramBotAPI-core/build.gradle index 19420bf448..eaf93b61f8 100644 --- a/TelegramBotAPI-core/build.gradle +++ b/TelegramBotAPI-core/build.gradle @@ -41,7 +41,7 @@ kotlin { dependencies { implementation kotlin('stdlib') api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" - api "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialisation_runtime_version" + api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version" api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version" api "com.soywiz.korlibs.klock:klock:$klock_version" diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt index 01c3d0f8b5..1a4e506d12 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt @@ -8,6 +8,7 @@ internal val nonstrictJsonFormat = Json { ignoreUnknownKeys = true allowSpecialFloatingPointValues = true useArrayPolymorphism = true + encodeDefaults = true } fun T.toJsonWithoutNulls(serializer: SerializationStrategy): JsonObject = toJson(serializer).withoutNulls() diff --git a/TelegramBotAPI-core/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/SimpleInputFilesTest.kt b/TelegramBotAPI-core/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/SimpleInputFilesTest.kt index 1da2a34a55..22294176ea 100644 --- a/TelegramBotAPI-core/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/SimpleInputFilesTest.kt +++ b/TelegramBotAPI-core/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/SimpleInputFilesTest.kt @@ -13,6 +13,7 @@ private val nonstrictJsonFormat = Json { ignoreUnknownKeys = true allowSpecialFloatingPointValues = true useArrayPolymorphism = true + encodeDefaults = true } class SimpleInputFilesTest { diff --git a/TelegramBotAPI-core/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/TestsJsonFormat.kt b/TelegramBotAPI-core/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/TestsJsonFormat.kt index c027bfd689..913df02bde 100644 --- a/TelegramBotAPI-core/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/TestsJsonFormat.kt +++ b/TelegramBotAPI-core/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/TestsJsonFormat.kt @@ -2,4 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI import kotlinx.serialization.json.Json -val TestsJsonFormat = Json {} +val TestsJsonFormat = Json { + encodeDefaults = true +} diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/JsonUtils.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/JsonUtils.kt index 0a4153f2c1..2ae50a6cdb 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/JsonUtils.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/JsonUtils.kt @@ -8,4 +8,5 @@ internal val nonstrictJsonFormat = Json { ignoreUnknownKeys = true allowSpecialFloatingPointValues = true useArrayPolymorphism = true + encodeDefaults = true } diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/JsonFormat.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/JsonFormat.kt index 86b3f21720..76b4a1d614 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/JsonFormat.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/JsonFormat.kt @@ -8,4 +8,5 @@ internal val nonstrictJsonFormat = Json { ignoreUnknownKeys = true allowSpecialFloatingPointValues = true useArrayPolymorphism = true + encodeDefaults = true } diff --git a/gradle.properties b/gradle.properties index 89d3e9ce4e..f6c24eaf52 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,8 +7,8 @@ kotlin.incremental.js=true kotlin_version=1.4.10 kotlin_coroutines_version=1.3.9 -kotlin_serialisation_runtime_version=1.0.0-RC -klock_version=1.12.0 +kotlin_serialisation_runtime_version=1.0.0-RC2 +klock_version=1.12.1 uuid_version=0.2.2 ktor_version=1.4.0 From acd9505a5d2c43ce5ff03b2435002583acd8d48b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 22 Sep 2020 14:47:34 +0600 Subject: [PATCH 4/8] inline queries extensions --- CHANGELOG.md | 11 ++++++ .../utils/internal_utils/UpdatesFiltering.kt | 16 +++++++++ .../ChosenInlineResultUpdatesConversations.kt | 36 +++++++++++++++++++ .../InlineQueryUpdatesConversations.kt | 35 ++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/internal_utils/UpdatesFiltering.kt create mode 100644 TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt create mode 100644 TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/InlineQueryUpdatesConversations.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index e7ea38cb3e..adbefeb070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,17 @@ * `TelegramBotAPI-core`: * All `InlineQueryResult` has changed their type of id for more obvious relation between `InlineQueryResult#id` and `ChosenInlineResult#resultId`: `String` -> `InlineQueryIdentifier` +* `TelegramBotAPI-extensions-utils`: + * Several extensions for updates flows based on `InlineQueryUpdate` has been added: + * `Flow#onlyBaseInlineQueriesWithUpdates` + * `Flow#onlyBaseInlineQueries` + * `Flow#onlyLocationInlineQueriesWithUpdates` + * `Flow#onlyLocationInlineQueries` + * Several extensions for updates flows based on `ChosenInlineResultUpdate` has been added: + * `Flow.onlyBaseChosenInlineResultsWithUpdates` + * `Flow.onlyBaseChosenInlineResults` + * `Flow.onlyLocationChosenInlineResultsWithUpdates` + * `Flow.onlyLocationChosenInlineResults` ### 0.28.2 diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/internal_utils/UpdatesFiltering.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/internal_utils/UpdatesFiltering.kt new file mode 100644 index 0000000000..86ef6b60b2 --- /dev/null +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/internal_utils/UpdatesFiltering.kt @@ -0,0 +1,16 @@ +package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils + +import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.mapNotNull + +internal inline fun Flow.onlySpecifiedTypeOfDataWithUpdates(): Flow> { + return mapNotNull { + it.updateId to (it.data as? T ?: return@mapNotNull null) + } +} + +internal inline fun Flow.onlySpecifiedTypeOfData(): Flow { + return mapNotNull { it as? T } +} diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt new file mode 100644 index 0000000000..ccd53fd7b9 --- /dev/null +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt @@ -0,0 +1,36 @@ +package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates + +import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils.onlySpecifiedTypeOfData +import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils.onlySpecifiedTypeOfDataWithUpdates +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.ChosenInlineResult.BaseChosenInlineResult +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.ChosenInlineResult.LocationChosenInlineResult +import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.update.ChosenInlineResultUpdate +import com.github.insanusmokrassar.TelegramBotAPI.types.update.InlineQueryUpdate +import kotlinx.coroutines.flow.Flow + +/** + * @return Mapped [Flow] with [Pair]s. [Pair.first] in this pair will be [UpdateIdentifier]. It could be useful in + * cases you are using [InlineQueryUpdate.updateId] for some reasons. [Pair.second] will always be [BaseChosenInlineResult]. + */ +fun Flow.onlyBaseChosenInlineResultsWithUpdates(): Flow> = onlySpecifiedTypeOfDataWithUpdates() + +/** + * @return Filter updates only with [BaseChosenInlineResult] and map it to a [Flow] with values [BaseChosenInlineResult] + * + * @see onlyBaseChosenInlineResultsWithUpdates + */ +fun Flow.onlyBaseChosenInlineResults(): Flow = onlySpecifiedTypeOfData() + +/** + * @return Mapped [Flow] with [Pair]s. [Pair.first] in this pair will be [UpdateIdentifier]. It could be useful in + * cases you are using [InlineQueryUpdate.updateId] for some reasons. [Pair.second] will always be [LocationChosenInlineResult]. + */ +fun Flow.onlyLocationChosenInlineResultsWithUpdates(): Flow> = onlySpecifiedTypeOfDataWithUpdates() + +/** + * @return Filter updates only with [LocationChosenInlineResult] and map it to a [Flow] with values [LocationChosenInlineResult] + * + * @see onlyLocationChosenInlineResultsWithUpdates + */ +fun Flow.onlyLocationChosenInlineResults(): Flow = onlySpecifiedTypeOfData() diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/InlineQueryUpdatesConversations.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/InlineQueryUpdatesConversations.kt new file mode 100644 index 0000000000..8f9a230fc9 --- /dev/null +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/InlineQueryUpdatesConversations.kt @@ -0,0 +1,35 @@ +package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates + +import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils.onlySpecifiedTypeOfData +import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils.onlySpecifiedTypeOfDataWithUpdates +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.query.BaseInlineQuery +import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.query.LocationInlineQuery +import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.update.InlineQueryUpdate +import kotlinx.coroutines.flow.* + +/** + * @return Mapped [Flow] with [Pair]s. [Pair.first] in this pair will be [UpdateIdentifier]. It could be useful in + * cases you are using [InlineQueryUpdate.updateId] for some reasons. [Pair.second] will always be [BaseInlineQuery]. + */ +fun Flow.onlyBaseInlineQueriesWithUpdates(): Flow> = onlySpecifiedTypeOfDataWithUpdates() + +/** + * @return Filter updates only with [BaseInlineQuery] and map it to a [Flow] with values [BaseInlineQuery] + * + * @see onlyBaseInlineQueriesWithUpdates + */ +fun Flow.onlyBaseInlineQueries(): Flow = onlySpecifiedTypeOfData() + +/** + * @return Mapped [Flow] with [Pair]s. [Pair.first] in this pair will be [UpdateIdentifier]. It could be useful in + * cases you are using [InlineQueryUpdate.updateId] for some reasons. [Pair.second] will always be [LocationInlineQuery]. + */ +fun Flow.onlyLocationInlineQueriesWithUpdates(): Flow> = onlySpecifiedTypeOfDataWithUpdates() + +/** + * @return Filter updates only with [LocationInlineQuery] and map it to a [Flow] with values [LocationInlineQuery] + * + * @see onlyLocationInlineQueriesWithUpdates + */ +fun Flow.onlyLocationInlineQueries(): Flow = onlySpecifiedTypeOfData() From 70436475849470ddf23854e724a75fbbc74f4ed8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 22 Sep 2020 15:15:20 +0600 Subject: [PATCH 5/8] changelog parser script has been added --- changelog_info_retriever | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 changelog_info_retriever diff --git a/changelog_info_retriever b/changelog_info_retriever new file mode 100755 index 0000000000..834ae33666 --- /dev/null +++ b/changelog_info_retriever @@ -0,0 +1,16 @@ +#!/bin/bash + +version=$1 + +read -r +while [ -z "`echo $REPLY | grep -e "^#\+ $version"`" ] +do + read -r +done + +read -r +while [ -z "`echo $REPLY | grep -e "^#\+"`" ] +do + echo "$REPLY" + read -r +done From 034901a479f74c052ff54ef3be86465009763593 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 22 Sep 2020 18:04:10 +0600 Subject: [PATCH 6/8] add publication of github release via changelog --- .gitignore | 3 +++ CHANGELOG.md | 2 +- build.gradle | 48 ++++++++++++++++++++++++++++++++++++++++ changelog_info_retriever | 35 ++++++++++++++++++++--------- gradle.properties | 1 + 5 files changed, 77 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 5dc177e271..0546396337 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ settings.xml .gradle/ build/ out/ + +local.properties +secret.gradle diff --git a/CHANGELOG.md b/CHANGELOG.md index adbefeb070..2a831fab41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ ### 0.28.3 -* Common`: +* Common: * Version updates: * `Klock`: `0.12.0` -> `0.12.1` * `Kotlin serialization`: `1.0.0-RC` -> `1.0.0-RC2` (dependency `kotlinx-serialization-core` was replaced with diff --git a/build.gradle b/build.gradle index 59d75fc3a7..9183cb1bad 100644 --- a/build.gradle +++ b/build.gradle @@ -3,12 +3,14 @@ buildscript { mavenLocal() jcenter() mavenCentral() + maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" + classpath "com.github.breadmoirai:github-release:$github_release_plugin_version" } } @@ -16,3 +18,49 @@ plugins { id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" apply false id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false } + +ext { + enable_github_publish=new File(projectDir, "secret.gradle").exists() + changelog_from_file="" +} + +if (ext.enable_github_publish) { + apply from: './secret.gradle' + apply plugin: "com.github.breadmoirai.github-release" +} + +private String getCurrentVersionChangelog() { + OutputStream changelogDataOS = new ByteArrayOutputStream() + exec { + standardOutput = changelogDataOS + commandLine './changelog_info_retriever', "$library_version", 'CHANGELOG.md' + } + + return changelogDataOS.toString().trim() +} + +if (enable_github_publish && project.hasProperty('GITHUB_RELEASE_TOKEN')) { + String changelogFromFile = "" + githubRelease { + token "${project.property('GITHUB_RELEASE_TOKEN')}" + + owner "InsanusMokrassar" + repo "TelegramBotAPI" + + tagName "$library_version" + releaseName "$library_version" + targetCommitish "$library_version" + + body getCurrentVersionChangelog() + } + +// tasks.getByName("githubRelease").doFirst { +// OutputStream changelogDataOS = new ByteArrayOutputStream() +// exec { +// standardOutput = changelogDataOS +// commandLine './changelog_info_retriever', "$library_version", 'CHANGELOG.md' +// } +// changelogFromFile = changelogDataOS.toString().trim() +// ext.changelog_from_file = changelogFromFile +// } +} diff --git a/changelog_info_retriever b/changelog_info_retriever index 834ae33666..9fc99fbd5d 100755 --- a/changelog_info_retriever +++ b/changelog_info_retriever @@ -1,16 +1,29 @@ #!/bin/bash +function parse() { + version=$1 + + read -r + while [ -z "`echo $REPLY | grep -e "^#\+ $version"`" ] + do + read -r + done + + read -r + while [ -z "`echo $REPLY | grep -e "^#\+"`" ] + do + echo "$REPLY" + read -r + done +} + version=$1 +file=$2 + +if [ -n "$file" ]; then + parse $version < "$file" +else + parse $version +fi -read -r -while [ -z "`echo $REPLY | grep -e "^#\+ $version"`" ] -do - read -r -done -read -r -while [ -z "`echo $REPLY | grep -e "^#\+"`" ] -do - echo "$REPLY" - read -r -done diff --git a/gradle.properties b/gradle.properties index f6c24eaf52..b6819c45aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,3 +18,4 @@ library_group=com.github.insanusmokrassar library_version=0.28.3 gradle_bintray_plugin_version=1.8.5 +github_release_plugin_version=2.2.12 From 8b5244d8df2bc74a140d8c9a93cd4b899a83b353 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 22 Sep 2020 18:06:50 +0600 Subject: [PATCH 7/8] hotfix --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9183cb1bad..f1a3fca3a0 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,6 @@ plugins { ext { enable_github_publish=new File(projectDir, "secret.gradle").exists() - changelog_from_file="" } if (ext.enable_github_publish) { From 8804a24013b5c3eb7a747e211d93714b0416f498 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 22 Sep 2020 18:12:48 +0600 Subject: [PATCH 8/8] small refactoring --- build.gradle | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index f1a3fca3a0..344837f1b4 100644 --- a/build.gradle +++ b/build.gradle @@ -19,15 +19,6 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false } -ext { - enable_github_publish=new File(projectDir, "secret.gradle").exists() -} - -if (ext.enable_github_publish) { - apply from: './secret.gradle' - apply plugin: "com.github.breadmoirai.github-release" -} - private String getCurrentVersionChangelog() { OutputStream changelogDataOS = new ByteArrayOutputStream() exec { @@ -38,8 +29,10 @@ private String getCurrentVersionChangelog() { return changelogDataOS.toString().trim() } -if (enable_github_publish && project.hasProperty('GITHUB_RELEASE_TOKEN')) { - String changelogFromFile = "" +if (new File(projectDir, "secret.gradle").exists()) { + apply from: './secret.gradle' + apply plugin: "com.github.breadmoirai.github-release" + githubRelease { token "${project.property('GITHUB_RELEASE_TOKEN')}" @@ -52,14 +45,4 @@ if (enable_github_publish && project.hasProperty('GITHUB_RELEASE_TOKEN')) { body getCurrentVersionChangelog() } - -// tasks.getByName("githubRelease").doFirst { -// OutputStream changelogDataOS = new ByteArrayOutputStream() -// exec { -// standardOutput = changelogDataOS -// commandLine './changelog_info_retriever', "$library_version", 'CHANGELOG.md' -// } -// changelogFromFile = changelogDataOS.toString().trim() -// ext.changelog_from_file = changelogFromFile -// } }