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

add restrictions check in SetChatAdministratorCustomTitle

This commit is contained in:
InsanusMokrassar 2020-01-01 21:56:53 +06:00
parent 47428dd6f9
commit 5ee472305c
2 changed files with 13 additions and 2 deletions

View File

@ -1,12 +1,15 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import kotlinx.serialization.*
import kotlinx.serialization.internal.BooleanSerializer
/**
* Representation of https://core.telegram.org/bots/api#setchatadministratorcustomtitle
*
* Please, remember about restrictions for characters in custom title
*/
@Serializable
data class SetChatAdministratorCustomTitle(
@SerialName(chatIdField)
@ -21,4 +24,10 @@ data class SetChatAdministratorCustomTitle(
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = RestrictChatMember.serializer()
init {
if (customTitle.length !in customTitleLength) {
throw IllegalArgumentException("Custom title length must be in range $customTitleLength, but was ${customTitle.length}")
}
}
}

View File

@ -40,6 +40,8 @@ val livePeriodLimit = 60 .. 86400
val inlineQueryAnswerResultsLimit = 0 .. 50
val customTitleLength = 0 .. 16
const val chatIdField = "chat_id"
const val messageIdField = "message_id"
const val updateIdField = "update_id"