1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-25 19:48:43 +00:00

Fix #184: Anonymous Admins: support for is_anonymous flag

This commit is contained in:
madhead 2020-11-05 01:56:36 +03:00
parent 53b8cc4625
commit 0a73dfb799
No known key found for this signature in database
GPG Key ID: 66017D6A7E85EBE6
5 changed files with 9 additions and 1 deletions

View File

@ -41,6 +41,8 @@
* `LocationContent#createResend` now can create `LiveLocation`
* Support of `ProximityAlertTriggered`. It is `CommonEvent`
* Property `pollQuestionTextLength` now have maximum up to `300`
* Anonymous Admins:
* New field `AdministratorChatMember#isAnonymous`
* `API`:
* Extensions `TelegramBot#pinChatMessage` now support any `Chat` and `Message`s from any `Chat`
* New extensions `TelegramBot#unpinAllChatMessages`

View File

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

View File

@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.User
data class CreatorChatMember(
override val user: User,
override val isAnonymous: Boolean,
override val customTitle: String?
) : AdministratorChatMember {
override val canBeEdited: Boolean = true

View File

@ -40,12 +40,14 @@ internal data class RawChatMember(
private val canSendOtherMessages: Boolean = false,
@SerialName(canAddWebPagePreviewsField)
private val canAddWebPagePreviews: Boolean = false,
@SerialName(isAnonymousField)
private val isAnonymous: Boolean = false,
@SerialName(customTitleField)
private val customTitle: String? = null
) {
val asChatMember: ChatMember by lazy {
when (status) {
"creator" -> CreatorChatMember(user, customTitle)
"creator" -> CreatorChatMember(user, isAnonymous, customTitle)
"administrator" -> AdministratorChatMemberImpl(
user,
canBeEdited,
@ -57,6 +59,7 @@ internal data class RawChatMember(
canRestrictMembers,
canPinMessages,
canPromoteMembers,
isAnonymous,
customTitle
)
"member" -> MemberChatMember(user)

View File

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