mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
fixes in Username
This commit is contained in:
parent
063a43922c
commit
45ba325f1b
@ -22,6 +22,10 @@ work with media groups lists
|
|||||||
|
|
||||||
### 0.10.2
|
### 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
|
## 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
|
||||||
|
@ -19,12 +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) || other ?.let {
|
||||||
|
super.equals("@$it")
|
||||||
|
} ?: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user