User as PrivateChat

This commit is contained in:
InsanusMokrassar 2019-12-11 10:18:12 +06:00
parent 761e08afc6
commit a17af67f83
3 changed files with 22 additions and 8 deletions

View File

@ -10,6 +10,10 @@
### 0.20.1
* `User` now implement `PrivateChat`
* `TextMentionMessageEntity` now accept `PrivateChat` instead of `User` in main constructor
* `TextMentionMessageEntity` now contains not user, but contains `PrivateChat`
## 0.19.0 ImplicitReflection removing
* Total rework of serialization for requests. Now all `SimpleRequest` children have:

View File

@ -1,14 +1,23 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.User
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionMarkdown
class TextMentionMessageEntity(
override val offset: Int,
override val length: Int,
override val sourceString: String,
val user: User
val privateChat: PrivateChat
) : MessageEntity {
override val asMarkdownSource: String = sourceString.mentionMarkdown(user.id)
override val asHtmlSource: String = sourceString.mentionMarkdown(user.id)
@Deprecated("Deprecated due to the fact that there is more common constructor")
constructor(
offset: Int,
length: Int,
sourceString: String,
user: User
) : this(offset, length, sourceString, user as PrivateChat)
override val asMarkdownSource: String = sourceString.mentionMarkdown(privateChat.id)
override val asHtmlSource: String = sourceString.mentionMarkdown(privateChat.id)
}

View File

@ -1,19 +1,20 @@
package com.github.insanusmokrassar.TelegramBotAPI.types
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class User(
val id: ChatId,
override val id: ChatId,
@SerialName(isBotField)
val isBot: Boolean = false,
@SerialName(firstNameField)
val firstName: String,
override val firstName: String,
@SerialName(lastNameField)
val lastName: String? = null,
override val lastName: String = "",
@SerialName(usernameField)
val username: Username? = null,
override val username: Username? = null,
@SerialName(languageCodeField)
val languageCode: String? = null
)
) : PrivateChat