1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-21 14:55:44 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
eb08732938 add travis dokka step 2020-10-19 19:48:17 +06:00
6 changed files with 12 additions and 20 deletions

View File

@@ -1,14 +1,5 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 0.29.2
* `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 ## 0.29.1
* `Common`: * `Common`:

View File

@@ -74,7 +74,7 @@ kotlin {
![Libraries hierarchy](resources/TelegramBotAPI-libraries-hierarchy.svg) ![Libraries hierarchy](resources/TelegramBotAPI-libraries-hierarchy.svg)
In most cases, the most simple way will be to implement [TelegramBotAPI](tgbotapi/README.md) - it contains In most cases, the most simple way will be to implement [TelegramBotAPI](TelegramBotAPI/README.md) - it contains
all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just
[TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md), [TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md),
[TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) or even [TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) or even

View File

@@ -6,7 +6,7 @@ kotlin.incremental=true
kotlin.incremental.js=true kotlin.incremental.js=true
kotlin_version=1.4.10 kotlin_version=1.4.10
kotlin_coroutines_version=1.4.0 kotlin_coroutines_version=1.3.9
kotlin_serialisation_runtime_version=1.0.0 kotlin_serialisation_runtime_version=1.0.0
klock_version=1.12.1 klock_version=1.12.1
uuid_version=0.2.2 uuid_version=0.2.2
@@ -15,7 +15,7 @@ ktor_version=1.4.1
javax_activation_version=1.1.1 javax_activation_version=1.1.1
library_group=dev.inmo library_group=dev.inmo
library_version=0.29.2 library_version=0.29.1
gradle_bintray_plugin_version=1.8.5 gradle_bintray_plugin_version=1.8.5
github_release_plugin_version=2.2.12 github_release_plugin_version=2.2.12

View File

@@ -5,20 +5,21 @@ import dev.inmo.tgbotapi.types.update.*
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.* import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.*
import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate
import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.types.update.abstracts.Update
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
@Suppress("EXPERIMENTAL_API_USAGE", "unused") @Suppress("EXPERIMENTAL_API_USAGE", "unused")
class FlowsUpdatesFilter( class FlowsUpdatesFilter(
broadcastChannelsSize: Int = 100 broadcastChannelsSize: Int = 100
): UpdatesFilter { ): UpdatesFilter {
private val updatesSharedFlow = MutableSharedFlow<Update>(extraBufferCapacity = broadcastChannelsSize) private val updatesReceivingChannel = BroadcastChannel<Update>(broadcastChannelsSize)
@Suppress("MemberVisibilityCanBePrivate") @Suppress("MemberVisibilityCanBePrivate")
val allUpdatesFlow: Flow<Update> = updatesSharedFlow.asSharedFlow() val allUpdatesFlow: Flow<Update> = updatesReceivingChannel.asFlow()
override val allowedUpdates: List<String> override val allowedUpdates: List<String>
get() = ALL_UPDATES_LIST get() = ALL_UPDATES_LIST
override val asUpdateReceiver: UpdateReceiver<Update> = { override val asUpdateReceiver: UpdateReceiver<Update> = {
updatesSharedFlow.emit(it) updatesReceivingChannel.send(it)
} }
val messageFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance() val messageFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance()

View File

@@ -11,7 +11,6 @@ private sealed class DebounceAction<T> {
private data class AddValue<T>(override val value: T) : DebounceAction<T>() private data class AddValue<T>(override val value: T) : DebounceAction<T>()
private data class RemoveJob<T>(override val value: T, val job: Job) : DebounceAction<T>() private data class RemoveJob<T>(override val value: T, val job: Job) : DebounceAction<T>()
@Deprecated("Unused and will be removed in next major release")
fun <T> ReceiveChannel<T>.debounceByValue( fun <T> ReceiveChannel<T>.debounceByValue(
delayMillis: Long, delayMillis: Long,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default), scope: CoroutineScope = CoroutineScope(Dispatchers.Default),

View File

@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
/** /**
@@ -10,15 +11,15 @@ import kotlinx.coroutines.flow.*
fun <T> aggregateFlows( fun <T> aggregateFlows(
withScope: CoroutineScope, withScope: CoroutineScope,
vararg flows: Flow<T>, vararg flows: Flow<T>,
internalBufferSize: Int = 64 internalBufferSize: Int = Channel.BUFFERED
): Flow<T> { ): Flow<T> {
val sharedFlow = MutableSharedFlow<T>(extraBufferCapacity = internalBufferSize) val bc = BroadcastChannel<T>(internalBufferSize)
flows.forEach { flows.forEach {
it.onEach { it.onEach {
safely { sharedFlow.emit(it) } safely { bc.send(it) }
}.launchIn(withScope) }.launchIn(withScope)
} }
return sharedFlow return bc.asFlow()
} }
fun <T> Flow<Iterable<T>>.flatMap(): Flow<T> = flow { fun <T> Flow<Iterable<T>>.flatMap(): Flow<T> = flow {