diff --git a/CHANGELOG.md b/CHANGELOG.md index e80f2f6b00..a11a3fa8db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * New fields `ExtendedChannelChat#linkedGroupChatId` and `ExtendedSupergroupChat#linkedChannelChatId` * New fields `ExtendedSupergroupChat#location` * New fields `AudioFile#fileName` and `VideoFile#fileName` + * New fields `SendDocument#disableContentTypeDetection` and `InputMediaDocument#disableContentTypeDetection` ## 0.29.4 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt index 0b2db11bf8..961d512dc6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt @@ -14,6 +14,15 @@ import dev.inmo.tgbotapi.utils.mapOfNotNull import dev.inmo.tgbotapi.utils.throwRangeError import kotlinx.serialization.* +/** + * Use this method to send general files. On success, the sent [ContentMessage] with [DocumentContent] is returned. + * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * + * @param disableContentTypeDetection Disables automatic server-side content type detection for [document] [MultipartFile] + * + * @see ContentMessage + * @see DocumentContent + */ fun SendDocument( chatId: ChatIdentifier, document: InputFile, @@ -22,7 +31,8 @@ fun SendDocument( parseMode: ParseMode? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null + replyMarkup: KeyboardMarkup? = null, + disableContentTypeDetection: Boolean? = null ): Request> { val documentAsFileId = (document as? FileId) ?.fileId val documentAsFile = document as? MultipartFile @@ -37,7 +47,8 @@ fun SendDocument( parseMode, disableNotification, replyToMessageId, - replyMarkup + replyMarkup, + disableContentTypeDetection ) return if (documentAsFile == null && thumbAsFile == null) { @@ -53,6 +64,15 @@ fun SendDocument( private val commonResultDeserializer: DeserializationStrategy> = TelegramBotAPIMessageDeserializationStrategyClass() +/** + * Use this method to send general files. On success, the sent [ContentMessage] with [DocumentContent] is returned. + * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * + * @param disableContentTypeDetection Disables automatic server-side content type detection for [document] [MultipartFile] + * + * @see ContentMessage + * @see DocumentContent + */ @Serializable data class SendDocumentData internal constructor( @SerialName(chatIdField) @@ -70,7 +90,9 @@ data class SendDocumentData internal constructor( @SerialName(replyToMessageIdField) override val replyToMessageId: MessageIdentifier? = null, @SerialName(replyMarkupField) - override val replyMarkup: KeyboardMarkup? = null + override val replyMarkup: KeyboardMarkup? = null, + @SerialName(disableContentTypeDetectionField) + val disableContentTypeDetection: Boolean? = null ) : DataRequest>, SendMessageRequest>, ReplyingMarkupSendMessageRequest>, 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 3957c733d5..f56da81409 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 @@ -86,6 +86,7 @@ const val disableWebPagePreviewField = "disable_web_page_preview" const val disableNotificationField = "disable_notification" const val replyToMessageIdField = "reply_to_message_id" const val replyMarkupField = "reply_markup" +const val disableContentTypeDetectionField = "disable_content_type_detection" const val supportStreamingField = "support_streaming" const val livePeriodField = "live_period" const val isBotField = "is_bot" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt index 465b630c6a..a0fa37b7c0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt @@ -4,19 +4,32 @@ import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField +import dev.inmo.tgbotapi.types.disableContentTypeDetectionField import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.mediaField import kotlinx.serialization.* internal const val documentInputMediaType = "document" +/** + * Represents a general file to be sent. See https://core.telegram.org/bots/api#inputmediadocument + * + * @param disableContentTypeDetection Disables automatic server-side content type detection for files uploaded using + * multipart/form-data. Always used by Telegram system as true, if the document is sent as part of an album. + * + * @see InputFile + * @see MultipartFile + * @see FileId + */ @Serializable data class InputMediaDocument( override val file: InputFile, override val caption: String? = null, @SerialName(parseModeField) override val parseMode: ParseMode? = null, - override val thumb: InputFile? = null + override val thumb: InputFile? = null, + @SerialName(disableContentTypeDetectionField) + val disableContentTypeDetection: Boolean? = null ) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia, CaptionedOutput { override val type: String = documentInputMediaType