From 09bbb1945cc1b359d2cc616d9f07bc4206cac9c8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Oct 2020 20:12:18 +0600 Subject: [PATCH 1/9] start 0.29.2 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3ee49eeb6..713dcc62fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.29.2 + ## 0.29.1 * `Common`: diff --git a/gradle.properties b/gradle.properties index a07f5a51b1..0dec4fd5e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ ktor_version=1.4.1 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.29.1 +library_version=0.29.2 gradle_bintray_plugin_version=1.8.5 github_release_plugin_version=2.2.12 From 4f9cb531c04735d527de2b418f79d681d806729b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Oct 2020 20:25:26 +0600 Subject: [PATCH 2/9] add slot machine, but currently it is not working --- CHANGELOG.md | 3 +++ .../kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 713dcc62fc..ba91cae384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.29.2 +* `Core`: + * New dice type `SlotMachineDiceAnimationType` + ## 0.29.1 * `Common`: 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 806e43d16f..89ea0878cf 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 @@ -22,6 +22,10 @@ object BasketballDiceAnimationType : DiceAnimationType() { override val emoji: String = "\uD83C\uDFC0" } @Serializable(DiceAnimationTypeSerializer::class) +object SlotMachineDiceAnimationType : DiceAnimationType() { + override val emoji: String = "\uD83C\uDFB0" +} +@Serializable(DiceAnimationTypeSerializer::class) data class CustomDiceAnimationType( override val emoji: String ) : DiceAnimationType() @@ -34,6 +38,7 @@ internal object DiceAnimationTypeSerializer : KSerializer { CubeDiceAnimationType.emoji -> CubeDiceAnimationType DartsDiceAnimationType.emoji -> DartsDiceAnimationType BasketballDiceAnimationType.emoji -> BasketballDiceAnimationType + SlotMachineDiceAnimationType.emoji -> BasketballDiceAnimationType else -> CustomDiceAnimationType(type) } } From f317e144e672c970986f039ede71d89dff13a9e8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Oct 2020 14:53:22 +0600 Subject: [PATCH 3/9] Revert "add slot machine, but currently it is not working" This reverts commit 4f9cb531c04735d527de2b418f79d681d806729b. --- CHANGELOG.md | 3 --- .../kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt | 5 ----- 2 files changed, 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba91cae384..713dcc62fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,6 @@ ## 0.29.2 -* `Core`: - * New dice type `SlotMachineDiceAnimationType` - ## 0.29.1 * `Common`: 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 89ea0878cf..806e43d16f 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 @@ -22,10 +22,6 @@ object BasketballDiceAnimationType : DiceAnimationType() { override val emoji: String = "\uD83C\uDFC0" } @Serializable(DiceAnimationTypeSerializer::class) -object SlotMachineDiceAnimationType : DiceAnimationType() { - override val emoji: String = "\uD83C\uDFB0" -} -@Serializable(DiceAnimationTypeSerializer::class) data class CustomDiceAnimationType( override val emoji: String ) : DiceAnimationType() @@ -38,7 +34,6 @@ internal object DiceAnimationTypeSerializer : KSerializer { CubeDiceAnimationType.emoji -> CubeDiceAnimationType DartsDiceAnimationType.emoji -> DartsDiceAnimationType BasketballDiceAnimationType.emoji -> BasketballDiceAnimationType - SlotMachineDiceAnimationType.emoji -> BasketballDiceAnimationType else -> CustomDiceAnimationType(type) } } From d8dbbdf549a02299dd39b774c21ef00ed25e500a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Oct 2020 15:01:30 +0600 Subject: [PATCH 4/9] update coroutines --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 713dcc62fc..dae596bb51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.29.2 +* `Common`: + * Version updates: + * `Coroutines`: `1.3.9` -> `1.4.0` + ## 0.29.1 * `Common`: diff --git a/gradle.properties b/gradle.properties index 0dec4fd5e8..efe61a1257 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ kotlin.incremental=true kotlin.incremental.js=true kotlin_version=1.4.10 -kotlin_coroutines_version=1.3.9 +kotlin_coroutines_version=1.4.0 kotlin_serialisation_runtime_version=1.0.0 klock_version=1.12.1 uuid_version=0.2.2 From 6d782f28c327f93234ecba8e4f6d0670dd228a43 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Oct 2020 15:11:57 +0600 Subject: [PATCH 5/9] updates after coroutines version change --- CHANGELOG.md | 3 +++ .../inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt | 7 +++---- .../dev/inmo/tgbotapi/utils/extensions/ReceiveChannel.kt | 1 + .../dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dae596bb51..0c3b61ffa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ * `Common`: * Version updates: * `Coroutines`: `1.3.9` -> `1.4.0` + * Internal broadcast channels were replaced with `SharedFlow` +* `TelegramBotAPI-extensions-utils`: + * Extension `ReceiveChannel#debounceByValue` has been deprecated ## 0.29.1 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt index 616fa4bfce..1e8adcf5f0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt @@ -5,21 +5,20 @@ import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.* import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.flow.* @Suppress("EXPERIMENTAL_API_USAGE", "unused") class FlowsUpdatesFilter( broadcastChannelsSize: Int = 100 ): UpdatesFilter { - private val updatesReceivingChannel = BroadcastChannel(broadcastChannelsSize) + private val updatesSharedFlow = MutableSharedFlow(extraBufferCapacity = broadcastChannelsSize) @Suppress("MemberVisibilityCanBePrivate") - val allUpdatesFlow: Flow = updatesReceivingChannel.asFlow() + val allUpdatesFlow: Flow = updatesSharedFlow.asSharedFlow() override val allowedUpdates: List get() = ALL_UPDATES_LIST override val asUpdateReceiver: UpdateReceiver = { - updatesReceivingChannel.send(it) + updatesSharedFlow.emit(it) } val messageFlow: Flow = allUpdatesFlow.filterIsInstance() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ReceiveChannel.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ReceiveChannel.kt index fe239ed191..4094709bce 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ReceiveChannel.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ReceiveChannel.kt @@ -11,6 +11,7 @@ private sealed class DebounceAction { private data class AddValue(override val value: T) : DebounceAction() private data class RemoveJob(override val value: T, val job: Job) : DebounceAction() +@Deprecated("Unused and will be removed in next major release") fun ReceiveChannel.debounceByValue( delayMillis: Long, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt index 3eb1b9f88b..49e717f89e 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt @@ -13,10 +13,11 @@ fun aggregateFlows( vararg flows: Flow, internalBufferSize: Int = Channel.BUFFERED ): Flow { + val sharedFlow = MutableSharedFlow(extraBufferCapacity = internalBufferSize) val bc = BroadcastChannel(internalBufferSize) flows.forEach { it.onEach { - safely { bc.send(it) } + safely { sharedFlow.emit(it) } }.launchIn(withScope) } return bc.asFlow() From 87d2537bda0f78260eb4ada33ab7a552687cb358 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Oct 2020 15:14:45 +0600 Subject: [PATCH 6/9] update greetings config --- .github/workflows/greetings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index bdde1cca7b..48687e51e4 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -4,7 +4,7 @@ on: [pull_request, issues] jobs: greeting: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 steps: - uses: actions/first-interaction@v1 with: From 23a1fed7dd4f6cab626b5e374ee8ab04e5ddc1e9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Oct 2020 15:16:04 +0600 Subject: [PATCH 7/9] Revert "update greetings config" This reverts commit 87d2537bda0f78260eb4ada33ab7a552687cb358. --- .github/workflows/greetings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 48687e51e4..bdde1cca7b 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -4,7 +4,7 @@ on: [pull_request, issues] jobs: greeting: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - uses: actions/first-interaction@v1 with: From b053c29ea32e7ab5229f1841128d4ea0253acd8d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Oct 2020 15:26:32 +0600 Subject: [PATCH 8/9] update aggregateFlows --- .../dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt index 49e717f89e..b3149217cb 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.extensions.utils import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.BroadcastChannel -import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.* /** @@ -11,7 +10,7 @@ import kotlinx.coroutines.flow.* fun aggregateFlows( withScope: CoroutineScope, vararg flows: Flow, - internalBufferSize: Int = Channel.BUFFERED + internalBufferSize: Int = 64 ): Flow { val sharedFlow = MutableSharedFlow(extraBufferCapacity = internalBufferSize) val bc = BroadcastChannel(internalBufferSize) From 37a23c7e79da8bcc775fecc1cd3ee2da804e6108 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Oct 2020 15:51:48 +0600 Subject: [PATCH 9/9] fixes in aggregation of flows --- .../dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt index b3149217cb..bf4c4b8f74 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt @@ -13,13 +13,12 @@ fun aggregateFlows( internalBufferSize: Int = 64 ): Flow { val sharedFlow = MutableSharedFlow(extraBufferCapacity = internalBufferSize) - val bc = BroadcastChannel(internalBufferSize) flows.forEach { it.onEach { safely { sharedFlow.emit(it) } }.launchIn(withScope) } - return bc.asFlow() + return sharedFlow } fun Flow>.flatMap(): Flow = flow {