From 063a43922cb14c4460d20d43e83495d26e9ab8b7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 17 Feb 2019 21:10:42 +0800 Subject: [PATCH 1/5] start 0.10.2 --- CHANGELOG.md | 2 ++ build.gradle | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d7f8fb055..2a6d0e1d45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ work with media groups lists * Fix `parseMode` of `InputTextMessageContent` +### 0.10.2 + ## 0.9.0 * Old extension `OkHttpClient.Builder#useWith` now deprecated and must be replaced by the same in diff --git a/build.gradle b/build.gradle index 6688104501..340034426d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -project.version = "0.10.1" +project.version = "0.10.2" project.group = "com.github.insanusmokrassar" buildscript { From 45ba325f1bc76216d7da4cfbbf6b1fbe26ba7d56 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 17 Feb 2019 21:12:56 +0800 Subject: [PATCH 2/5] fixes in Username --- CHANGELOG.md | 4 ++++ .../TelegramBotAPI/types/ChatIdentifier.kt | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a6d0e1d45..da7e0d6a38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ work with media groups lists ### 0.10.2 +* Fixes in `Username` + * Now you can create username object using string which is not starting with `@` + * Now `Username` correctly comparing with strings, which are not starting with `@` + ## 0.9.0 * Old extension `OkHttpClient.Builder#useWith` now deprecated and must be replaced by the same in diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt index 651a53c450..36c74899cd 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt @@ -19,12 +19,19 @@ fun Identifier.toChatId(): ChatId = ChatId(this) @Serializable(ChatIdentifierSerializer::class) data class Username( - val username: String + private val baseUsername: String ) : ChatIdentifier() { - init { - if (!username.startsWith("@")) { - throw IllegalArgumentException("Username must starts with `@`") - } + @Transient + val username: String = if (!baseUsername.startsWith("@")) { + "@$baseUsername" + } else { + baseUsername + } + + override fun equals(other: Any?): Boolean { + return super.equals(other) || other ?.let { + super.equals("@$it") + } ?: false } } From 0009d211bc8049322cef6727c4e9e8178df59a5f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Feb 2019 12:53:01 +0800 Subject: [PATCH 3/5] fix "equals" of Ysername --- .../TelegramBotAPI/types/ChatIdentifier.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt index 36c74899cd..176f3292d3 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt @@ -29,9 +29,10 @@ data class Username( } override fun equals(other: Any?): Boolean { - return super.equals(other) || other ?.let { - super.equals("@$it") - } ?: false + return super.equals(other) || when (other) { + is String -> super.equals("@$other") + else -> false + } } } From f6581ff3bea5d4f021f2477223ac996063375654 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Feb 2019 12:56:50 +0800 Subject: [PATCH 4/5] replace all usernames which was as strings by Username class usage --- CHANGELOG.md | 1 + .../com/github/insanusmokrassar/TelegramBotAPI/types/User.kt | 2 +- .../TelegramBotAPI/types/chat/ChannelChat.kt | 5 ++--- .../TelegramBotAPI/types/chat/PrivateChat.kt | 5 ++--- .../insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt | 5 ++--- .../TelegramBotAPI/types/chat/SupergroupChat.kt | 5 ++--- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da7e0d6a38..49acd27eb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ work with media groups lists * Fixes in `Username` * Now you can create username object using string which is not starting with `@` * Now `Username` correctly comparing with strings, which are not starting with `@` +* Now most part of usernames in library have type `Username` ## 0.9.0 diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt index 4e40b14e93..c824ff3d3c 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt @@ -17,7 +17,7 @@ data class User( val lastName: String? = null, @SerialName(usernameField) @Optional - val username: String? = null, + val username: Username? = null, @SerialName(languageCodeField) @Optional private val languageCode: String? = null diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChannelChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChannelChat.kt index fb861ea9e4..244350736c 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChannelChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChannelChat.kt @@ -1,13 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto +import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage data class ChannelChat( override val id: ChatId, override val title: String? = null, - val username: String? = null, + val username: Username? = null, val description: String? = null, override val inviteLink: String? = null, override val chatPhoto: ChatPhoto? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/PrivateChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/PrivateChat.kt index 4d1fb7ca1e..f266426398 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/PrivateChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/PrivateChat.kt @@ -1,11 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto +import com.github.insanusmokrassar.TelegramBotAPI.types.* data class PrivateChat( override val id: ChatId, - val username: String? = null, + val username: Username? = null, val firstName: String? = null, val lastName: String? = null, override val chatPhoto: ChatPhoto? = null diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt index 442bb58653..f10eaf9957 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt @@ -1,7 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto +import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import kotlinx.serialization.* @@ -10,7 +9,7 @@ data class RawChat( override val id: ChatId, private val type: String, @Optional private val title: String? = null, - @Optional private val username: String? = null, + @Optional private val username: Username? = null, @Optional private val first_name: String? = null, @Optional private val last_name: String? = null, @Optional private val all_members_are_administrators: Boolean? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/SupergroupChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/SupergroupChat.kt index f555efa613..3a1232e4fb 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/SupergroupChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/SupergroupChat.kt @@ -1,13 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto +import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage data class SupergroupChat( override val id: ChatId, override val title: String? = null, - val username: String? = null, + val username: Username? = null, val description: String? = null, override val allMembersAreAdmins: Boolean, override val inviteLink: String? = null, From aaa0f8f1148ec3e623a53b83de850d348f2b8fb2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Feb 2019 12:59:09 +0800 Subject: [PATCH 5/5] Optional replyMarkup in InlineQueryResultArticle --- CHANGELOG.md | 1 + .../InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49acd27eb4..2350f49bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ work with media groups lists * Now you can create username object using string which is not starting with `@` * Now `Username` correctly comparing with strings, which are not starting with `@` * Now most part of usernames in library have type `Username` +* Fix `replyMarkup` in `InlineQueryResultArticle` ## 0.9.0 diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt index b87ab02591..aa3094450b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt @@ -15,6 +15,7 @@ class InlineQueryResultArticle( @SerialName(inputMessageContentField) override val inputMessageContent: InputMessageContent, @SerialName(replyMarkupField) + @Optional override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(urlField) @Optional