mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
chat permissions adding
This commit is contained in:
parent
cb94a3a389
commit
394bec1805
@ -15,6 +15,7 @@ like this
|
|||||||
Changes according to [July 29, 2019 Telegram Bot API update](https://core.telegram.org/bots/api#july-29-2019):
|
Changes according to [July 29, 2019 Telegram Bot API update](https://core.telegram.org/bots/api#july-29-2019):
|
||||||
|
|
||||||
* `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
|
||||||
|
|
||||||
## 0.16.0 Bot API 4.3
|
## 0.16.0 Bot API 4.3
|
||||||
|
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SetChatPermissions (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(permissionsField)
|
||||||
|
val permissions: ChatPermissions
|
||||||
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
|
override fun method(): String = "setChatPermissions"
|
||||||
|
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
|
}
|
@ -146,6 +146,7 @@ const val isMemberField = "is_member"
|
|||||||
const val canSendMessagesField = "can_send_messages"
|
const val canSendMessagesField = "can_send_messages"
|
||||||
const val canSendMediaMessagesField = "can_send_media_messages"
|
const val canSendMediaMessagesField = "can_send_media_messages"
|
||||||
const val canSendOtherMessagesField = "can_send_other_messages"
|
const val canSendOtherMessagesField = "can_send_other_messages"
|
||||||
|
const val canSendPollsField = "can_send_polls"
|
||||||
const val canAddWebPagePreviewsField = "can_add_web_page_previews"
|
const val canAddWebPagePreviewsField = "can_add_web_page_previews"
|
||||||
|
|
||||||
const val canBeEditedField = "can_be_edited"
|
const val canBeEditedField = "can_be_edited"
|
||||||
@ -202,6 +203,7 @@ const val certificateField = "certificate"
|
|||||||
const val questionField = "question"
|
const val questionField = "question"
|
||||||
const val optionsField = "options"
|
const val optionsField = "options"
|
||||||
const val payField = "pay"
|
const val payField = "pay"
|
||||||
|
const val permissionsField = "permissions"
|
||||||
|
|
||||||
const val pointField = "point"
|
const val pointField = "point"
|
||||||
const val xShiftField = "x_shift"
|
const val xShiftField = "x_shift"
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ChatPermissions(
|
||||||
|
@SerialName(canSendMessagesField)
|
||||||
|
val canSendMessages: Boolean = false,
|
||||||
|
@SerialName(canSendMediaMessagesField)
|
||||||
|
val canSendMediaMessages: Boolean = false,
|
||||||
|
@SerialName(canSendPollsField)
|
||||||
|
val canSendPolls: Boolean = false,
|
||||||
|
@SerialName(canSendOtherMessagesField)
|
||||||
|
val canSendOtherMessages: Boolean = false,
|
||||||
|
@SerialName(canAddWebPagePreviewsField)
|
||||||
|
val canAddWebPagePreviews: Boolean = false,
|
||||||
|
@SerialName(canChangeInfoField)
|
||||||
|
val canChangeInfo: Boolean = false,
|
||||||
|
@SerialName(canInviteUsersField)
|
||||||
|
val canInviteUsers: Boolean = false,
|
||||||
|
@SerialName(canPinMessagesField)
|
||||||
|
val canPinMessages: Boolean = false
|
||||||
|
)
|
@ -11,5 +11,6 @@ data class GroupChatImpl(
|
|||||||
override val allMembersAreAdmins: Boolean,
|
override val allMembersAreAdmins: Boolean,
|
||||||
override val inviteLink: String? = null,
|
override val inviteLink: String? = null,
|
||||||
override val chatPhoto: ChatPhoto? = null,
|
override val chatPhoto: ChatPhoto? = null,
|
||||||
override val pinnedMessage: RawMessage? = null
|
override val pinnedMessage: RawMessage? = null,
|
||||||
|
override val permissions: ChatPermissions? = null
|
||||||
) : GroupChat
|
) : GroupChat
|
||||||
|
@ -21,7 +21,8 @@ data class RawChat(
|
|||||||
private val sticker_set_name: String? = null,
|
private val sticker_set_name: String? = null,
|
||||||
private val can_set_sticker_set: Boolean? = null,
|
private val can_set_sticker_set: Boolean? = null,
|
||||||
@SerialName("photo")
|
@SerialName("photo")
|
||||||
override val chatPhoto: ChatPhoto? = null
|
override val chatPhoto: ChatPhoto? = null,
|
||||||
|
private val permissions: ChatPermissions? = null
|
||||||
) : Chat {
|
) : Chat {
|
||||||
fun extractChat(): Chat {
|
fun extractChat(): Chat {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
@ -31,7 +32,9 @@ data class RawChat(
|
|||||||
title,
|
title,
|
||||||
all_members_are_administrators ?: false,
|
all_members_are_administrators ?: false,
|
||||||
invite_link,
|
invite_link,
|
||||||
chatPhoto
|
chatPhoto,
|
||||||
|
pinned_message,
|
||||||
|
permissions
|
||||||
)
|
)
|
||||||
"supergroup" -> SupergroupChat(
|
"supergroup" -> SupergroupChat(
|
||||||
id,
|
id,
|
||||||
@ -43,7 +46,8 @@ data class RawChat(
|
|||||||
chatPhoto,
|
chatPhoto,
|
||||||
pinned_message,
|
pinned_message,
|
||||||
sticker_set_name,
|
sticker_set_name,
|
||||||
can_set_sticker_set ?: false
|
can_set_sticker_set ?: false,
|
||||||
|
permissions
|
||||||
)
|
)
|
||||||
"channel" -> ChannelChat(
|
"channel" -> ChannelChat(
|
||||||
id,
|
id,
|
||||||
|
@ -15,5 +15,6 @@ data class SupergroupChat(
|
|||||||
override val chatPhoto: ChatPhoto? = null,
|
override val chatPhoto: ChatPhoto? = null,
|
||||||
override val pinnedMessage: RawMessage? = null,
|
override val pinnedMessage: RawMessage? = null,
|
||||||
val stickerSetName: String? = null,
|
val stickerSetName: String? = null,
|
||||||
val canSetStickerSet: Boolean
|
val canSetStickerSet: Boolean = false,
|
||||||
|
override val permissions: ChatPermissions? = null
|
||||||
) : GroupChat, UsernameChat, DescriptionChat
|
) : GroupChat, UsernameChat, DescriptionChat
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
|
|
||||||
interface GroupChat : PublicChat {
|
interface GroupChat : PublicChat {
|
||||||
val allMembersAreAdmins: Boolean
|
val allMembersAreAdmins: Boolean
|
||||||
|
val permissions: ChatPermissions?
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user