diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a3426a04..d734a3be91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 6.1.0 +* `API`: + * Fix of [#732](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/732) + ## 6.0.3 * `Versions`: diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt index 8e9fc661ca..9874e15c86 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt @@ -5,7 +5,9 @@ import dev.inmo.tgbotapi.requests.DeleteMessage import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.content.MediaGroupContent suspend fun TelegramBot.deleteMessage( chatId: ChatIdentifier, @@ -21,7 +23,16 @@ suspend fun TelegramBot.deleteMessage( suspend fun TelegramBot.deleteMessage( message: Message -) = deleteMessage(message.chat, message.messageId) +): Boolean { + val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupContent<*>) + if (mediaGroupContent == null) { + return deleteMessage(message.chat, message.messageId) + } else { + return mediaGroupContent.group.map { + deleteMessage(it.sourceMessage) + }.all { it } + } +} suspend fun TelegramBot.delete( chatId: ChatIdentifier,