From f89849218ad0922764ff045c42166ce64bb6aae6 Mon Sep 17 00:00:00 2001 From: bpavuk Date: Wed, 10 Jul 2024 16:39:52 +0300 Subject: [PATCH] Added `to: AccessibleMessage` overload --- .../api/send/RepliesWithChatsAndMessages.kt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index af5874b388..8284cc65ec 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -2049,6 +2049,45 @@ suspend fun TelegramBot.reply( } } +suspend fun TelegramBot.reply( + to: AccessibleMessage, + content: PaidMediaInfoContent, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, + replyInBusinessConnectionId: BusinessConnectionId? = replyInChatId.businessConnectionId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + parseMode: ParseMode? = null, + replyMarkup: KeyboardMarkup? = null +) { + val media = content.paidMediaInfo.media.mapNotNull { + when (it) { + is PaidMedia.Video -> it.toTelegramPaidMediaVideo() + is PaidMedia.Photo -> it.toTelegramMediaPhoto() + is PaidMedia.Preview, is PaidMedia.Unknown -> null + } + } + sendPaidMedia( + chatId = replyInChatId, + starCount = content.paidMediaInfo.stars, + media = media, + text = content.text, + parseMode = parseMode, + showCaptionAboveMedia = content.showCaptionAboveMedia, + threadId = replyInThreadId, + businessConnectionId = replyInBusinessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyMarkup = replyMarkup, + replyParameters = ReplyParameters( + messageId = to.messageId, + chatIdentifier = to.chat.id, + allowSendingWithoutReply = allowSendingWithoutReply + ) + ) +} + suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, @@ -2088,3 +2127,4 @@ suspend fun TelegramBot.reply( ) ) } +