From 65048648b828d6d491933266db60e802c373957f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 1 Nov 2024 14:44:20 +0600 Subject: [PATCH] improve support of media adding to text messages --- .../dev/inmo/tgbotapi/extensions/api/edit/Edits.kt | 12 ++++++++++++ .../api/edit/media/EditChatMessageMedia.kt | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt index f0451beda8..2224d0dcec 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.abstracts.TextedWithTextSources import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.api.edit.caption.editMessageCaption import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation +import dev.inmo.tgbotapi.extensions.api.edit.media.addMessageMedia import dev.inmo.tgbotapi.extensions.api.edit.media.editMessageMedia import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText @@ -173,6 +174,17 @@ public suspend fun TelegramBot.edit( replyMarkup: InlineKeyboardMarkup? = null ): ContentMessage = editMessageMedia(message, media, businessConnectionId, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +public suspend fun TelegramBot.addMedia( + message: ContentMessage, + media: TelegramFreeMedia, + businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId, + replyMarkup: InlineKeyboardMarkup? = null +): ContentMessage = addMessageMedia(message, media, businessConnectionId, replyMarkup) + /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * as a builder for that diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt index 6a1b51e785..41148b9305 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt @@ -11,6 +11,8 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.MediaContent +import dev.inmo.tgbotapi.types.message.content.TextContent +import kotlin.jvm.JvmName /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -48,3 +50,14 @@ public suspend fun TelegramBot.editMessageMedia( businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId, replyMarkup: InlineKeyboardMarkup? = null ): ContentMessage = editMessageMedia(message.chat.id, message.messageId, media, businessConnectionId, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +public suspend fun TelegramBot.addMessageMedia( + message: ContentMessage, + media: TelegramFreeMedia, + businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId, + replyMarkup: InlineKeyboardMarkup? = null +): ContentMessage = editMessageMedia(message.chat.id, message.messageId, media, businessConnectionId, replyMarkup)