1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00
This commit is contained in:
InsanusMokrassar 2023-03-01 12:38:50 +06:00
parent 5a456bcdbf
commit 017d57e5e5

View File

@ -55,12 +55,17 @@ fun TelegramBot.longPollingFlow(
val updatesHandler: (suspend (List<Update>) -> Unit) = if (mediaGroupsDebounceTimeMillis != null) { val updatesHandler: (suspend (List<Update>) -> Unit) = if (mediaGroupsDebounceTimeMillis != null) {
val scope = CoroutineScope(contextToWork) val scope = CoroutineScope(contextToWork)
val updatesReceiver = scope.updateHandlerWithMediaGroupsAdaptation( val updatesReceiver = scope.updateHandlerWithMediaGroupsAdaptation(
::send, {
withContext(contextToWork) {
send(it)
}
},
mediaGroupsDebounceTimeMillis mediaGroupsDebounceTimeMillis
); );
{ originalUpdates: List<Update> -> { originalUpdates: List<Update> ->
originalUpdates.forEach { originalUpdates.forEach {
updatesReceiver(it) updatesReceiver(it)
lastUpdateIdentifier = maxOf(lastUpdateIdentifier ?: it.updateId, it.updateId)
} }
} }
} else { } else {