1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-26 18:47:14 +00:00

now any administrator object instance have nullable field

This commit is contained in:
InsanusMokrassar 2020-01-01 21:51:11 +06:00
parent b4e4bed622
commit 47428dd6f9
5 changed files with 14 additions and 6 deletions

View File

@ -2,6 +2,7 @@
## 0.21.0 TelegramBotAPI 4.5
* Now any administrator object instance have `customTitle` nullable field
* Added the new request `SetChatAdministratorCustomTitle` to manage the custom titles of administrators promoted by the
bot.
* Added the field `slowModeDelay` to the `ExtendedSupergroupChat` objects.

View File

@ -13,5 +13,6 @@ data class AdministratorChatMemberImpl(
override val canInviteUsers: Boolean,
override val canRestrictMembers: Boolean,
override val canPinMessages: Boolean,
override val canPromoteMembers: Boolean
override val canPromoteMembers: Boolean,
override val customTitle: String?
) : AdministratorChatMember

View File

@ -3,8 +3,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.User
data class CreatorChatMember(override val user: User) :
AdministratorChatMember {
data class CreatorChatMember(
override val user: User,
override val customTitle: String?
) : AdministratorChatMember {
override val canBeEdited: Boolean = true
override val canChangeInfo: Boolean = true
override val canPostMessages: Boolean = true

View File

@ -39,11 +39,13 @@ internal data class RawChatMember(
@SerialName(canSendOtherMessagesField)
private val canSendOtherMessages: Boolean = false,
@SerialName(canAddWebPagePreviewsField)
private val canAddWebPagePreviews: Boolean = false
private val canAddWebPagePreviews: Boolean = false,
@SerialName(customTitleField)
private val customTitle: String? = null
) {
val asChatMember: ChatMember by lazy {
when (status) {
"creator" -> CreatorChatMember(user)
"creator" -> CreatorChatMember(user, customTitle)
"administrator" -> AdministratorChatMemberImpl(
user,
canBeEdited,
@ -54,7 +56,8 @@ internal data class RawChatMember(
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers
canPromoteMembers,
customTitle
)
"member" -> MemberChatMember(user)
"restricted" -> RestrictedChatMember(

View File

@ -7,4 +7,5 @@ interface AdministratorChatMember : SpecialRightsChatMember {
val canRemoveMessages: Boolean
val canRestrictMembers: Boolean
val canPromoteMembers: Boolean
val customTitle: String?
}