From 93e06a5765d8a296d5c1959378a462ec12a5f916 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 28 May 2024 22:48:06 +0600 Subject: [PATCH] add support of show_caption_above_media"" --- .../edit/caption/EditChatMessageCaption.kt | 21 +- .../api/edit/text/EditInlineMessageText.kt | 12 +- .../extensions/api/send/CopyMessage.kt | 50 ++++- .../api/send/media/SendAnimation.kt | 173 ++++++++++++--- .../extensions/api/send/media/SendPhoto.kt | 201 +++++++++++++++--- .../extensions/api/send/media/SendVideo.kt | 175 +++++++++++---- .../abstracts/WithCustomizableCaption.kt | 5 + .../edit/caption/EditChatMessageCaption.kt | 33 +-- .../edit/text/EditInlineMessageText.kt | 33 +-- .../tgbotapi/requests/send/CopyMessage.kt | 101 +++++---- .../WithCustomizableCaptionRequest.kt | 6 + .../requests/send/media/SendAnimation.kt | 71 ++++--- .../tgbotapi/requests/send/media/SendPhoto.kt | 55 ++--- .../tgbotapi/requests/send/media/SendVideo.kt | 75 ++++--- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../InlineQueryResultGifCachedImpl.kt | 33 ++- .../InlineQueryResultGifImpl.kt | 79 +++++-- .../InlineQueryResultMpeg4GifCachedImpl.kt | 33 ++- .../InlineQueryResultMpeg4GifImpl.kt | 48 +++-- .../InlineQueryResultPhotoCachedImpl.kt | 36 +++- .../InlineQueryResultPhotoImpl.kt | 45 ++-- .../InlineQueryResultVideoCachedImpl.kt | 36 +++- .../InlineQueryResultVideoImpl.kt | 51 +++-- ...ithCustomizableCaptionInlineQueryResult.kt | 5 + .../results/gif/InlineQueryResultGifCommon.kt | 3 +- .../InlineQueryResultMpeg4GifCommon.kt | 3 +- .../photo/InlineQueryResultPhotoCommon.kt | 3 +- .../video/InlineQueryResultVideoCommon.kt | 3 +- .../inmo/tgbotapi/types/files/VideoFile.kt | 38 ++-- .../media/MediaGroupMemberTelegramMedia.kt | 2 +- .../types/media/TelegramMediaAnimation.kt | 9 +- .../types/media/TelegramMediaPhoto.kt | 34 +-- .../types/media/TelegramMediaVideo.kt | 30 ++- .../WithCustomizableCaptionTelegramMedia.kt | 5 + .../inmo/tgbotapi/types/message/RawMessage.kt | 11 +- .../types/message/content/Abstracts.kt | 2 + .../types/message/content/AbstractsMedia.kt | 2 +- .../types/message/content/AnimationContent.kt | 20 +- .../types/message/content/PhotoContent.kt | 5 +- .../types/message/content/VideoContent.kt | 9 +- 40 files changed, 1121 insertions(+), 436 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithCustomizableCaption.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/WithCustomizableCaptionRequest.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/WithCustomizableCaptionInlineQueryResult.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/WithCustomizableCaptionTelegramMedia.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt index f7992ccd8b..d5d2317240 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt @@ -24,9 +24,10 @@ suspend fun TelegramBot.editMessageCaption( messageId: MessageId, text: String, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null ) = execute( - EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup) + EditChatMessageCaption(chatId, messageId, text, parseMode, showCaptionAboveMedia, replyMarkup) ) /** @@ -38,8 +39,9 @@ suspend fun TelegramBot.editMessageCaption( messageId: MessageId, text: String, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup) +) = editMessageCaption(chat.id, messageId, text, parseMode, showCaptionAboveMedia, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -49,10 +51,11 @@ suspend fun TelegramBot.editMessageCaption( message: ContentMessage, text: String, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null ): ContentMessage where T : TextedWithTextSources, T : MediaContent { @Suppress("UNCHECKED_CAST") - return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) as ContentMessage + return editMessageCaption(message.chat.id, message.messageId, text, parseMode, showCaptionAboveMedia, replyMarkup) as ContentMessage } /** @@ -63,9 +66,10 @@ suspend fun TelegramBot.editMessageCaption( chatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null ) = execute( - EditChatMessageCaption(chatId, messageId, entities, replyMarkup) + EditChatMessageCaption(chatId, messageId, entities, showCaptionAboveMedia, replyMarkup) ) /** @@ -76,8 +80,9 @@ suspend fun TelegramBot.editMessageCaption( chat: Chat, messageId: MessageId, entities: List, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageCaption(chat.id, messageId, entities, replyMarkup) +) = editMessageCaption(chat.id, messageId, entities, showCaptionAboveMedia, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -86,10 +91,11 @@ suspend fun TelegramBot.editMessageCaption( suspend fun TelegramBot.editMessageCaption( message: ContentMessage, entities: List, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null ): ContentMessage where T : TextedWithTextSources, T : MediaContent { @Suppress("UNCHECKED_CAST") - return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup) as ContentMessage + return editMessageCaption(message.chat.id, message.messageId, entities, showCaptionAboveMedia, replyMarkup) as ContentMessage } /** @@ -100,7 +106,8 @@ suspend fun TelegramBot.editMessageCaption( suspend fun TelegramBot.editMessageCaption( message: AccessibleMessage, entities: List, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null ): ContentMessage where T : TextedWithTextSources, T : MediaContent { - return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup) + return editMessageCaption(message.chat.id, message.messageId, entities, showCaptionAboveMedia, replyMarkup) } diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt index 3a9c64d5b5..3401f5e352 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt @@ -19,9 +19,10 @@ suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageId, text: String, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, linkPreviewOptions, replyMarkup)) +) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, showCaptionAboveMedia, linkPreviewOptions, replyMarkup)) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -30,9 +31,10 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageId, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = execute(EditInlineMessageText(inlineMessageId, entities, linkPreviewOptions, replyMarkup)) +) = execute(EditInlineMessageText(inlineMessageId, entities, showCaptionAboveMedia, linkPreviewOptions, replyMarkup)) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -41,10 +43,11 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageId, separator: TextSource? = null, + showCaptionAboveMedia: Boolean = false, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) +) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -53,7 +56,8 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageId, separator: String, + showCaptionAboveMedia: Boolean = false, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) +) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt index 2524e2b145..a39e052d2a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt @@ -19,6 +19,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -31,6 +32,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId, text, parseMode, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -49,12 +51,13 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -66,12 +69,13 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -83,12 +87,13 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -100,6 +105,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -111,6 +117,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, toChatId, entities, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -128,12 +135,13 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChatId, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChatId, entities, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -144,12 +152,13 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChat: Chat, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(fromChatId, messageId, toChat.id, entities, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -160,12 +169,13 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChat: Chat, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChat.id, entities, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -176,12 +186,13 @@ suspend inline fun TelegramBot.copyMessage( message: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -192,12 +203,13 @@ suspend inline fun TelegramBot.copyMessage( message: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -207,12 +219,13 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, message: AccessibleMessage, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChatId, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChatId, entities, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -222,12 +235,13 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, message: AccessibleMessage, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChat, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChat, entities, showCaptionAboveMedia, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -239,6 +253,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -251,6 +266,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId, text, parseMode, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -269,6 +285,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -280,6 +297,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, text, parseMode, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -297,6 +315,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -308,6 +327,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, text, parseMode, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -325,6 +345,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -336,6 +357,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, text, parseMode, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -353,6 +375,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -364,6 +387,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, toChatId, entities, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -381,6 +405,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, messageId: MessageId, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -391,6 +416,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat.id, messageId, entities, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -407,6 +433,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -417,6 +444,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId, messageId, entities, + showCaptionAboveMedia, threadId, disableNotification, protectContent, @@ -433,6 +461,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, messageId: MessageId, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -443,6 +472,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat.id, messageId, entities, + showCaptionAboveMedia, threadId, disableNotification, protectContent, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt index 31552072e7..b15f158436 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt @@ -21,6 +21,7 @@ suspend fun TelegramBot.sendAnimation( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -33,21 +34,22 @@ suspend fun TelegramBot.sendAnimation( replyMarkup: KeyboardMarkup? = null ) = execute( SendAnimation( - chatId, - animation, - thumb, - text, - parseMode, - spoilered, - duration, - width, - height, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + animation = animation, + thumbnail = thumb, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) ) @@ -60,6 +62,7 @@ suspend fun TelegramBot.sendAnimation( animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -71,7 +74,22 @@ suspend fun TelegramBot.sendAnimation( replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumbnail ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup + chatId = chatId, + animation = animation.fileId, + thumb = animation.thumbnail ?.fileId, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) /** @@ -84,6 +102,7 @@ suspend fun TelegramBot.sendAnimation( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -94,7 +113,24 @@ suspend fun TelegramBot.sendAnimation( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, thumb, text, parseMode, spoilered, duration, width, height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendAnimation( + chatId = chat.id, + animation = animation, + thumb = thumb, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -105,6 +141,7 @@ suspend fun TelegramBot.sendAnimation( animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -115,7 +152,23 @@ suspend fun TelegramBot.sendAnimation( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, text, parseMode, spoilered, duration, width, height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendAnimation( + chatId = chat.id, + animation = animation, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** @@ -127,6 +180,7 @@ suspend fun TelegramBot.sendAnimation( animation: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -139,20 +193,21 @@ suspend fun TelegramBot.sendAnimation( replyMarkup: KeyboardMarkup? = null ) = execute( SendAnimation( - chatId, - animation, - thumb, - entities, - spoilered, - duration, - width, - height, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + animation = animation, + thumbnail = thumb, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) ) @@ -164,6 +219,7 @@ suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: AnimationFile, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -175,7 +231,21 @@ suspend fun TelegramBot.sendAnimation( replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumbnail ?.fileId, entities, spoilered, duration, width, height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup + chatId = chatId, + animation = animation.fileId, + thumb = animation.thumbnail ?.fileId, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) /** @@ -187,6 +257,7 @@ suspend fun TelegramBot.sendAnimation( animation: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -197,7 +268,23 @@ suspend fun TelegramBot.sendAnimation( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, thumb, entities, spoilered, duration, width, height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendAnimation( + chatId = chat.id, + animation = animation, + thumb = thumb, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -207,6 +294,7 @@ suspend fun TelegramBot.sendAnimation( chat: Chat, animation: AnimationFile, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -217,4 +305,19 @@ suspend fun TelegramBot.sendAnimation( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, entities, spoilered, duration, width, height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendAnimation( + chatId = chat.id, + animation = animation, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt index 61fff8881c..6d94551009 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt @@ -20,6 +20,7 @@ suspend fun TelegramBot.sendPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -29,17 +30,18 @@ suspend fun TelegramBot.sendPhoto( replyMarkup: KeyboardMarkup? = null ) = execute( SendPhoto( - chatId, - fileId, - text, - parseMode, - spoilered, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + photo = fileId, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) ) @@ -52,6 +54,7 @@ suspend fun TelegramBot.sendPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, @@ -59,7 +62,20 @@ suspend fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, text, parseMode, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chat.id, + fileId = fileId, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -70,6 +86,7 @@ suspend fun TelegramBot.sendPhoto( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -77,7 +94,20 @@ suspend fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chatId, + fileId = photo.biggest() ?.fileId ?: error("Photo content must not be empty"), + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -88,6 +118,7 @@ suspend fun TelegramBot.sendPhoto( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, @@ -95,7 +126,20 @@ suspend fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, text, parseMode, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chat.id, + photo = photo, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -106,6 +150,7 @@ suspend fun TelegramBot.sendPhoto( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -113,7 +158,20 @@ suspend fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize.fileId, text, parseMode, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chatId, + fileId = photoSize.fileId, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -124,6 +182,7 @@ suspend fun TelegramBot.sendPhoto( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, @@ -131,7 +190,20 @@ suspend fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photoSize, text, parseMode, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chat.id, + photoSize = photoSize, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** @@ -142,6 +214,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -151,16 +224,17 @@ suspend inline fun TelegramBot.sendPhoto( replyMarkup: KeyboardMarkup? = null ) = execute( SendPhoto( - chatId, - fileId, - entities, - spoilered, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + photo = fileId, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) ) @@ -172,6 +246,7 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, @@ -179,7 +254,19 @@ suspend inline fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, entities, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chat.id, + fileId = fileId, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -189,6 +276,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -196,7 +284,19 @@ suspend inline fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chatId, + fileId = photo.biggest() ?.fileId ?: error("Photo content must not be empty"), + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -206,6 +306,7 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, @@ -213,7 +314,19 @@ suspend inline fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, entities, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chat.id, + photo = photo, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -223,6 +336,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photoSize: PhotoSize, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -230,7 +344,19 @@ suspend inline fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize.fileId, entities, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chatId, + fileId = photoSize.fileId, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -240,6 +366,7 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photoSize: PhotoSize, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, @@ -247,4 +374,16 @@ suspend inline fun TelegramBot.sendPhoto( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photoSize, entities, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendPhoto( + chatId = chat.id, + photoSize = photoSize, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt index b4c8cefc0f..c1fcd0028d 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt @@ -21,6 +21,7 @@ suspend fun TelegramBot.sendVideo( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -33,22 +34,23 @@ suspend fun TelegramBot.sendVideo( replyMarkup: KeyboardMarkup? = null ) = execute( SendVideo( - chatId, - video, - thumb, - text, - parseMode, - spoilered, - duration, - width, - height, - null, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + video = video, + thumbnail = thumb, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + supportStreaming = null, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) ) @@ -61,6 +63,7 @@ suspend fun TelegramBot.sendVideo( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -68,7 +71,24 @@ suspend fun TelegramBot.sendVideo( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendVideo( + chatId = chatId, + video = video.fileId, + thumb = video.thumbnail ?.fileId, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = video.duration, + width = video.width, + height = video.height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -80,6 +100,7 @@ suspend fun TelegramBot.sendVideo( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -90,7 +111,24 @@ suspend fun TelegramBot.sendVideo( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendVideo( + chatId = chat.id, + video = video, + thumb = thumb, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** @@ -102,6 +140,7 @@ suspend fun TelegramBot.sendVideo( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, @@ -109,7 +148,20 @@ suspend fun TelegramBot.sendVideo( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, text, parseMode, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendVideo( + chatId = chat.id, + video = video, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -120,6 +172,7 @@ suspend inline fun TelegramBot.sendVideo( video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -132,21 +185,22 @@ suspend inline fun TelegramBot.sendVideo( replyMarkup: KeyboardMarkup? = null ) = execute( SendVideo( - chatId, - video, - thumb, - entities, - spoilered, - duration, - width, - height, - null, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + video = video, + thumbnail = thumb, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + supportStreaming = null, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) ) @@ -158,6 +212,7 @@ suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: VideoFile, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -165,7 +220,23 @@ suspend inline fun TelegramBot.sendVideo( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendVideo( + chatId = chatId, + video = video.fileId, + thumb = video.thumbnail ?.fileId, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = video.duration, + width = video.width, + height = video.height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -176,6 +247,7 @@ suspend inline fun TelegramBot.sendVideo( video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -186,7 +258,23 @@ suspend inline fun TelegramBot.sendVideo( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, thumb, entities, spoilered, duration, width, height, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendVideo( + chatId = chat.id, + video = video, + thumb = thumb, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) /** @@ -197,6 +285,7 @@ suspend inline fun TelegramBot.sendVideo( chat: Chat, video: VideoFile, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, @@ -204,4 +293,16 @@ suspend inline fun TelegramBot.sendVideo( protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, entities, spoilered, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = sendVideo( + chatId = chat.id, + video = video, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithCustomizableCaption.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithCustomizableCaption.kt new file mode 100644 index 0000000000..00b6bbf4c3 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithCustomizableCaption.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.abstracts + +interface WithCustomizableCaption : Texted { + val showCaptionAboveMedia: Boolean +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditChatMessageCaption.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditChatMessageCaption.kt index 13fae9e209..58fe36e728 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditChatMessageCaption.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditChatMessageCaption.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.edit.caption import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer +import dev.inmo.tgbotapi.requests.send.abstracts.WithCustomizableCaptionRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.ParseMode @@ -22,28 +23,32 @@ fun EditChatMessageCaption( messageId: MessageId, text: String, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageCaption( - chatId, - messageId, - text, - parseMode, - null, - replyMarkup + chatId = chatId, + messageId = messageId, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup ) fun EditChatMessageCaption( chatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageCaption( - chatId, - messageId, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup + chatId = chatId, + messageId = messageId, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup ) @Serializable @@ -58,9 +63,11 @@ data class EditChatMessageCaption internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null -) : EditChatMessage, EditTextChatMessage, EditReplyMessage { +) : EditChatMessage, WithCustomizableCaptionRequest>, EditTextChatMessage, EditReplyMessage { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt index 9bc3a1c248..a5b6048958 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.edit.text import dev.inmo.tgbotapi.requests.edit.abstracts.* +import dev.inmo.tgbotapi.requests.send.abstracts.WithCustomizableCaptionRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.ParseMode @@ -16,29 +17,33 @@ fun EditInlineMessageText( inlineMessageId: InlineMessageId, text: String, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageText( - inlineMessageId, - text, - parseMode, - null, - linkPreviewOptions, - replyMarkup + inlineMessageId = inlineMessageId, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + linkPreviewOptions = linkPreviewOptions, + replyMarkup = replyMarkup ) fun EditInlineMessageText( inlineMessageId: InlineMessageId, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageText( - inlineMessageId, - entities.makeString(), - null, - entities.toRawMessageEntities(), - linkPreviewOptions, - replyMarkup + inlineMessageId = inlineMessageId, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + linkPreviewOptions = linkPreviewOptions, + replyMarkup = replyMarkup ) @Serializable @@ -51,11 +56,13 @@ data class EditInlineMessageText internal constructor( override val parseMode: ParseMode? = null, @SerialName(entitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(linkPreviewOptionsField) override val linkPreviewOptions: LinkPreviewOptions? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null -) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditLinkPreviewOptionsContainer { +) : EditInlineMessage, WithCustomizableCaptionRequest, EditTextChatMessage, EditReplyMessage, EditLinkPreviewOptionsContainer { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt index 5a13f941e9..44cf7d512c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt @@ -1,11 +1,13 @@ package dev.inmo.tgbotapi.requests.send import dev.inmo.tgbotapi.abstracts.TextedOutput +import dev.inmo.tgbotapi.abstracts.WithCustomizableCaption import dev.inmo.tgbotapi.abstracts.types.MessageAction import dev.inmo.tgbotapi.abstracts.types.ProtectContent import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest +import dev.inmo.tgbotapi.requests.send.abstracts.WithCustomizableCaptionRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.message.textsources.TextSource @@ -28,23 +30,25 @@ fun CopyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = CopyMessage( - toChatId, - fromChatId, - messageId, - text, - parseMode, - null, - threadId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + toChatId = toChatId, + fromChatId = fromChatId, + messageId = messageId, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) fun CopyMessage( @@ -52,23 +56,25 @@ fun CopyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: List, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = CopyMessage( - toChatId, - fromChatId, - messageId, - entities.makeString(), - null, - entities.toRawMessageEntities(), - threadId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + toChatId = toChatId, + fromChatId = fromChatId, + messageId = messageId, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) fun CopyMessage( @@ -77,23 +83,25 @@ fun CopyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = CopyMessage( - toChatId, - fromChatId, - messageId, - text, - parseMode, - null, - threadId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + toChatId = toChatId, + fromChatId = fromChatId, + messageId = messageId, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) fun CopyMessage( @@ -101,23 +109,25 @@ fun CopyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: List, + showCaptionAboveMedia: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = CopyMessage( - toChatId, - fromChatId, - messageId, - entities.makeString(), - null, - entities.toRawMessageEntities(), - threadId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + toChatId = toChatId, + fromChatId = fromChatId, + messageId = messageId, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) @Serializable @@ -134,6 +144,8 @@ data class CopyMessage internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(messageThreadIdField) override val threadId: MessageThreadId? = toChatId.threadId, @SerialName(disableNotificationField) @@ -146,6 +158,7 @@ data class CopyMessage internal constructor( override val replyMarkup: KeyboardMarkup? = null ): SimpleRequest, ReplyingMarkupSendMessageRequest, + WithCustomizableCaptionRequest, MessageAction, TextedOutput, ProtectContent, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/WithCustomizableCaptionRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/WithCustomizableCaptionRequest.kt new file mode 100644 index 0000000000..9229ee9271 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/WithCustomizableCaptionRequest.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.requests.send.abstracts + +import dev.inmo.tgbotapi.abstracts.WithCustomizableCaption +import dev.inmo.tgbotapi.requests.abstracts.Request + +interface WithCustomizableCaptionRequest : Request, WithCustomizableCaption diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt index 2cd5129abc..3e692c4f97 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt @@ -27,6 +27,7 @@ fun SendAnimation( thumbnail: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -42,22 +43,23 @@ fun SendAnimation( val thumbAsFile = thumbnail as? MultipartFile val data = SendAnimationData( - chatId, - animation, - thumbnail ?.fileId, - text, - parseMode, - null, - spoilered, - duration, - width, - height, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + animation = animation, + thumbnail = thumbnail ?.fileId, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (animationAsFile == null && thumbAsFile == null) { @@ -75,6 +77,7 @@ fun SendAnimation( animation: InputFile, thumbnail: InputFile? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -90,22 +93,23 @@ fun SendAnimation( val thumbAsFile = thumbnail as? MultipartFile val data = SendAnimationData( - chatId, - animation, - thumbnail ?.fileId, - entities.makeString(), - null, - entities.toRawMessageEntities(), - spoilered, - duration, - width, - height, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + animation = animation, + thumbnail = thumbnail ?.fileId, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (animationAsFile == null && thumbAsFile == null) { @@ -135,6 +139,8 @@ data class SendAnimationData internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(hasSpoilerField) override val spoilered: Boolean = false, @SerialName(durationField) @@ -162,6 +168,7 @@ data class SendAnimationData internal constructor( ThumbedSendMessageRequest>, DuratedSendMessageRequest>, SizedSendMessageRequest>, + WithCustomizableCaptionRequest>, OptionallyWithSpoilerRequest { override val textSources: TextSourcesList? by lazy { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt index 2e7522cb16..0cbd8437ae 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt @@ -25,6 +25,7 @@ fun SendPhoto( photo: InputFile, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -34,18 +35,19 @@ fun SendPhoto( replyMarkup: KeyboardMarkup? = null ): Request> { val data = SendPhotoData( - chatId, - photo, - text, - parseMode, - null, - spoilered, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + photo = photo, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (photo is MultipartFile) { CommonMultipartFileRequest( @@ -61,6 +63,7 @@ fun SendPhoto( chatId: ChatIdentifier, photo: InputFile, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, @@ -70,18 +73,19 @@ fun SendPhoto( replyMarkup: KeyboardMarkup? = null ): Request> { val data = SendPhotoData( - chatId, - photo, - entities.makeString(), - null, - entities.toRawMessageEntities(), - spoilered, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + photo = photo, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (photo is MultipartFile) { @@ -109,6 +113,8 @@ data class SendPhotoData internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(hasSpoilerField) override val spoilered: Boolean = false, @SerialName(messageThreadIdField) @@ -127,6 +133,7 @@ data class SendPhotoData internal constructor( SendContentMessageRequest>, ReplyingMarkupSendMessageRequest>, TextableSendMessageRequest>, + WithCustomizableCaptionRequest>, OptionallyWithSpoilerRequest { override val textSources: TextSourcesList? by lazy { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt index 3a6fa55530..1fa756eec3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt @@ -27,6 +27,7 @@ fun SendVideo( thumbnail: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -43,23 +44,24 @@ fun SendVideo( val thumbAsFile = thumbnail as? MultipartFile val data = SendVideoData( - chatId, - video, - thumbnail ?.fileId, - text, - parseMode, - null, - spoilered, - duration, - width, - height, - supportStreaming, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + video = video, + thumbnail = thumbnail ?.fileId, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + supportStreaming = supportStreaming, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (videoAsFile == null && thumbAsFile == null) { @@ -77,6 +79,7 @@ fun SendVideo( video: InputFile, thumbnail: InputFile? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, @@ -93,23 +96,24 @@ fun SendVideo( val thumbAsFile = thumbnail as? MultipartFile val data = SendVideoData( - chatId, - video, - thumbnail ?.fileId, - entities.makeString(), - null, - entities.toRawMessageEntities(), - spoilered, - duration, - width, - height, - supportStreaming, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + video = video, + thumbnail = thumbnail ?.fileId, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + spoilered = spoilered, + duration = duration, + width = width, + height = height, + supportStreaming = supportStreaming, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (videoAsFile == null && thumbAsFile == null) { @@ -139,6 +143,8 @@ data class SendVideoData internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(hasSpoilerField) override val spoilered: Boolean = false, @SerialName(durationField) @@ -168,6 +174,7 @@ data class SendVideoData internal constructor( ThumbedSendMessageRequest>, DuratedSendMessageRequest>, SizedSendMessageRequest>, + WithCustomizableCaptionRequest>, OptionallyWithSpoilerRequest { override val textSources: TextSourcesList? by lazy { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 286e0e0b2b..ffe238571b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -227,6 +227,7 @@ const val canEditStoriesField = "can_edit_stories" const val canDeleteStoriesField = "can_delete_stories" const val captionEntitiesField = "caption_entities" const val hasSpoilerField = "has_spoiler" +const val showCaptionAboveMediaField = "show_caption_above_media" const val loginUrlField = "login_url" const val forwardTextField = "forward_text" const val botUsernameField = "bot_username" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt index 2b599f98fd..2ed6956f97 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt @@ -22,26 +22,39 @@ fun InlineQueryResultGifCachedImpl( title: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultGifCachedImpl(id, fileId, title, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultGifCachedImpl( + id = id, + fileId = fileId, + title = title, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultGifCachedImpl( id: InlineQueryId, fileId: FileId, title: String? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultGifCachedImpl( - id, - fileId, - title, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup, - inputMessageContent + id = id, + fileId = fileId, + title = title, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) @Serializable @@ -58,6 +71,8 @@ data class InlineQueryResultGifCachedImpl internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt index 4b3ce77e26..cc33e87a85 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt @@ -28,9 +28,25 @@ fun InlineQueryResultGifImpl( title: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultGifImpl(id, url, thumbnailUrl, thumbnailMimeType, width, height, duration, title, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultGifImpl( + id = id, + url = url, + thumbnailUrl = thumbnailUrl, + thumbnailMimeType = thumbnailMimeType, + width = width, + height = height, + duration = duration, + title = title, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultGifImpl( id: InlineQueryId, @@ -42,22 +58,24 @@ fun InlineQueryResultGifImpl( duration: Int? = null, title: String? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultGifImpl( - id, - url, - thumbnailUrl, - thumbnailMimeType, - width, - height, - duration, - title, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup, - inputMessageContent + id = id, + url = url, + thumbnailUrl = thumbnailUrl, + thumbnailMimeType = thumbnailMimeType, + width = width, + height = height, + duration = duration, + title = title, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) fun InlineQueryResultGifImpl( @@ -71,9 +89,24 @@ fun InlineQueryResultGifImpl( title: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultGifImpl(id, gifFile.fileId, thumbnailUrl, thumbnailMimeType, width, height, duration, title, text, parseMode, replyMarkup, inputMessageContent) +) = InlineQueryResultGifImpl( + id = id, + url = gifFile.fileId, + thumbnailUrl = thumbnailUrl, + thumbnailMimeType = thumbnailMimeType, + width = width, + height = height, + duration = duration, + title = title, + text = text, + parseMode = parseMode, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultGifImpl( id: InlineQueryId, @@ -85,10 +118,22 @@ fun InlineQueryResultGifImpl( duration: Int? = null, title: String? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultGifImpl( - id, gifFile.fileId, thumbnailUrl, thumbnailMimeType, width, height, duration, title, entities, replyMarkup, inputMessageContent + id = id, + url = gifFile.fileId, + thumbnailUrl = thumbnailUrl, + thumbnailMimeType = thumbnailMimeType, + width = width, + height = height, + duration = duration, + title = title, + entities = entities, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) @Serializable @@ -115,6 +160,8 @@ data class InlineQueryResultGifImpl internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt index 3fa6cec961..566c0dd3ae 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt @@ -22,26 +22,39 @@ fun InlineQueryResultMpeg4GifCachedImpl( title: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultMpeg4GifCachedImpl(id, fileId, title, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultMpeg4GifCachedImpl( + id = id, + fileId = fileId, + title = title, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultMpeg4GifCachedImpl( id: InlineQueryId, fileId: FileId, title: String? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultMpeg4GifCachedImpl( - id, - fileId, - title, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup, - inputMessageContent + id = id, + fileId = fileId, + title = title, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) @Serializable @@ -58,6 +71,8 @@ data class InlineQueryResultMpeg4GifCachedImpl internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt index fd7eb92ad5..8662aa9ec2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt @@ -27,9 +27,25 @@ fun InlineQueryResultMpeg4GifImpl( title: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultMpeg4GifImpl(id, url, thumbnailUrl, thumbnailMimeType, width, height, duration, title, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultMpeg4GifImpl( + id = id, + url = url, + thumbnailUrl = thumbnailUrl, + thumbnailMimeType = thumbnailMimeType, + width = width, + height = height, + duration = duration, + title = title, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultMpeg4GifImpl( id: InlineQueryId, @@ -41,22 +57,24 @@ fun InlineQueryResultMpeg4GifImpl( duration: Int? = null, title: String? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultMpeg4GifImpl( - id, - url, - thumbnailUrl, - thumbnailMimeType, - width, - height, - duration, - title, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup, - inputMessageContent + id = id, + url = url, + thumbnailUrl = thumbnailUrl, + thumbnailMimeType = thumbnailMimeType, + width = width, + height = height, + duration = duration, + title = title, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) @Serializable @@ -83,6 +101,8 @@ data class InlineQueryResultMpeg4GifImpl internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt index f506f1f3b2..5b6d1073b4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt @@ -23,9 +23,21 @@ fun InlineQueryResultPhotoCachedImpl( description: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultPhotoCachedImpl(id, fileId, title, description, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultPhotoCachedImpl( + id = id, + fileId = fileId, + title = title, + description = description, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultPhotoCachedImpl( id: InlineQueryId, @@ -33,18 +45,20 @@ fun InlineQueryResultPhotoCachedImpl( title: String? = null, description: String? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultPhotoCachedImpl( - id, - fileId, - title, - description, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup, - inputMessageContent + id = id, + fileId = fileId, + title = title, + description = description, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) @Serializable @@ -63,6 +77,8 @@ data class InlineQueryResultPhotoCachedImpl internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt index 7a102c8878..70414e70ab 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt @@ -25,9 +25,24 @@ fun InlineQueryResultPhotoImpl( description: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultPhotoImpl(id, url, thumbnailUrl, width, height, title, description, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultPhotoImpl( + id = id, + url = url, + thumbnailUrl = thumbnailUrl, + width = width, + height = height, + title = title, + description = description, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultPhotoImpl( id: InlineQueryId, @@ -38,21 +53,23 @@ fun InlineQueryResultPhotoImpl( title: String? = null, description: String? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultPhotoImpl( - id, - url, - thumbnailUrl, - width, - height, - title, - description, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup, - inputMessageContent + id = id, + url = url, + thumbnailUrl = thumbnailUrl, + width = width, + height = height, + title = title, + description = description, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) @Serializable @@ -77,6 +94,8 @@ data class InlineQueryResultPhotoImpl internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt index d144e56326..eb158461b6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt @@ -23,9 +23,21 @@ fun InlineQueryResultVideoCachedImpl( description: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultVideoCachedImpl(id, fileId, title, description, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultVideoCachedImpl( + id = id, + fileId = fileId, + title = title, + description = description, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultVideoCachedImpl( id: InlineQueryId, @@ -33,18 +45,20 @@ fun InlineQueryResultVideoCachedImpl( title: String, description: String? = null, entities: TextSourcesList, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVideoCachedImpl( - id, - fileId, - title, - description, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup, - inputMessageContent + id = id, + fileId = fileId, + title = title, + description = description, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) @Serializable @@ -63,6 +77,8 @@ data class InlineQueryResultVideoCachedImpl internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt index 229c5ab4e3..cf2d23abe4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt @@ -28,9 +28,26 @@ fun InlineQueryResultVideoImpl( description: String? = null, text: String? = null, parseMode: ParseMode? = null, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultVideoImpl(id, url, thumbnailUrl, mimeType, title, width, height, duration, description, text, parseMode, null, replyMarkup, inputMessageContent) +) = InlineQueryResultVideoImpl( + id = id, + url = url, + thumbnailUrl = thumbnailUrl, + mimeType = mimeType, + title = title, + width = width, + height = height, + duration = duration, + description = description, + text = text, + parseMode = parseMode, + rawEntities = null, + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent +) fun InlineQueryResultVideoImpl( id: InlineQueryId, @@ -43,23 +60,25 @@ fun InlineQueryResultVideoImpl( duration: Int? = null, description: String? = null, entities: List, + showCaptionAboveMedia: Boolean = false, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVideoImpl( - id, - url, - thumbnailUrl, - mimeType, - title, - width, - height, - duration, - description, - entities.makeString(), - null, - entities.toRawMessageEntities(), - replyMarkup, - inputMessageContent + id = id, + url = url, + thumbnailUrl = thumbnailUrl, + mimeType = mimeType, + title = title, + width = width, + height = height, + duration = duration, + description = description, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + showCaptionAboveMedia = showCaptionAboveMedia, + replyMarkup = replyMarkup, + inputMessageContent = inputMessageContent ) @Serializable @@ -88,6 +107,8 @@ data class InlineQueryResultVideoImpl internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null, @SerialName(inputMessageContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/WithCustomizableCaptionInlineQueryResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/WithCustomizableCaptionInlineQueryResult.kt new file mode 100644 index 0000000000..e6d72ed5c7 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/WithCustomizableCaptionInlineQueryResult.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts + +import dev.inmo.tgbotapi.abstracts.WithCustomizableCaption + +interface WithCustomizableCaptionInlineQueryResult : InlineQueryResult, WithCustomizableCaption diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt index 7202d3b67a..2d63b160ee 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt @@ -8,4 +8,5 @@ const val inlineQueryResultGifType = "gif" interface InlineQueryResultGifCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, TextedOutput, - WithInputMessageContentInlineQueryResult + WithInputMessageContentInlineQueryResult, + WithCustomizableCaptionInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt index 7b1564aadf..367eb5e49f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt @@ -8,4 +8,5 @@ const val inlineQueryResultMpeg4GifType = "mpeg4_gif" interface InlineQueryResultMpeg4GifCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, TextedOutput, - WithInputMessageContentInlineQueryResult + WithInputMessageContentInlineQueryResult, + WithCustomizableCaptionInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt index 5de38e39a4..68956b3b98 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt @@ -9,4 +9,5 @@ interface InlineQueryResultPhotoCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, DescribedInlineQueryResult, TextedOutput, - WithInputMessageContentInlineQueryResult + WithInputMessageContentInlineQueryResult, + WithCustomizableCaptionInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt index b251ea994e..d99d03d944 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt @@ -9,4 +9,5 @@ interface InlineQueryResultVideoCommon : InlineQueryResult, TitledInlineQueryResult, DescribedInlineQueryResult, TextedOutput, - WithInputMessageContentInlineQueryResult + WithInputMessageContentInlineQueryResult, + WithCustomizableCaptionInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index 4b5411ac47..846fc7ca91 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -36,28 +36,32 @@ data class VideoFile( inline fun VideoFile.toTelegramMediaVideo( text: String? = null, parseMode: ParseMode? = null, - spoilered: Boolean = false + spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false ) = TelegramMediaVideo( - fileId, - text, - parseMode, - spoilered, - width, - height, - duration, - thumbnail ?.fileId + file = fileId, + text = text, + parseMode = parseMode, + spoilered = spoilered, + showCaptionAboveMedia = showCaptionAboveMedia, + width = width, + height = height, + duration = duration, + thumb = thumbnail ?.fileId ) @Suppress("NOTHING_TO_INLINE") inline fun VideoFile.toTelegramMediaVideo( textSources: TextSourcesList, - spoilered: Boolean = false + spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false ) = TelegramMediaVideo( - fileId, - textSources, - spoilered, - width, - height, - duration, - thumbnail ?.fileId + file = fileId, + entities = textSources, + spoilered = spoilered, + showCaptionAboveMedia = showCaptionAboveMedia, + width = width, + height = height, + duration = duration, + thumb = thumbnail ?.fileId ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/MediaGroupMemberTelegramMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/MediaGroupMemberTelegramMedia.kt index 64a8287081..a04884841b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/MediaGroupMemberTelegramMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/MediaGroupMemberTelegramMedia.kt @@ -20,4 +20,4 @@ sealed interface AudioMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMed sealed interface DocumentMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMedia @Serializable(MediaGroupMemberTelegramMediaSerializer::class) -sealed interface VisualMediaGroupMemberTelegramMedia : MediaGroupMemberTelegramMedia, SpoilerableTelegramMedia +sealed interface VisualMediaGroupMemberTelegramMedia : MediaGroupMemberTelegramMedia, SpoilerableTelegramMedia, WithCustomizableCaptionTelegramMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaAnimation.kt index 7f73206e76..f3fafe6f6c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaAnimation.kt @@ -19,16 +19,18 @@ fun TelegramMediaAnimation( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false, width: Int? = null, height: Int? = null, duration: Long? = null, thumb: InputFile? = null -) = TelegramMediaAnimation(file, text, parseMode, null, spoilered, width, height, duration, thumb) +) = TelegramMediaAnimation(file, text, parseMode, null, spoilered, showCaptionAboveMedia, width, height, duration, thumb) fun TelegramMediaAnimation( file: InputFile, entities: TextSourcesList, spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false, width: Int? = null, height: Int? = null, duration: Long? = null, @@ -39,6 +41,7 @@ fun TelegramMediaAnimation( null, entities.toRawMessageEntities(), spoilered, + showCaptionAboveMedia, width, height, duration, @@ -56,11 +59,13 @@ data class TelegramMediaAnimation internal constructor( private val rawEntities: List? = null, @SerialName(hasSpoilerField) override val spoilered: Boolean = false, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, override val width: Int? = null, override val height: Int? = null, override val duration: Long? = null, override val thumb: InputFile? = null -) : TelegramMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TextedOutput, SpoilerableTelegramMedia { +) : TelegramMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TextedOutput, SpoilerableTelegramMedia, WithCustomizableCaptionTelegramMedia { override val type: String = "animation" override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaPhoto.kt index 5678e2f35f..f7eaa6320c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaPhoto.kt @@ -19,14 +19,16 @@ fun TelegramMediaPhoto( file: InputFile, text: String? = null, parseMode: ParseMode? = null, - spoilered: Boolean = false -) = TelegramMediaPhoto(file, text, parseMode, null, spoilered) + spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false +) = TelegramMediaPhoto(file, text, parseMode, null, spoilered, showCaptionAboveMedia) fun TelegramMediaPhoto( file: InputFile, entities: TextSourcesList, - spoilered: Boolean = false -) = TelegramMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities(), spoilered) + spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false +) = TelegramMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities(), spoilered, showCaptionAboveMedia) @Serializable data class TelegramMediaPhoto internal constructor( @@ -39,6 +41,8 @@ data class TelegramMediaPhoto internal constructor( private val rawEntities: List? = null, @SerialName(hasSpoilerField) override val spoilered: Boolean = false, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, ) : TelegramMedia, VisualMediaGroupMemberTelegramMedia { override val type: String = photoTelegramMediaType override val textSources: TextSourcesList? by lazy { @@ -55,19 +59,23 @@ data class TelegramMediaPhoto internal constructor( fun PhotoSize.toTelegramMediaPhoto( text: String? = null, parseMode: ParseMode? = null, - spoilered: Boolean = false + spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false ): TelegramMediaPhoto = TelegramMediaPhoto( - fileId, - text, - parseMode, - spoilered + file = fileId, + text = text, + parseMode = parseMode, + spoilered = spoilered, + showCaptionAboveMedia = showCaptionAboveMedia ) fun PhotoSize.toTelegramMediaPhoto( textSources: TextSourcesList = emptyList(), - spoilered: Boolean = false + spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false ): TelegramMediaPhoto = TelegramMediaPhoto( - fileId, - textSources, - spoilered + file = fileId, + entities = textSources, + spoilered = spoilered, + showCaptionAboveMedia = showCaptionAboveMedia ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaVideo.kt index 3999b118e1..1871adb345 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMediaVideo.kt @@ -19,21 +19,45 @@ fun TelegramMediaVideo( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false, width: Int? = null, height: Int? = null, duration: Long? = null, thumb: InputFile? = null -) = TelegramMediaVideo(file, text, parseMode, null, spoilered, width, height, duration, thumb) +) = TelegramMediaVideo( + file = file, + text = text, + parseMode = parseMode, + rawEntities = null, + spoilered = spoilered, + showCaptionAboveMedia = showCaptionAboveMedia, + width = width, + height = height, + duration = duration, + thumb = thumb +) fun TelegramMediaVideo( file: InputFile, entities: TextSourcesList, spoilered: Boolean = false, + showCaptionAboveMedia: Boolean = false, width: Int? = null, height: Int? = null, duration: Long? = null, thumb: InputFile? = null -) = TelegramMediaVideo(file, entities.makeString(), null, entities.toRawMessageEntities(), spoilered, width, height, duration, thumb) +) = TelegramMediaVideo( + file = file, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + spoilered = spoilered, + showCaptionAboveMedia = showCaptionAboveMedia, + width = width, + height = height, + duration = duration, + thumb = thumb +) @Serializable data class TelegramMediaVideo internal constructor ( @@ -46,6 +70,8 @@ data class TelegramMediaVideo internal constructor ( private val rawEntities: List? = null, @SerialName(hasSpoilerField) override val spoilered: Boolean = false, + @SerialName(showCaptionAboveMediaField) + override val showCaptionAboveMedia: Boolean = false, override val width: Int? = null, override val height: Int? = null, override val duration: Long? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/WithCustomizableCaptionTelegramMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/WithCustomizableCaptionTelegramMedia.kt new file mode 100644 index 0000000000..0556a5e40e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/WithCustomizableCaptionTelegramMedia.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.types.media + +import dev.inmo.tgbotapi.abstracts.WithCustomizableCaption + +sealed interface WithCustomizableCaptionTelegramMedia : TelegramMedia, WithCustomizableCaption diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 056f5de8bf..a69ba0a14c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -145,6 +145,8 @@ internal data class RawMessage( private val effect_id: EffectId? = null, + private val show_caption_above_media: Boolean = false, + private val reply_markup: InlineKeyboardMarkup? = null, // Business @@ -178,7 +180,8 @@ internal data class RawMessage( caption, adaptedCaptionEntities, has_media_spoiler ?: false, - quote + quote, + show_caption_above_media ) animation != null -> AnimationContent( animation, @@ -186,7 +189,8 @@ internal data class RawMessage( caption, adaptedCaptionEntities, has_media_spoiler ?: false, - quote + quote, + show_caption_above_media ) document != null -> DocumentContent( document, @@ -205,7 +209,8 @@ internal data class RawMessage( caption, adaptedCaptionEntities, has_media_spoiler ?: false, - quote + quote, + show_caption_above_media ) sticker != null -> StickerContent(sticker) dice != null -> DiceContent(dice) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt index 18fad944fd..dd30759e94 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.abstracts.SpoilerableData import dev.inmo.tgbotapi.abstracts.TextedInput +import dev.inmo.tgbotapi.abstracts.WithCustomizableCaption import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.* @@ -142,6 +143,7 @@ sealed interface MediaContent: MessageContent { } sealed interface SpoilerableMediaContent : MediaContent, SpoilerableData +sealed interface WithCustomizedCaptionMediaContent : MediaContent, TextedContent, WithCustomizableCaption @ClassCastsIncluded sealed interface ResendableContent { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt index fe9fe24abd..e9ed7abd1b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt @@ -38,6 +38,6 @@ sealed interface MediaGroupPartContent : TextedMediaContent { fun toMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia } -sealed interface VisualMediaGroupPartContent : MediaGroupPartContent, SpoilerableMediaContent { +sealed interface VisualMediaGroupPartContent : MediaGroupPartContent, SpoilerableMediaContent, WithCustomizedCaptionMediaContent { override fun toMediaGroupMemberTelegramMedia(): VisualMediaGroupMemberTelegramMedia } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt index 5c5c5bd903..1aa583143e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt @@ -19,8 +19,9 @@ data class AnimationContent( override val text: String?, override val textSources: TextSourcesList = emptyList(), override val spoilered: Boolean = false, - override val quote: TextQuote? = null -) : TextedMediaContent, SpoilerableMediaContent { + override val quote: TextQuote? = null, + override val showCaptionAboveMedia: Boolean = false +) : TextedMediaContent, SpoilerableMediaContent, WithCustomizedCaptionMediaContent { override fun createResend( chatId: ChatIdentifier, messageThreadId: MessageThreadId?, @@ -47,12 +48,13 @@ data class AnimationContent( ) override fun asTelegramMedia(): TelegramMediaAnimation = TelegramMediaAnimation( - media.fileId, - textSources, - spoilered, - media.width, - media.height, - media.duration, - media.thumbnail ?.fileId + file = media.fileId, + entities = textSources, + spoilered = spoilered, + showCaptionAboveMedia = showCaptionAboveMedia, + width = media.width, + height = media.height, + duration = media.duration, + thumb = media.thumbnail ?.fileId ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt index 76cd68f744..2b0b643f00 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt @@ -19,7 +19,8 @@ data class PhotoContent( override val text: String? = null, override val textSources: TextSourcesList = emptyList(), override val spoilered: Boolean = false, - override val quote: TextQuote? = null + override val quote: TextQuote? = null, + override val showCaptionAboveMedia: Boolean = false ) : MediaCollectionContent, VisualMediaGroupPartContent, WithOptionalQuoteInfo { override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") @@ -46,5 +47,5 @@ data class PhotoContent( override fun toMediaGroupMemberTelegramMedia(): TelegramMediaPhoto = asTelegramMedia() - override fun asTelegramMedia(): TelegramMediaPhoto = media.toTelegramMediaPhoto(textSources, spoilered) + override fun asTelegramMedia(): TelegramMediaPhoto = media.toTelegramMediaPhoto(textSources, spoilered, showCaptionAboveMedia) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt index 8086404b3b..08d72e5b17 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt @@ -18,7 +18,8 @@ data class VideoContent( override val text: String? = null, override val textSources: TextSourcesList = emptyList(), override val spoilered: Boolean = false, - override val quote: TextQuote? = null + override val quote: TextQuote? = null, + override val showCaptionAboveMedia: Boolean = false ) : VisualMediaGroupPartContent { override fun createResend( chatId: ChatIdentifier, @@ -48,5 +49,9 @@ data class VideoContent( override fun toMediaGroupMemberTelegramMedia(): TelegramMediaVideo = asTelegramMedia() - override fun asTelegramMedia(): TelegramMediaVideo = media.toTelegramMediaVideo(textSources) + override fun asTelegramMedia(): TelegramMediaVideo = media.toTelegramMediaVideo( + textSources = textSources, + spoilered = spoilered, + showCaptionAboveMedia = showCaptionAboveMedia + ) }