diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt index a64820dcff..c49a398ec4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt @@ -14,8 +14,10 @@ import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.json.buildJsonArray -@RiskFeature("Media groups contains restrictions related to combinations of media types. Currently it is possible to" + - " combine photo + video OR audio OR documents") +const val rawSendingMediaGroupsWarning = "Media groups contains restrictions related to combinations of media" + + " types. Currently it is possible to combine photo + video OR audio OR documents" + +@RiskFeature(rawSendingMediaGroupsWarning) fun SendMediaGroup( chatId: ChatIdentifier, media: List, @@ -56,28 +58,35 @@ fun SendMediaGroup( /** * Use this method to be sure that you are correctly sending playlist with audios + * + * @see InputMediaAudio */ @Suppress("NOTHING_TO_INLINE") inline fun SendPlaylist( chatId: ChatIdentifier, - media: List, + media: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null ) = SendMediaGroup(chatId, media, disableNotification, replyToMessageId) /** * Use this method to be sure that you are correctly sending documents media group + * + * @see InputMediaDocument */ @Suppress("NOTHING_TO_INLINE") inline fun SendDocumentsGroup( chatId: ChatIdentifier, - media: List, + media: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null ) = SendMediaGroup(chatId, media, disableNotification, replyToMessageId) /** * Use this method to be sure that you are correctly sending visual media group + * + * @see InputMediaPhoto + * @see InputMediaVideo */ @Suppress("NOTHING_TO_INLINE") inline fun SendVisualMediaGroup( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt index f430f993eb..d5585c58f4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt @@ -23,7 +23,7 @@ data class InputMediaAudio( override val performer: String? = null, override val title: String? = null, override val thumb: InputFile? = null -) : InputMedia, MediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, CaptionedOutput, Performerable { +) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, CaptionedOutput, Performerable { override val type: String = audioInputMediaType override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt index e6d918a278..e58029e6c2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt @@ -17,7 +17,7 @@ data class InputMediaDocument( @SerialName(parseModeField) override val parseMode: ParseMode? = null, override val thumb: InputFile? = null -) : InputMedia, MediaGroupMemberInputMedia, ThumbedInputMedia, CaptionedOutput { +) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia, CaptionedOutput { override val type: String = documentInputMediaType override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt index 202f40c366..83965179f8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt @@ -19,5 +19,8 @@ interface MediaGroupMemberInputMedia : InputMedia, CaptionedOutput { fun serialize(format: StringFormat): String } +interface AudioMediaGroupMemberInputMedia: MediaGroupMemberInputMedia +interface DocumentMediaGroupMemberInputMedia: MediaGroupMemberInputMedia + @Serializable(MediaGroupMemberInputMediaSerializer::class) interface VisualMediaGroupMemberInputMedia : MediaGroupMemberInputMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt index 07be31f7ca..a87f5bd337 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt @@ -39,7 +39,7 @@ data class AudioContent( replyMarkup ) - override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = media.toInputMediaAudio( + override fun toMediaGroupMemberInputMedia(): InputMediaAudio = media.toInputMediaAudio( toHtmlCaptions().firstOrNull(), HTMLParseMode ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt index 9163fafcb8..acbea12dd9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt @@ -39,7 +39,7 @@ data class DocumentContent( replyMarkup ) - override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = media.toInputMediaDocument( + override fun toMediaGroupMemberInputMedia(): InputMediaDocument = media.toInputMediaDocument( toHtmlCaptions().firstOrNull(), HTMLParseMode ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt index 0b37841c06..3aae309f48 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt @@ -38,7 +38,7 @@ data class PhotoContent( replyMarkup ) - override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto( + override fun toMediaGroupMemberInputMedia(): InputMediaPhoto = InputMediaPhoto( media.fileId, toHtmlCaptions().firstOrNull(), HTMLParseMode diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt index 7d76c656da..8dd6efed24 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt @@ -42,7 +42,7 @@ data class VideoContent( replyMarkup ) - override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaVideo( + override fun toMediaGroupMemberInputMedia(): InputMediaVideo = InputMediaVideo( media.fileId, toHtmlCaptions().firstOrNull(), HTMLParseMode, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt index 1f0cf52f6a..03e5d13e3d 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt @@ -1,13 +1,18 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.requests.send.media.SendMediaGroup +import dev.inmo.tgbotapi.requests.send.media.* import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.InputMedia.MediaGroupMemberInputMedia +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.abstracts.Message +import dev.inmo.tgbotapi.utils.RiskFeature +/** + * @see SendMediaGroup + */ +@RiskFeature(rawSendingMediaGroupsWarning) suspend fun TelegramBot.sendMediaGroup( chatId: ChatIdentifier, media: List, @@ -19,6 +24,10 @@ suspend fun TelegramBot.sendMediaGroup( ) ) +/** + * @see SendMediaGroup + */ +@RiskFeature(rawSendingMediaGroupsWarning) suspend fun TelegramBot.sendMediaGroup( chat: Chat, media: List, @@ -28,12 +37,108 @@ suspend fun TelegramBot.sendMediaGroup( chat.id, media, disableNotification, replyToMessageId ) +/** + * @see SendPlaylist + */ +suspend fun TelegramBot.sendPlaylist( + chatId: ChatIdentifier, + media: List, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null +) = execute( + SendPlaylist( + chatId, media, disableNotification, replyToMessageId + ) +) + +/** + * @see SendPlaylist + */ +suspend fun TelegramBot.sendPlaylist( + chat: Chat, + media: List, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null +) = sendPlaylist( + chat.id, media, disableNotification, replyToMessageId +) + +/** + * @see SendDocumentsGroup + */ +suspend fun TelegramBot.sendDocumentsGroup( + chatId: ChatIdentifier, + media: List, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null +) = execute( + SendDocumentsGroup( + chatId, media, disableNotification, replyToMessageId + ) +) + +/** + * @see SendDocumentsGroup + */ +suspend fun TelegramBot.sendDocumentsGroup( + chat: Chat, + media: List, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null +) = sendDocumentsGroup( + chat.id, media, disableNotification, replyToMessageId +) + +/** + * @see SendVisualMediaGroup + */ +suspend fun TelegramBot.sendVisualMediaGroup( + chatId: ChatIdentifier, + media: List, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null +) = execute( + SendVisualMediaGroup( + chatId, media, disableNotification, replyToMessageId + ) +) + +/** + * @see SendVisualMediaGroup + */ +suspend fun TelegramBot.sendVisualMediaGroup( + chat: Chat, + media: List, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null +) = sendVisualMediaGroup( + chat.id, media, disableNotification, replyToMessageId +) + suspend inline fun TelegramBot.replyWithMediaGroup( to: Message, media: List, disableNotification: Boolean = false ) = sendMediaGroup(to.chat, media, disableNotification, to.messageId) +suspend inline fun TelegramBot.replyWithPlaylist( + to: Message, + media: List, + disableNotification: Boolean = false +) = sendPlaylist(to.chat, media, disableNotification, to.messageId) + +suspend inline fun TelegramBot.replyWithDocumentsGroup( + to: Message, + media: List, + disableNotification: Boolean = false +) = sendDocumentsGroup(to.chat, media, disableNotification, to.messageId) + +suspend inline fun TelegramBot.replyWithVisualMediaGroup( + to: Message, + media: List, + disableNotification: Boolean = false +) = sendVisualMediaGroup(to.chat, media, disableNotification, to.messageId) + suspend inline fun TelegramBot.reply( to: Message, media: List,