From f0eb670c3f4cbf152fefd6ff2a995f12909c4b3f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Feb 2021 13:47:31 +0600 Subject: [PATCH 1/4] start 0.32.6 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c4afa347e..c12691ca62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.32.6 + ## 0.32.5 * `Core`: diff --git a/gradle.properties b/gradle.properties index 766ffc876a..767df09b36 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.24 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.32.5 +library_version=0.32.6 github_release_plugin_version=2.2.12 From f8b3c441469a86ad270e470366ff5d5088d80a39 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Feb 2021 13:48:32 +0600 Subject: [PATCH 2/4] update micro_utils --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c12691ca62..8aefe807ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.32.6 +* `Common`: + * `Version`: + * `MicroUtils`: `0.4.24` -> `0.4.25` + ## 0.32.5 * `Core`: diff --git a/gradle.properties b/gradle.properties index 767df09b36..3fdf6502e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.0.6 uuid_version=0.2.3 ktor_version=1.5.1 -micro_utils_version=0.4.24 +micro_utils_version=0.4.25 javax_activation_version=1.1.1 From 41b4d29917b8e9c39b725c84ecc5afd1cc387a25 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 17 Feb 2021 16:58:57 +0600 Subject: [PATCH 3/4] updates in slot machine utils --- CHANGELOG.md | 4 +++ .../extensions/utils/SlotMachineUtils.kt | 30 ++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aefe807ff..677ec2f80b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ * `Common`: * `Version`: * `MicroUtils`: `0.4.24` -> `0.4.25` +* `Extensions Utils`: + * `SlotMachineReelImages` has been renamed to `SlotMachineReelImage` + * `SlotMachineReelImage` got two built-in parameters: `text` and `number` + * New extension `String.asSlotMachineReelImage` ## 0.32.5 diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt index 4ac9cd338e..82fcdb7e77 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt @@ -6,16 +6,30 @@ import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType import kotlinx.serialization.Serializable import kotlinx.serialization.Transient -enum class SlotMachineReelImages { - BAR, BERRIES, LEMON, SEVEN +/** + * @param text Is a text representation + * @param number Internal representation of reel + */ +enum class SlotMachineReelImage(val text: String, val number: Int) { + BAR("[bar]", 0), + BERRIES("\uD83C\uDF52", 1), + LEMON("\uD83C\uDF4B", 2), + SEVEN("7", 3) } +@Deprecated("Renamed", ReplaceWith("SlotMachineReelImage", "dev.inmo.tgbotapi.extensions.utils.SlotMachineReelImage")) +typealias SlotMachineReelImages = SlotMachineReelImage + +/** + * @return First [SlotMachineReelImage] with [SlotMachineReelImage.number] equal to receiver OR [SlotMachineReelImage.SEVEN] + */ val Int.asSlotMachineReelImage - get() = when (this) { - 0 -> SlotMachineReelImages.BAR - 1 -> SlotMachineReelImages.BERRIES - 2 -> SlotMachineReelImages.LEMON - else -> SlotMachineReelImages.SEVEN - } + get() = SlotMachineReelImage.values().firstOrNull { it.number == this } ?: SlotMachineReelImage.SEVEN + +/** + * @return First [SlotMachineReelImage] with [SlotMachineReelImage.text] equal to receiver OR [SlotMachineReelImage.SEVEN] + */ +val String.asSlotMachineReelImage + get() = SlotMachineReelImage.values().firstOrNull { it.text == this } ?: SlotMachineReelImage.SEVEN @Serializable data class SlotMachineResult( From 841ae73f7c7eb88109f457b0714904c782617221 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 17 Feb 2021 17:10:21 +0600 Subject: [PATCH 4/4] replyWithDice --- CHANGELOG.md | 4 +++- .../dev/inmo/tgbotapi/extensions/api/send/SendDice.kt | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 677ec2f80b..47cf1ffcc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,12 @@ * `Common`: * `Version`: * `MicroUtils`: `0.4.24` -> `0.4.25` +* `Extensions API`: + * New extension `TelegramBot#replyWithDice` * `Extensions Utils`: * `SlotMachineReelImages` has been renamed to `SlotMachineReelImage` * `SlotMachineReelImage` got two built-in parameters: `text` and `number` - * New extension `String.asSlotMachineReelImage` + * New extension `String#asSlotMachineReelImage` ## 0.32.5 diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt index 250f55d88a..ff3ee673d4 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt @@ -29,10 +29,18 @@ suspend fun TelegramBot.sendDice( replyMarkup: KeyboardMarkup? = null ) = sendDice(chat.id, animationType, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) -suspend inline fun TelegramBot.reply( +suspend inline fun TelegramBot.replyWithDice( to: Message, animationType: DiceAnimationType? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendDice(to.chat, animationType, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + animationType: DiceAnimationType? = null, + disableNotification: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = replyWithDice(to, animationType, disableNotification, allowSendingWithoutReply, replyMarkup)