From 28eecfa3effb169dc18bcc46f50af719fb4fba77 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 6 Feb 2020 21:23:59 +0600 Subject: [PATCH] add send animation extensions --- .../requests/send/media/SendAnimation.kt | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt index 0de73f8fdc..e8be272d5d 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.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.AnimationFile +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.AnimationContent @@ -112,3 +115,137 @@ data class SendAnimationFiles internal constructor( animationField to animation, thumbField to thumb ) + +suspend fun RequestsExecutor.sendAnimation( + chatId: ChatIdentifier, + animation: FileId, + thumb: FileId? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + SendAnimationData( + chatId, + animation.fileId, + thumb ?.fileId, + text, + parseMode, + duration, + width, + height, + disableNotification, + replyToMessageId, + replyMarkup + ) +) + +suspend fun RequestsExecutor.sendAnimation( + chatId: ChatIdentifier, + animation: AnimationFile, + thumb: PhotoSize? = animation.thumb, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendAnimation( + chatId, animation.fileId, thumb ?.fileId, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup +) + +suspend fun RequestsExecutor.sendAnimation( + chatId: ChatIdentifier, + animation: MultipartFile, + thumb: FileId? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + MultipartRequestImpl( + SendAnimationData( + chatId, null, thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup + ), + SendAnimationFiles(animation) + ) +) + +suspend fun RequestsExecutor.sendAnimation( + chatId: ChatIdentifier, + animation: MultipartFile, + thumb: MultipartFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + MultipartRequestImpl( + SendAnimationData( + chatId, null, null, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup + ), + SendAnimationFiles(animation, thumb) + ) +) + +suspend fun RequestsExecutor.sendAnimation( + chatId: ChatIdentifier, + animation: FileId, + thumb: MultipartFile, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + MultipartRequestImpl( + SendAnimationData( + chatId, animation.fileId, null, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup + ), + SendAnimationFiles(null, thumb) + ) +) + +suspend fun RequestsExecutor.sendAnimation( + chatId: ChatIdentifier, + animation: MultipartFile, + thumb: PhotoSize? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendAnimation( + chatId, animation, thumb ?.fileId , text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup +) + +suspend fun RequestsExecutor.sendAnimation( + chatId: ChatIdentifier, + animation: AnimationFile, + thumb: MultipartFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendAnimation( + chatId, animation.fileId, thumb, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup +) +