From 28fce0b4c1678f9351634eb3f5add52ececb8543 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 12 Jan 2022 11:39:35 +0600 Subject: [PATCH] New extensions "TelegramBot#send*" for media groups with contents --- CHANGELOG.md | 3 + .../api/send/media/SendMediaGroup.kt | 126 ++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 568a631b1e..031ee31f3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.38.3 +* `API` + * New extensions `TelegramBot#send*` for media groups with contents + ## 0.38.2 * `Common`: diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt index 0bd5de4206..be8f180f54 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt @@ -7,7 +7,11 @@ import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.media.AudioContent +import dev.inmo.tgbotapi.types.message.content.media.DocumentContent import dev.inmo.tgbotapi.utils.RiskFeature +import kotlin.jvm.JvmName /** * @see SendMediaGroup @@ -41,6 +45,38 @@ suspend fun TelegramBot.sendMediaGroup( chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) +/** + * @see SendMediaGroup + */ +@RiskFeature(rawSendingMediaGroupsWarning) +@JvmName("sendMedaGroupByContent") +suspend fun TelegramBot.sendMediaGroup( + chatId: ChatIdentifier, + media: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) = sendMediaGroup( + chatId, media.map { it.toMediaGroupMemberInputMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply +) + +/** + * @see SendMediaGroup + */ +@RiskFeature(rawSendingMediaGroupsWarning) +@JvmName("sendMedaGroupByContent") +suspend fun TelegramBot.sendMediaGroup( + chat: Chat, + media: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) = sendMediaGroup( + chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply +) + /** * @see SendPlaylist */ @@ -71,6 +107,36 @@ suspend fun TelegramBot.sendPlaylist( chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) +/** + * @see SendPlaylist + */ +@JvmName("sendPlaylistByContent") +suspend fun TelegramBot.sendPlaylist( + chatId: ChatIdentifier, + media: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) = sendPlaylist( + chatId, media.map { it.toMediaGroupMemberInputMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply +) + +/** + * @see SendPlaylist + */ +@JvmName("sendPlaylistByContent") +suspend fun TelegramBot.sendPlaylist( + chat: Chat, + media: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) = sendPlaylist( + chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply +) + /** * @see SendDocumentsGroup */ @@ -101,6 +167,36 @@ suspend fun TelegramBot.sendDocumentsGroup( chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) +/** + * @see SendDocumentsGroup + */ +@JvmName("sendDocumentsByContent") +suspend fun TelegramBot.sendDocumentsGroup( + chatId: ChatIdentifier, + media: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) = sendDocumentsGroup( + chatId, media.map { it.toMediaGroupMemberInputMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply +) + +/** + * @see SendDocumentsGroup + */ +@JvmName("sendDocumentsByContent") +suspend fun TelegramBot.sendDocumentsGroup( + chat: Chat, + media: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) = sendDocumentsGroup( + chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply +) + /** * @see SendVisualMediaGroup */ @@ -130,3 +226,33 @@ suspend fun TelegramBot.sendVisualMediaGroup( ) = sendVisualMediaGroup( chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) + +/** + * @see SendVisualMediaGroup + */ +@JvmName("sendVisualMediaGroupByContent") +suspend fun TelegramBot.sendVisualMediaGroup( + chatId: ChatIdentifier, + media: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) = sendVisualMediaGroup( + chatId, media.map { it.toMediaGroupMemberInputMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply +) + +/** + * @see SendVisualMediaGroup + */ +@JvmName("sendVisualMediaGroupByContent") +suspend fun TelegramBot.sendVisualMediaGroup( + chat: Chat, + media: List, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) = sendVisualMediaGroup( + chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply +)