diff --git a/CHANGELOG.md b/CHANGELOG.md index 80cf84c579..02f12fabf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.25.0 +* `TelegramBotAPI`: + * `Bot` implementations (as and `Bot` itself) now have not nullable `username` + ## 0.24.0 * `TelegramBotAPI`: diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt index d23a1ce1d0..8362b2cd42 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt @@ -22,17 +22,19 @@ data class CommonUser( ) : User() @Serializable(UserSerializer::class) -sealed class Bot : User() +sealed class Bot : User() { + abstract override val username: Username +} @Serializable data class CommonBot( override val id: ChatId, + @SerialName(usernameField) + override val username: Username, @SerialName(firstNameField) override val firstName: String, @SerialName(lastNameField) - override val lastName: String = "", - @SerialName(usernameField) - override val username: Username? = null + override val lastName: String = "" ) : Bot() { @SerialName(isBotField) private val isBot = true @@ -41,12 +43,12 @@ data class CommonBot( @Serializable data class ExtendedBot( override val id: ChatId, + @SerialName(usernameField) + override val username: Username, @SerialName(firstNameField) override val firstName: String, @SerialName(lastNameField) override val lastName: String = "", - @SerialName(usernameField) - override val username: Username? = null, @SerialName(canJoinGroupsField) val canJoinGroups: Boolean = false, @SerialName(canReadAllGroupMessagesField)