From a2d7033745f382549307b629dfd856827c287a08 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 21 Jan 2019 16:04:55 +0800 Subject: [PATCH] CreatorChatMember implement AdministratorChatMember --- CHANGELOG | 1 + .../ChatMember/AdministratorChatMember.kt | 23 ++++++++----------- .../ChatMember/AdministratorChatMemberImpl.kt | 16 +++++++++++++ .../types/ChatMember/CreatorChatMember.kt | 12 +++++++++- .../types/ChatMember/RawChatMember.kt | 2 +- 5 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMemberImpl.kt diff --git a/CHANGELOG b/CHANGELOG index b9ad38e912..4a4c2f58d8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -35,3 +35,4 @@ * Change signature of `Update` * Now `Update` is untyped and data is `Any` * Media groups now are separated type of updates and you can subscribe on that receiving directly +* Now `AdministratorChatMember` is interface and `CreatorChatMember` implement it diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMember.kt index f9dd24f588..0f1ec8e402 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMember.kt @@ -1,16 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember -import com.github.insanusmokrassar.TelegramBotAPI.types.User - -data class AdministratorChatMember( - override val user: User, - val canBeEdited: Boolean, - val canChangeInfo: Boolean, - val canPostMessages: Boolean, - val canEditMessages: Boolean, - val canRemoveMessages: Boolean, - val canInviteUsers: Boolean, - val canRestrictMembers: Boolean, - val canPinMessages: Boolean, +interface AdministratorChatMember : ChatMember { + val canBeEdited: Boolean + val canChangeInfo: Boolean + val canPostMessages: Boolean + val canEditMessages: Boolean + val canRemoveMessages: Boolean + val canInviteUsers: Boolean + val canRestrictMembers: Boolean + val canPinMessages: Boolean val canPromoteMembers: Boolean -) : ChatMember +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMemberImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMemberImpl.kt new file mode 100644 index 0000000000..dd0245717d --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMemberImpl.kt @@ -0,0 +1,16 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember + +import com.github.insanusmokrassar.TelegramBotAPI.types.User + +data class AdministratorChatMemberImpl( + override val user: User, + override val canBeEdited: Boolean, + override val canChangeInfo: Boolean, + override val canPostMessages: Boolean, + override val canEditMessages: Boolean, + override val canRemoveMessages: Boolean, + override val canInviteUsers: Boolean, + override val canRestrictMembers: Boolean, + override val canPinMessages: Boolean, + override val canPromoteMembers: Boolean +) : AdministratorChatMember diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/CreatorChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/CreatorChatMember.kt index 1999680d49..c6507cdd2a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/CreatorChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/CreatorChatMember.kt @@ -2,4 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.User -data class CreatorChatMember(override val user: User) : ChatMember +data class CreatorChatMember(override val user: User) : AdministratorChatMember { + override val canBeEdited: Boolean = true + override val canChangeInfo: Boolean = true + override val canPostMessages: Boolean = true + override val canEditMessages: Boolean = true + override val canRemoveMessages: Boolean = true + override val canInviteUsers: Boolean = true + override val canRestrictMembers: Boolean = true + override val canPinMessages: Boolean = true + override val canPromoteMembers: Boolean = true +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RawChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RawChatMember.kt index f216b1fbe0..f64040c859 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RawChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RawChatMember.kt @@ -53,7 +53,7 @@ data class RawChatMember( val asChatMember: ChatMember by lazy { when (status) { "creator" -> CreatorChatMember(user) - "administrator" -> AdministratorChatMember( + "administrator" -> AdministratorChatMemberImpl( user, canBeEdited, canChangeInfo,