diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index 5b9188e7de..5dbadf9633 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -170,12 +170,12 @@ data class ExtendedForumChatImpl( @Serializable data class ExtendedBot( override val id: UserId, - @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) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt index 0ccc48b172..660fe4c554 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt @@ -67,19 +67,17 @@ data class ChannelChatImpl( sealed class User : PrivateChat @Serializable(UserSerializer::class) -sealed class Bot : User() { - abstract override val username: Username -} +sealed class Bot : User() @Serializable data class CommonBot( override val id: UserId, - @SerialName(usernameField) - override val username: Username, @SerialName(firstNameField) override val firstName: String, @SerialName(lastNameField) - override val lastName: String = "" + override val lastName: String = "", + @SerialName(usernameField) + override val username: Username? = null, ) : Bot() { @SerialName(isBotField) private val isBot = true diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppUser.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppUser.kt index facd42061e..a89a98b93c 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppUser.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppUser.kt @@ -28,9 +28,9 @@ val WebAppUser.isPremium fun WebAppUser.asUser() = if (isBot == true) { CommonBot( UserId(id), - username ?.let(::Username) ?: error("Username is absent for bot, but must exists"), firstName, - lastName ?: "" + lastName ?: "", + username ?.let(::Username) ?: error("Username is absent for bot, but must exists") ) } else { CommonUser(