Merge pull request #19 from InsanusMokrassar/0.10.2

0.10.2
This commit is contained in:
InsanusMokrassar 2019-02-18 13:07:34 +08:00 committed by GitHub
commit 3d786ee4bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 31 additions and 18 deletions

View File

@ -20,6 +20,14 @@
work with media groups lists
* Fix `parseMode` of `InputTextMessageContent`
### 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 `@`
* Now most part of usernames in library have type `Username`
* Fix `replyMarkup` in `InlineQueryResultArticle`
## 0.9.0
* Old extension `OkHttpClient.Builder#useWith` now deprecated and must be replaced by the same in

View File

@ -1,4 +1,4 @@
project.version = "0.10.1"
project.version = "0.10.2"
project.group = "com.github.insanusmokrassar"
buildscript {

View File

@ -19,11 +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) || when (other) {
is String -> super.equals("@$other")
else -> false
}
}
}

View File

@ -15,6 +15,7 @@ class InlineQueryResultArticle(
@SerialName(inputMessageContentField)
override val inputMessageContent: InputMessageContent,
@SerialName(replyMarkupField)
@Optional
override val replyMarkup: InlineKeyboardMarkup? = null,
@SerialName(urlField)
@Optional

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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,