From 3c5abac6691ef15f9ae9acc235ec945352041018 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 19:26:30 +0600 Subject: [PATCH] include canManageChat --- .../chat/members/PromoteChatMember.kt | 4 +++- .../ChatMember/AdministratorChatMemberImpl.kt | 2 ++ .../types/ChatMember/CreatorChatMember.kt | 2 ++ .../abstracts/AdministratorChatMember.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../api/chat/members/PromoteChatMember.kt | 24 ++++++++++++------- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt index 74e17ee623..91e18f7381 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt @@ -33,7 +33,9 @@ data class PromoteChatMember( @SerialName(canPromoteMembersField) private val canPromoteMembers: Boolean? = null, @SerialName(canManageVoiceChatsField) - private val canManageVoiceChats: Boolean? = null + private val canManageVoiceChats: Boolean? = null, + @SerialName(canManageChatField) + private val canManageChat: Boolean? = null ) : ChatMemberRequest, UntilDate { override fun method(): String = "promoteChatMember" override val resultDeserializer: DeserializationStrategy diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt index 109f9b27cc..b3bfd4cd18 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt @@ -28,6 +28,8 @@ data class AdministratorChatMemberImpl( override val canPromoteMembers: Boolean = false, @SerialName(canManageVoiceChatsField) override val canManageVoiceChats: Boolean = false, + @SerialName(canManageChatField) + override val canManageChat: Boolean = false, @SerialName(isAnonymousField) override val isAnonymous: Boolean = false, @SerialName(customTitleField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt index a47dafd111..8344c7bb22 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt @@ -32,6 +32,8 @@ data class CreatorChatMember( override val canPromoteMembers: Boolean = true @Transient override val canManageVoiceChats: Boolean = true + @Transient + override val canManageChat: Boolean = true @SerialName(statusField) @Required private val type: String = "creator" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt index db02e9d67c..ab6e9056f6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt @@ -14,6 +14,7 @@ interface AdministratorChatMember : SpecialRightsChatMember { val canRestrictMembers: Boolean val canPromoteMembers: Boolean val canManageVoiceChats: Boolean + val canManageChat: Boolean val isAnonymous: Boolean val customTitle: String? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index bb9f787337..50a9dacdc3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -240,6 +240,7 @@ const val canRestrictMembersField = "can_restrict_members" const val canPinMessagesField = "can_pin_messages" const val canPromoteMembersField = "can_promote_members" const val canManageVoiceChatsField = "can_manage_voice_chats" +const val canManageChatField = "can_manage_chat" const val pngStickerField = "png_sticker" const val tgsStickerField = "tgs_sticker" diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt index fe05c89a8d..865fc0ee80 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt @@ -18,7 +18,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, - canManageVoiceChats: Boolean? = null + canManageVoiceChats: Boolean? = null, + canManageChat: Boolean? ) = execute( PromoteChatMember( chatId, @@ -33,7 +34,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers, canPinMessages, canPromoteMembers, - canManageVoiceChats + canManageVoiceChats, + canManageChat ) ) @@ -50,7 +52,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, - canManageVoiceChats: Boolean? + canManageVoiceChats: Boolean? = null, + canManageChat: Boolean? = null ) = promoteChatMember( chat.id, userId, @@ -64,7 +67,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers, canPinMessages, canPromoteMembers, - canManageVoiceChats + canManageVoiceChats, + canManageChat ) suspend fun TelegramBot.promoteChatMember( @@ -80,7 +84,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, - canManageVoiceChats: Boolean? + canManageVoiceChats: Boolean? = null, + canManageChat: Boolean? = null ) = promoteChatMember( chatId, user.id, @@ -94,7 +99,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers, canPinMessages, canPromoteMembers, - canManageVoiceChats + canManageVoiceChats, + canManageChat ) suspend fun TelegramBot.promoteChatMember( @@ -110,7 +116,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, - canManageVoiceChats: Boolean? + canManageVoiceChats: Boolean? = null, + canManageChat: Boolean? = null ) = promoteChatMember( chat.id, user.id, @@ -124,5 +131,6 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers, canPinMessages, canPromoteMembers, - canManageVoiceChats + canManageVoiceChats, + canManageChat )