1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

chat members fields and restrict chat member request updates

This commit is contained in:
InsanusMokrassar 2019-08-12 14:09:14 +06:00
parent 6310dceacf
commit 8fbda09d24
13 changed files with 44 additions and 21 deletions

View File

@ -17,6 +17,9 @@ Changes according to [July 29, 2019 Telegram Bot API update](https://core.telegr
* `Sticker` and `StickerSet` now have field `isAnimated` * `Sticker` and `StickerSet` now have field `isAnimated`
* `ChatPermissions` object was added, `GroupChat` interface got `permissions` field, request `SetChatPermissions` was added * `ChatPermissions` object was added, `GroupChat` interface got `permissions` field, request `SetChatPermissions` was added
* `GroupChat` object now have no field `allMembersAreAdmins` * `GroupChat` object now have no field `allMembersAreAdmins`
* `SpecialRightsChatMember` was added for administrators and restricted members rights union, chat members abstractions
was replaced into `abstracts` package and available permissions was updated
* `RestrictChatMember` request now accept `permissions` object instead of separated permissions
## 0.16.0 Bot API 4.3 ## 0.16.0 Bot API 4.3

View File

@ -3,6 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.internal.BooleanSerializer import kotlinx.serialization.internal.BooleanSerializer
@ -14,14 +15,8 @@ data class RestrictChatMember(
override val userId: UserId, override val userId: UserId,
@SerialName(untilDateField) @SerialName(untilDateField)
override val untilDate: TelegramDate? = null, override val untilDate: TelegramDate? = null,
@SerialName(canSendMessagesField) @SerialName(permissionsField)
private val canSendMessages: Boolean? = null, val permissions: ChatPermissions
@SerialName(canSendMediaMessagesField)
private val canSendMediaMessages: Boolean? = null,
@SerialName(canSendOtherMessagesField)
private val canSendOtherMessages: Boolean? = null,
@SerialName(canAddWebPagePreviewsField)
private val canAddWebPagePreviews: Boolean? = null
) : ChatMemberRequest<Boolean>, UntilDate { ) : ChatMemberRequest<Boolean>, UntilDate {
override fun method(): String = "restrictChatMember" override fun method(): String = "restrictChatMember"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.User
data class AdministratorChatMemberImpl( data class AdministratorChatMemberImpl(

View File

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

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.BannedChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate
import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.User

View File

@ -1,5 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.User
data class LeftChatMember(override val user: User) : ChatMember data class LeftChatMember(override val user: User) :
ChatMember

View File

@ -1,5 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.User
data class MemberChatMember(override val user: User) : ChatMember data class MemberChatMember(override val user: User) :
ChatMember

View File

@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
import kotlinx.serialization.* import kotlinx.serialization.*
@Serializable @Serializable
@ -32,6 +33,8 @@ data class RawChatMember(
private val canSendMessages: Boolean = false, private val canSendMessages: Boolean = false,
@SerialName(canSendMediaMessagesField) @SerialName(canSendMediaMessagesField)
private val canSendMediaMessages: Boolean = false, private val canSendMediaMessages: Boolean = false,
@SerialName(canSendPollsField)
private val canSendPolls: Boolean = false,
@SerialName(canSendOtherMessagesField) @SerialName(canSendOtherMessagesField)
private val canSendOtherMessages: Boolean = false, private val canSendOtherMessages: Boolean = false,
@SerialName(canAddWebPagePreviewsField) @SerialName(canAddWebPagePreviewsField)
@ -60,8 +63,12 @@ data class RawChatMember(
isMember, isMember,
canSendMessages, canSendMessages,
canSendMediaMessages, canSendMediaMessages,
canSendPolls,
canSendOtherMessages, canSendOtherMessages,
canAddWebPagePreviews canAddWebPagePreviews,
canChangeInfo,
canInviteUsers,
canPinMessages
) )
"left" -> LeftChatMember(user) "left" -> LeftChatMember(user)
"kicked" -> KickedChatMember( "kicked" -> KickedChatMember(

View File

@ -1,5 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.BannedChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.SpecialRightsChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate
import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.User
@ -9,6 +11,10 @@ data class RestrictedChatMember(
val isMember: Boolean, val isMember: Boolean,
val canSendMessages: Boolean, val canSendMessages: Boolean,
val canSendMediaMessages: Boolean, val canSendMediaMessages: Boolean,
val canSendPolls: Boolean,
val canSendOtherMessages: Boolean, val canSendOtherMessages: Boolean,
val canAddWebpagePreviews: Boolean val canAddWebpagePreviews: Boolean,
) : BannedChatMember override val canChangeInfo: Boolean,
override val canInviteUsers: Boolean,
override val canPinMessages: Boolean
) : BannedChatMember, SpecialRightsChatMember

View File

@ -1,13 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
interface AdministratorChatMember : ChatMember { interface AdministratorChatMember : SpecialRightsChatMember {
val canBeEdited: Boolean val canBeEdited: Boolean
val canChangeInfo: Boolean
val canPostMessages: Boolean val canPostMessages: Boolean
val canEditMessages: Boolean val canEditMessages: Boolean
val canRemoveMessages: Boolean val canRemoveMessages: Boolean
val canInviteUsers: Boolean
val canRestrictMembers: Boolean val canRestrictMembers: Boolean
val canPinMessages: Boolean
val canPromoteMembers: Boolean val canPromoteMembers: Boolean
} }

View File

@ -1,4 +1,4 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate

View File

@ -1,4 +1,4 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.User

View File

@ -0,0 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
interface SpecialRightsChatMember : ChatMember {
val canChangeInfo: Boolean
val canInviteUsers: Boolean
val canPinMessages: Boolean
}