From f8cd4461338748bcf7dfeb6e6c07c7fbeea79345 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 8 Mar 2023 16:24:31 +0600 Subject: [PATCH 1/4] start 6.1.0 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf159eaa69..f6a3426a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 6.1.0 + ## 6.0.3 * `Versions`: diff --git a/gradle.properties b/gradle.properties index b9f70cd8d1..9c2d8b6297 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=6.0.3 +library_version=6.1.0 From 818ef8481db480b306dcb6df0ef3314b4a986010 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 8 Mar 2023 16:32:49 +0600 Subject: [PATCH 2/4] fix of #732 --- CHANGELOG.md | 3 +++ .../inmo/tgbotapi/extensions/api/DeleteMessage.kt | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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, From d83ff12560658c61c448a5a3383a071258f956a3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 8 Mar 2023 16:38:24 +0600 Subject: [PATCH 3/4] update dependencies --- CHANGELOG.md | 2 ++ gradle/libs.versions.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d734a3be91..3490340bd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 6.1.0 +* `Versions`: + * `MicroUtils`: `0.17.2` -> `0.17.3` * `API`: * Fix of [#732](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/732) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 404d430f4f..2187d2ec0f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ ktor = "2.2.4" ksp = "1.8.10-1.0.9" kotlin-poet = "1.12.0" -microutils = "0.17.2" +microutils = "0.17.3" github-release-plugin = "2.4.1" dokka = "1.8.10" From 4c08fb7d26e6c1a91c396ad7e88d98f03bafac52 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 8 Mar 2023 16:41:10 +0600 Subject: [PATCH 4/4] small improvement in #732 solution --- .../kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 9874e15c86..90c7f00b35 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 @@ -7,6 +7,7 @@ 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.MediaGroupCollectionContent import dev.inmo.tgbotapi.types.message.content.MediaGroupContent suspend fun TelegramBot.deleteMessage( @@ -24,7 +25,7 @@ suspend fun TelegramBot.deleteMessage( suspend fun TelegramBot.deleteMessage( message: Message ): Boolean { - val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupContent<*>) + val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>) if (mediaGroupContent == null) { return deleteMessage(message.chat, message.messageId) } else {