From 56663d8e735d30d895a0722149610052f34010bd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 6 Feb 2020 21:15:17 +0600 Subject: [PATCH] add send document extensions --- .../requests/send/media/SendDocument.kt | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt index 44ff036ec2..e770bc6f4e 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt @@ -1,5 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media +import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* @@ -7,6 +8,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile +import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.DocumentContent @@ -98,3 +101,118 @@ data class SendDocumentFiles internal constructor( documentField to document, thumbField to thumb ) + +suspend fun RequestsExecutor.sendDocument( + chatId: ChatIdentifier, + document: FileId, + thumb: FileId? = null, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + SendDocumentData( + chatId, + document.fileId, + thumb ?.fileId, + text, + parseMode, + disableNotification, + replyToMessageId, + replyMarkup + ) +) + +suspend fun RequestsExecutor.sendDocument( + chatId: ChatIdentifier, + document: DocumentFile, + thumb: PhotoSize? = document.thumb, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendDocument( + chatId, document.fileId, thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup +) + +suspend fun RequestsExecutor.sendDocument( + chatId: ChatIdentifier, + document: MultipartFile, + thumb: FileId? = null, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + MultipartRequestImpl( + SendDocumentData( + chatId, null, thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup + ), + SendDocumentFiles(document) + ) +) + +suspend fun RequestsExecutor.sendDocument( + chatId: ChatIdentifier, + document: MultipartFile, + thumb: MultipartFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + MultipartRequestImpl( + SendDocumentData( + chatId, null, null, text, parseMode, disableNotification, replyToMessageId, replyMarkup + ), + SendDocumentFiles(document, thumb) + ) +) + +suspend fun RequestsExecutor.sendDocument( + chatId: ChatIdentifier, + document: FileId, + thumb: MultipartFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + MultipartRequestImpl( + SendDocumentData( + chatId, document.fileId, null, text, parseMode, disableNotification, replyToMessageId, replyMarkup + ), + SendDocumentFiles(null, thumb) + ) +) + +suspend fun RequestsExecutor.sendDocument( + chatId: ChatIdentifier, + document: MultipartFile, + thumb: PhotoSize? = null, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendDocument( + chatId, document, thumb ?.fileId , text, parseMode, disableNotification, replyToMessageId, replyMarkup +) + +suspend fun RequestsExecutor.sendDocument( + chatId: ChatIdentifier, + document: DocumentFile, + thumb: MultipartFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendDocument( + chatId, document.fileId, thumb, text, parseMode, disableNotification, replyToMessageId, replyMarkup +)