mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 07:09:23 +00:00
add restrictions check in SetChatAdministratorCustomTitle
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
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.requests.chat.abstracts.ChatMemberRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of https://core.telegram.org/bots/api#setchatadministratorcustomtitle
|
||||||
|
*
|
||||||
|
* Please, remember about restrictions for characters in custom title
|
||||||
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetChatAdministratorCustomTitle(
|
data class SetChatAdministratorCustomTitle(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@@ -21,4 +24,10 @@ data class SetChatAdministratorCustomTitle(
|
|||||||
get() = BooleanSerializer
|
get() = BooleanSerializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = RestrictChatMember.serializer()
|
get() = RestrictChatMember.serializer()
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (customTitle.length !in customTitleLength) {
|
||||||
|
throw IllegalArgumentException("Custom title length must be in range $customTitleLength, but was ${customTitle.length}")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -40,6 +40,8 @@ val livePeriodLimit = 60 .. 86400
|
|||||||
|
|
||||||
val inlineQueryAnswerResultsLimit = 0 .. 50
|
val inlineQueryAnswerResultsLimit = 0 .. 50
|
||||||
|
|
||||||
|
val customTitleLength = 0 .. 16
|
||||||
|
|
||||||
const val chatIdField = "chat_id"
|
const val chatIdField = "chat_id"
|
||||||
const val messageIdField = "message_id"
|
const val messageIdField = "message_id"
|
||||||
const val updateIdField = "update_id"
|
const val updateIdField = "update_id"
|
||||||
|
Reference in New Issue
Block a user