1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 09:07:12 +00:00

add send document extensions

This commit is contained in:
InsanusMokrassar 2020-02-06 21:15:17 +06:00
parent 2fd842746b
commit 56663d8e73

View File

@ -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
)