1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

fix of error inside of update utils for media groups

This commit is contained in:
InsanusMokrassar 2020-03-26 14:26:44 +06:00
parent 688de1053b
commit 3dd428c7d9
2 changed files with 10 additions and 8 deletions

View File

@ -27,6 +27,8 @@
### 0.25.1 ### 0.25.1
* Fix of error inside of update utils for media groups
## 0.24.0 ## 0.24.0
* `TelegramBotAPI`: * `TelegramBotAPI`:

View File

@ -23,19 +23,19 @@ internal fun List<Update>.convertWithMediaGroupUpdates(): List<Update> {
val resultUpdates = mutableListOf<Update>() val resultUpdates = mutableListOf<Update>()
val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<BaseSentMessageUpdate>>() val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<BaseSentMessageUpdate>>()
for (update in this) { for (update in this) {
val data = (update.data as? MediaGroupMessage)
if (data == null) {
resultUpdates.add(update)
continue
}
when (update) { when (update) {
is BaseEditMessageUpdate -> resultUpdates.add( is BaseEditMessageUpdate -> resultUpdates.add(
update.toEditMediaGroupUpdate() update.toEditMediaGroupUpdate()
) )
is BaseSentMessageUpdate -> { is BaseSentMessageUpdate -> {
val data = update.data mediaGroups.getOrPut(data.mediaGroupId) {
if (data is MediaGroupMessage) { mutableListOf()
mediaGroups.getOrPut(data.mediaGroupId) { }.add(update)
mutableListOf()
}.add(update)
} else {
resultUpdates.add(update)
}
} }
else -> resultUpdates.add(update) else -> resultUpdates.add(update)
} }