1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

DiceAnimationType#valueLimits

This commit is contained in:
InsanusMokrassar 2020-11-04 23:52:22 +06:00
parent 6a05a7ecab
commit 609a959b99
3 changed files with 30 additions and 8 deletions

View File

@ -19,6 +19,9 @@
* New fields `SendDocument#disableContentTypeDetection` and `InputMediaDocument#disableContentTypeDetection` * New fields `SendDocument#disableContentTypeDetection` and `InputMediaDocument#disableContentTypeDetection`
* New request `UnpinAllChatMessages` * New request `UnpinAllChatMessages`
* New dice type `FootballDiceAnimationType` * New dice type `FootballDiceAnimationType`
* Limits for dices has been changed
* `commonDiceResultLimit` has been deprecated
* New field `DiceAnimationType#valueLimits`
* `API`: * `API`:
* Extensions `TelegramBot#pinChatMessage` now support any `Chat` and `Message`s from any `Chat` * Extensions `TelegramBot#pinChatMessage` now support any `Chat` and `Message`s from any `Chat`
* New extensions `TelegramBot#unpinAllChatMessages` * New extensions `TelegramBot#unpinAllChatMessages`

View File

@ -52,10 +52,14 @@ val inlineQueryAnswerResultsLimit = 0 .. 50
val customTitleLength = 0 .. 16 val customTitleLength = 0 .. 16
val commonDiceResultLimit = 1 .. 6 val dartsAndCubeDiceResultLimit = 1 .. 6
@Deprecated("Renamed", ReplaceWith("commonDiceResultLimit", "dev.inmo.tgbotapi.types.commonDiceResultLimit")) @Deprecated("Renamed", ReplaceWith("dartsAndCubeDiceResultLimit", "dev.inmo.tgbotapi.types.dartsAndCubeDiceResultLimit"))
val commonDiceResultLimit
get() = dartsAndCubeDiceResultLimit
@Deprecated("Renamed", ReplaceWith("dartsAndCubeDiceResultLimit", "dev.inmo.tgbotapi.types.dartsAndCubeDiceResultLimit"))
val diceResultLimit val diceResultLimit
get() = commonDiceResultLimit get() = dartsAndCubeDiceResultLimit
val basketballAndFootballDiceResultLimit = 1 .. 5
val slotMachineDiceResultLimit = 1 .. 64 val slotMachineDiceResultLimit = 1 .. 64
val botCommandLengthLimit = 1 .. 32 val botCommandLengthLimit = 1 .. 32

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.dice package dev.inmo.tgbotapi.types.dice
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.* import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
@ -8,31 +9,45 @@ import kotlinx.serialization.encoding.Encoder
@Serializable(DiceAnimationTypeSerializer::class) @Serializable(DiceAnimationTypeSerializer::class)
sealed class DiceAnimationType { sealed class DiceAnimationType {
abstract val emoji: String abstract val emoji: String
abstract val valueLimits: IntRange
} }
@Serializable(DiceAnimationTypeSerializer::class) @Serializable(DiceAnimationTypeSerializer::class)
object CubeDiceAnimationType : DiceAnimationType() { object CubeDiceAnimationType : DiceAnimationType() {
override val emoji: String = "\uD83C\uDFB2" override val emoji: String = "\uD83C\uDFB2"
override val valueLimits: IntRange
get() = dartsAndCubeDiceResultLimit
} }
@Serializable(DiceAnimationTypeSerializer::class) @Serializable(DiceAnimationTypeSerializer::class)
object DartsDiceAnimationType : DiceAnimationType() { object DartsDiceAnimationType : DiceAnimationType() {
override val emoji: String = "\uD83C\uDFAF" override val emoji: String = "\uD83C\uDFAF"
override val valueLimits: IntRange
get() = dartsAndCubeDiceResultLimit
} }
@Serializable(DiceAnimationTypeSerializer::class) @Serializable(DiceAnimationTypeSerializer::class)
object BasketballDiceAnimationType : DiceAnimationType() { object BasketballDiceAnimationType : DiceAnimationType() {
override val emoji: String = "\uD83C\uDFC0" override val emoji: String = "\uD83C\uDFC0"
} override val valueLimits: IntRange
@Serializable(DiceAnimationTypeSerializer::class) get() = basketballAndFootballDiceResultLimit
object SlotMachineDiceAnimationType : DiceAnimationType() {
override val emoji: String = "\uD83C\uDFB0"
} }
@Serializable(DiceAnimationTypeSerializer::class) @Serializable(DiceAnimationTypeSerializer::class)
object FootballDiceAnimationType : DiceAnimationType() { object FootballDiceAnimationType : DiceAnimationType() {
override val emoji: String = "" override val emoji: String = ""
override val valueLimits: IntRange
get() = basketballAndFootballDiceResultLimit
}
@Serializable(DiceAnimationTypeSerializer::class)
object SlotMachineDiceAnimationType : DiceAnimationType() {
override val emoji: String = "\uD83C\uDFB0"
override val valueLimits: IntRange
get() = slotMachineDiceResultLimit
} }
@Serializable(DiceAnimationTypeSerializer::class) @Serializable(DiceAnimationTypeSerializer::class)
data class CustomDiceAnimationType( data class CustomDiceAnimationType(
override val emoji: String override val emoji: String
) : DiceAnimationType() ) : DiceAnimationType() {
override val valueLimits: IntRange
get() = error("Custom dice animation type have unknown value limits")
}
@Serializer(DiceAnimationType::class) @Serializer(DiceAnimationType::class)
internal object DiceAnimationTypeSerializer : KSerializer<DiceAnimationType> { internal object DiceAnimationTypeSerializer : KSerializer<DiceAnimationType> {