1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

add opportunity to set up media groups devounce time

This commit is contained in:
InsanusMokrassar 2020-05-15 16:53:21 +06:00
parent 1f20ae16aa
commit ea40474c47

View File

@ -17,12 +17,13 @@ import kotlinx.coroutines.launch
* @see UpdateReceiver * @see UpdateReceiver
*/ */
fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation( fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(
output: UpdateReceiver<Update> output: UpdateReceiver<Update>,
mediaGroupsDebounceMillis: Long = 1000L
): UpdateReceiver<Update> { ): UpdateReceiver<Update> {
val updatesChannel = Channel<Update>(Channel.UNLIMITED) val updatesChannel = Channel<Update>(Channel.UNLIMITED)
val mediaGroupChannel = Channel<Pair<String, BaseMessageUpdate>>(Channel.UNLIMITED) val mediaGroupChannel = Channel<Pair<String, BaseMessageUpdate>>(Channel.UNLIMITED)
val mediaGroupAccumulatedChannel = mediaGroupChannel.accumulateByKey( val mediaGroupAccumulatedChannel = mediaGroupChannel.accumulateByKey(
1000L, mediaGroupsDebounceMillis,
scope = this scope = this
) )