1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-25 19:48:43 +00:00

BotCommand checks

This commit is contained in:
InsanusMokrassar 2020-04-01 10:08:44 +06:00
parent e85d5df03e
commit a6aa4b8758
3 changed files with 15 additions and 2 deletions

View File

@ -40,6 +40,9 @@
### 0.26.1
* `TelegramBotAPI`:
* `BotCommand` now will check and throw error in case when command or description lengths is/are incorrect
## 0.25.0
* Common:

View File

@ -9,4 +9,13 @@ data class BotCommand(
val command: String,
@SerialName(descriptionField)
val description: String
)
) {
init {
if (command.length !in botCommandLengthLimit) {
error("Command size must be in range $botCommandLengthLimit, but actually have length ${command.length}")
}
if (description.length !in botCommandDescriptionLimit) {
error("Command description size must be in range $botCommandDescriptionLimit, but actually have length ${description.length}")
}
}
}

View File

@ -49,7 +49,8 @@ val customTitleLength = 0 .. 16
val diceResultLimit = 1 .. 6
val botCommandLimit = 1 .. 32
val botCommandLengthLimit = 1 .. 32
val botCommandLimit = botCommandLengthLimit
val botCommandDescriptionLimit = 3 .. 256
val botCommandsLimit = 0 .. 100