mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 11:38:45 +00:00
make bots username nullable
This commit is contained in:
parent
8247e7c69c
commit
b3a657b7d6
@ -170,12 +170,12 @@ data class ExtendedForumChatImpl(
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class ExtendedBot(
|
data class ExtendedBot(
|
||||||
override val id: UserId,
|
override val id: UserId,
|
||||||
@SerialName(usernameField)
|
|
||||||
override val username: Username,
|
|
||||||
@SerialName(firstNameField)
|
@SerialName(firstNameField)
|
||||||
override val firstName: String,
|
override val firstName: String,
|
||||||
@SerialName(lastNameField)
|
@SerialName(lastNameField)
|
||||||
override val lastName: String = "",
|
override val lastName: String = "",
|
||||||
|
@SerialName(usernameField)
|
||||||
|
override val username: Username? = null,
|
||||||
@SerialName(canJoinGroupsField)
|
@SerialName(canJoinGroupsField)
|
||||||
val canJoinGroups: Boolean = false,
|
val canJoinGroups: Boolean = false,
|
||||||
@SerialName(canReadAllGroupMessagesField)
|
@SerialName(canReadAllGroupMessagesField)
|
||||||
|
@ -67,19 +67,17 @@ data class ChannelChatImpl(
|
|||||||
sealed class User : PrivateChat
|
sealed class User : PrivateChat
|
||||||
|
|
||||||
@Serializable(UserSerializer::class)
|
@Serializable(UserSerializer::class)
|
||||||
sealed class Bot : User() {
|
sealed class Bot : User()
|
||||||
abstract override val username: Username
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CommonBot(
|
data class CommonBot(
|
||||||
override val id: UserId,
|
override val id: UserId,
|
||||||
@SerialName(usernameField)
|
|
||||||
override val username: Username,
|
|
||||||
@SerialName(firstNameField)
|
@SerialName(firstNameField)
|
||||||
override val firstName: String,
|
override val firstName: String,
|
||||||
@SerialName(lastNameField)
|
@SerialName(lastNameField)
|
||||||
override val lastName: String = ""
|
override val lastName: String = "",
|
||||||
|
@SerialName(usernameField)
|
||||||
|
override val username: Username? = null,
|
||||||
) : Bot() {
|
) : Bot() {
|
||||||
@SerialName(isBotField)
|
@SerialName(isBotField)
|
||||||
private val isBot = true
|
private val isBot = true
|
||||||
|
@ -28,9 +28,9 @@ val WebAppUser.isPremium
|
|||||||
fun WebAppUser.asUser() = if (isBot == true) {
|
fun WebAppUser.asUser() = if (isBot == true) {
|
||||||
CommonBot(
|
CommonBot(
|
||||||
UserId(id),
|
UserId(id),
|
||||||
username ?.let(::Username) ?: error("Username is absent for bot, but must exists"),
|
|
||||||
firstName,
|
firstName,
|
||||||
lastName ?: ""
|
lastName ?: "",
|
||||||
|
username ?.let(::Username) ?: error("Username is absent for bot, but must exists")
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
CommonUser(
|
CommonUser(
|
||||||
|
Loading…
Reference in New Issue
Block a user