1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

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 work with media groups lists
* Fix `parseMode` of `InputTextMessageContent` * 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 ## 0.9.0
* Old extension `OkHttpClient.Builder#useWith` now deprecated and must be replaced by the same in * 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" project.group = "com.github.insanusmokrassar"
buildscript { buildscript {

View File

@ -19,11 +19,19 @@ fun Identifier.toChatId(): ChatId = ChatId(this)
@Serializable(ChatIdentifierSerializer::class) @Serializable(ChatIdentifierSerializer::class)
data class Username( data class Username(
val username: String private val baseUsername: String
) : ChatIdentifier() { ) : ChatIdentifier() {
init { @Transient
if (!username.startsWith("@")) { val username: String = if (!baseUsername.startsWith("@")) {
throw IllegalArgumentException("Username must starts with `@`") "@$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) @SerialName(inputMessageContentField)
override val inputMessageContent: InputMessageContent, override val inputMessageContent: InputMessageContent,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
@Optional
override val replyMarkup: InlineKeyboardMarkup? = null, override val replyMarkup: InlineKeyboardMarkup? = null,
@SerialName(urlField) @SerialName(urlField)
@Optional @Optional

View File

@ -17,7 +17,7 @@ data class User(
val lastName: String? = null, val lastName: String? = null,
@SerialName(usernameField) @SerialName(usernameField)
@Optional @Optional
val username: String? = null, val username: Username? = null,
@SerialName(languageCodeField) @SerialName(languageCodeField)
@Optional @Optional
private val languageCode: String? = null private val languageCode: String? = null

View File

@ -1,13 +1,12 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.chat package com.github.insanusmokrassar.TelegramBotAPI.types.chat
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
data class ChannelChat( data class ChannelChat(
override val id: ChatId, override val id: ChatId,
override val title: String? = null, override val title: String? = null,
val username: String? = null, val username: Username? = null,
val description: String? = null, val description: String? = null,
override val inviteLink: String? = null, override val inviteLink: String? = null,
override val chatPhoto: ChatPhoto? = null, override val chatPhoto: ChatPhoto? = null,

View File

@ -1,11 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.chat package com.github.insanusmokrassar.TelegramBotAPI.types.chat
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto
data class PrivateChat( data class PrivateChat(
override val id: ChatId, override val id: ChatId,
val username: String? = null, val username: Username? = null,
val firstName: String? = null, val firstName: String? = null,
val lastName: String? = null, val lastName: String? = null,
override val chatPhoto: ChatPhoto? = null override val chatPhoto: ChatPhoto? = null

View File

@ -1,7 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.chat package com.github.insanusmokrassar.TelegramBotAPI.types.chat
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
import kotlinx.serialization.* import kotlinx.serialization.*
@ -10,7 +9,7 @@ data class RawChat(
override val id: ChatId, override val id: ChatId,
private val type: String, private val type: String,
@Optional private val title: String? = null, @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 first_name: String? = null,
@Optional private val last_name: String? = null, @Optional private val last_name: String? = null,
@Optional private val all_members_are_administrators: Boolean? = null, @Optional private val all_members_are_administrators: Boolean? = null,

View File

@ -1,13 +1,12 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.chat package com.github.insanusmokrassar.TelegramBotAPI.types.chat
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
data class SupergroupChat( data class SupergroupChat(
override val id: ChatId, override val id: ChatId,
override val title: String? = null, override val title: String? = null,
val username: String? = null, val username: Username? = null,
val description: String? = null, val description: String? = null,
override val allMembersAreAdmins: Boolean, override val allMembersAreAdmins: Boolean,
override val inviteLink: String? = null, override val inviteLink: String? = null,