1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +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
* Fix of error inside of update utils for media groups
## 0.24.0
* `TelegramBotAPI`:

View File

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