mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 08:37:12 +00:00
make bots username nullable
This commit is contained in:
parent
8247e7c69c
commit
b3a657b7d6
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user