diff --git a/CHANGELOG.md b/CHANGELOG.md index aa450c184c..f39c66dac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ * New fields `SendDocument#disableContentTypeDetection` and `InputMediaDocument#disableContentTypeDetection` * New request `UnpinAllChatMessages` * New dice type `FootballDiceAnimationType` + * Limits for dices has been changed + * `commonDiceResultLimit` has been deprecated + * New field `DiceAnimationType#valueLimits` * `API`: * Extensions `TelegramBot#pinChatMessage` now support any `Chat` and `Message`s from any `Chat` * New extensions `TelegramBot#unpinAllChatMessages` diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index f56da81409..c113b6be23 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -52,10 +52,14 @@ val inlineQueryAnswerResultsLimit = 0 .. 50 val customTitleLength = 0 .. 16 -val commonDiceResultLimit = 1 .. 6 -@Deprecated("Renamed", ReplaceWith("commonDiceResultLimit", "dev.inmo.tgbotapi.types.commonDiceResultLimit")) +val dartsAndCubeDiceResultLimit = 1 .. 6 +@Deprecated("Renamed", ReplaceWith("dartsAndCubeDiceResultLimit", "dev.inmo.tgbotapi.types.dartsAndCubeDiceResultLimit")) +val commonDiceResultLimit + get() = dartsAndCubeDiceResultLimit +@Deprecated("Renamed", ReplaceWith("dartsAndCubeDiceResultLimit", "dev.inmo.tgbotapi.types.dartsAndCubeDiceResultLimit")) val diceResultLimit - get() = commonDiceResultLimit + get() = dartsAndCubeDiceResultLimit +val basketballAndFootballDiceResultLimit = 1 .. 5 val slotMachineDiceResultLimit = 1 .. 64 val botCommandLengthLimit = 1 .. 32 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt index 04b1ac0576..7a79ba36dd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.dice +import dev.inmo.tgbotapi.types.* import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder @@ -8,31 +9,45 @@ import kotlinx.serialization.encoding.Encoder @Serializable(DiceAnimationTypeSerializer::class) sealed class DiceAnimationType { abstract val emoji: String + abstract val valueLimits: IntRange } @Serializable(DiceAnimationTypeSerializer::class) object CubeDiceAnimationType : DiceAnimationType() { override val emoji: String = "\uD83C\uDFB2" + override val valueLimits: IntRange + get() = dartsAndCubeDiceResultLimit } @Serializable(DiceAnimationTypeSerializer::class) object DartsDiceAnimationType : DiceAnimationType() { override val emoji: String = "\uD83C\uDFAF" + override val valueLimits: IntRange + get() = dartsAndCubeDiceResultLimit } @Serializable(DiceAnimationTypeSerializer::class) object BasketballDiceAnimationType : DiceAnimationType() { override val emoji: String = "\uD83C\uDFC0" -} -@Serializable(DiceAnimationTypeSerializer::class) -object SlotMachineDiceAnimationType : DiceAnimationType() { - override val emoji: String = "\uD83C\uDFB0" + override val valueLimits: IntRange + get() = basketballAndFootballDiceResultLimit } @Serializable(DiceAnimationTypeSerializer::class) object FootballDiceAnimationType : DiceAnimationType() { 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) data class CustomDiceAnimationType( override val emoji: String -) : DiceAnimationType() +) : DiceAnimationType() { + override val valueLimits: IntRange + get() = error("Custom dice animation type have unknown value limits") +} @Serializer(DiceAnimationType::class) internal object DiceAnimationTypeSerializer : KSerializer {