From febd6ce63cf6352776b1dc0b14cd51efcd8be2d9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 30 Dec 2022 20:10:35 +0600 Subject: [PATCH] support of has_media_spoiler in message and sendPhoto/sendVideo/sendAnimation --- .../tgbotapi/extensions/api/send/Replies.kt | 40 +++++++++++----- .../tgbotapi/extensions/api/send/Sends.kt | 48 ++++++++++++------- .../api/send/media/SendAnimation.kt | 22 ++++++--- .../extensions/api/send/media/SendPhoto.kt | 34 +++++++++---- .../extensions/api/send/media/SendVideo.kt | 22 ++++++--- .../abstracts/OptionallyWithSpoilerRequest.kt | 5 ++ .../requests/send/media/SendAnimation.kt | 9 +++- .../tgbotapi/requests/send/media/SendPhoto.kt | 9 +++- .../tgbotapi/requests/send/media/SendVideo.kt | 9 +++- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../inmo/tgbotapi/types/message/RawMessage.kt | 10 ++-- .../types/message/content/Abstracts.kt | 12 +++++ .../types/message/content/AbstractsMedia.kt | 2 +- .../types/message/content/AnimationContent.kt | 5 +- .../types/message/content/PhotoContent.kt | 3 +- .../types/message/content/VideoContent.kt | 3 +- 16 files changed, 173 insertions(+), 61 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyWithSpoilerRequest.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 0290897343..e22e4d39e1 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -379,6 +379,7 @@ suspend inline fun TelegramBot.replyWithAnimation( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -392,6 +393,7 @@ suspend inline fun TelegramBot.replyWithAnimation( thumb, text, parseMode, + spoilered, duration, width, height, @@ -408,6 +410,7 @@ suspend inline fun TelegramBot.reply( animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -415,12 +418,13 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( to: Message, animation: InputFile, entities: TextSourcesList, + spoilered: Boolean = false, thumb: InputFile? = null, duration: Long? = null, width: Int? = null, @@ -434,6 +438,7 @@ suspend inline fun TelegramBot.replyWithAnimation( animation, thumb, entities, + spoilered, duration, width, height, @@ -449,6 +454,7 @@ suspend inline fun TelegramBot.reply( to: Message, animation: AnimationFile, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -456,7 +462,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(to.chat, animation, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Audio @@ -608,64 +614,70 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, photo: Photo, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photoSize, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( to: Message, fileId: InputFile, entities: TextSourcesList, + spoilered: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, photo: Photo, entities: TextSourcesList, + spoilered: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, photoSize: PhotoSize, entities: TextSourcesList, + spoilered: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Sticker @@ -697,6 +709,7 @@ suspend inline fun TelegramBot.replyWithVideo( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -704,24 +717,26 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithVideo( to: Message, video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -729,17 +744,18 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, video: VideoFile, entities: TextSourcesList, + spoilered: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // VideoNotes diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt index 45cdac1c67..70455fc405 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt @@ -56,6 +56,7 @@ suspend fun TelegramBot.send( animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -65,7 +66,7 @@ suspend fun TelegramBot.send( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAnimation] request @@ -77,6 +78,7 @@ suspend fun TelegramBot.send( animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -86,7 +88,7 @@ suspend fun TelegramBot.send( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAnimation] request @@ -97,6 +99,7 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, animation: AnimationFile, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -106,7 +109,7 @@ suspend fun TelegramBot.send( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chatId, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAnimation] request @@ -117,6 +120,7 @@ suspend fun TelegramBot.send( chat: Chat, animation: AnimationFile, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -126,7 +130,7 @@ suspend fun TelegramBot.send( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAudio] request @@ -688,13 +692,14 @@ suspend fun TelegramBot.send( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -706,13 +711,14 @@ suspend fun TelegramBot.send( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -724,13 +730,14 @@ suspend fun TelegramBot.send( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -742,13 +749,14 @@ suspend fun TelegramBot.send( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -759,13 +767,14 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, photo: Photo, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -776,13 +785,14 @@ suspend inline fun TelegramBot.send( chat: Chat, photo: Photo, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -793,13 +803,14 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, photoSize: PhotoSize, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -810,13 +821,14 @@ suspend inline fun TelegramBot.send( chat: Chat, photoSize: PhotoSize, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -1357,13 +1369,14 @@ suspend fun TelegramBot.send( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideo] request @@ -1375,13 +1388,14 @@ suspend fun TelegramBot.send( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideo] request @@ -1392,13 +1406,14 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, video: VideoFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideo] request @@ -1409,13 +1424,14 @@ suspend inline fun TelegramBot.send( chat: Chat, video: VideoFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideoNote] request 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 edfb5dfb29..623e44ccf2 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 @@ -23,6 +23,7 @@ suspend fun TelegramBot.sendAnimation( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -39,6 +40,7 @@ suspend fun TelegramBot.sendAnimation( thumb, text, parseMode, + spoilered, duration, width, height, @@ -60,6 +62,7 @@ suspend fun TelegramBot.sendAnimation( animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -70,7 +73,7 @@ suspend fun TelegramBot.sendAnimation( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -83,6 +86,7 @@ suspend fun TelegramBot.sendAnimation( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -92,7 +96,7 @@ suspend fun TelegramBot.sendAnimation( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -103,6 +107,7 @@ suspend fun TelegramBot.sendAnimation( animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -112,7 +117,7 @@ suspend fun TelegramBot.sendAnimation( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -124,6 +129,7 @@ suspend fun TelegramBot.sendAnimation( animation: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -139,6 +145,7 @@ suspend fun TelegramBot.sendAnimation( animation, thumb, entities, + spoilered, duration, width, height, @@ -159,6 +166,7 @@ suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: AnimationFile, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -169,7 +177,7 @@ suspend fun TelegramBot.sendAnimation( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, animation.fileId, animation.thumb ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -181,6 +189,7 @@ suspend fun TelegramBot.sendAnimation( animation: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -190,7 +199,7 @@ suspend fun TelegramBot.sendAnimation( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -200,6 +209,7 @@ suspend fun TelegramBot.sendAnimation( chat: Chat, animation: AnimationFile, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -209,4 +219,4 @@ suspend fun TelegramBot.sendAnimation( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 c091231391..3626bb8f66 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 @@ -22,6 +22,7 @@ suspend fun TelegramBot.sendPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -34,6 +35,7 @@ suspend fun TelegramBot.sendPhoto( fileId, text, parseMode, + spoilered, threadId, disableNotification, protectContent, @@ -52,13 +54,14 @@ suspend fun TelegramBot.sendPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -69,13 +72,14 @@ suspend fun TelegramBot.sendPhoto( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -86,13 +90,14 @@ suspend fun TelegramBot.sendPhoto( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -103,13 +108,14 @@ suspend fun TelegramBot.sendPhoto( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize.fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -120,13 +126,14 @@ suspend fun TelegramBot.sendPhoto( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -137,6 +144,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -148,6 +156,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId, fileId, entities, + spoilered, threadId, disableNotification, protectContent, @@ -165,13 +174,14 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, fileId, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -181,13 +191,14 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -197,13 +208,14 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -213,13 +225,14 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photoSize: PhotoSize, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize.fileId, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -229,10 +242,11 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photoSize: PhotoSize, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 c9123bab69..3b1b6c7481 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 @@ -23,6 +23,7 @@ suspend fun TelegramBot.sendVideo( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -39,6 +40,7 @@ suspend fun TelegramBot.sendVideo( thumb, text, parseMode, + spoilered, duration, width, height, @@ -61,13 +63,14 @@ suspend fun TelegramBot.sendVideo( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -79,6 +82,7 @@ suspend fun TelegramBot.sendVideo( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -88,7 +92,7 @@ suspend fun TelegramBot.sendVideo( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -100,13 +104,14 @@ suspend fun TelegramBot.sendVideo( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -117,6 +122,7 @@ suspend inline fun TelegramBot.sendVideo( video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -132,6 +138,7 @@ suspend inline fun TelegramBot.sendVideo( video, thumb, entities, + spoilered, duration, width, height, @@ -153,13 +160,14 @@ suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: VideoFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -170,6 +178,7 @@ suspend inline fun TelegramBot.sendVideo( video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -179,7 +188,7 @@ suspend inline fun TelegramBot.sendVideo( replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -190,10 +199,11 @@ suspend inline fun TelegramBot.sendVideo( chat: Chat, video: VideoFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyWithSpoilerRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyWithSpoilerRequest.kt new file mode 100644 index 0000000000..9ad3583e82 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyWithSpoilerRequest.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.requests.send.abstracts + +interface OptionallyWithSpoilerRequest { + val spoilered: Boolean +} 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 576ab84087..ec83f84067 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 @@ -25,6 +25,7 @@ fun SendAnimation( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -47,6 +48,7 @@ fun SendAnimation( text, parseMode, null, + spoilered, duration, width, height, @@ -73,6 +75,7 @@ fun SendAnimation( animation: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -95,6 +98,7 @@ fun SendAnimation( entities.makeString(), null, entities.toRawMessageEntities(), + spoilered, duration, width, height, @@ -133,6 +137,8 @@ data class SendAnimationData internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(hasSpoilerField) + override val spoilered: Boolean = false, @SerialName(durationField) override val duration: Long? = null, @SerialName(widthField) @@ -157,7 +163,8 @@ data class SendAnimationData internal constructor( TextableSendMessageRequest>, ThumbedSendMessageRequest>, DuratedSendMessageRequest>, - SizedSendMessageRequest> + SizedSendMessageRequest>, + OptionallyWithSpoilerRequest { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) 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 e2a7dde628..0c54d063e5 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 @@ -23,6 +23,7 @@ fun SendPhoto( photo: InputFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -36,6 +37,7 @@ fun SendPhoto( text, parseMode, null, + spoilered, threadId, disableNotification, protectContent, @@ -55,6 +57,7 @@ fun SendPhoto( chatId: ChatIdentifier, photo: InputFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -68,6 +71,7 @@ fun SendPhoto( entities.makeString(), null, entities.toRawMessageEntities(), + spoilered, threadId, disableNotification, protectContent, @@ -98,6 +102,8 @@ data class SendPhotoData internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(hasSpoilerField) + override val spoilered: Boolean = false, @SerialName(messageThreadIdField) override val threadId: MessageThreadId? = chatId.threadId, @SerialName(disableNotificationField) @@ -113,7 +119,8 @@ data class SendPhotoData internal constructor( ) : DataRequest>, SendMessageRequest>, ReplyingMarkupSendMessageRequest>, - TextableSendMessageRequest> + TextableSendMessageRequest>, + OptionallyWithSpoilerRequest { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) 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 8f78a4c37b..0b749649d2 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 @@ -25,6 +25,7 @@ fun SendVideo( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -48,6 +49,7 @@ fun SendVideo( text, parseMode, null, + spoilered, duration, width, height, @@ -75,6 +77,7 @@ fun SendVideo( video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -98,6 +101,7 @@ fun SendVideo( entities.makeString(), null, entities.toRawMessageEntities(), + spoilered, duration, width, height, @@ -137,6 +141,8 @@ data class SendVideoData internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(hasSpoilerField) + override val spoilered: Boolean = false, @SerialName(durationField) override val duration: Long? = null, @SerialName(widthField) @@ -163,7 +169,8 @@ data class SendVideoData internal constructor( TextableSendMessageRequest>, ThumbedSendMessageRequest>, DuratedSendMessageRequest>, - SizedSendMessageRequest> + SizedSendMessageRequest>, + OptionallyWithSpoilerRequest { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) 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 5a6d2f3398..6f53574fb3 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 @@ -228,6 +228,7 @@ const val allowsMultipleAnswersField = "allows_multiple_answers" const val isAnonymousField = "is_anonymous" const val canManageTopicsField = "can_manage_topics" const val captionEntitiesField = "caption_entities" +const val hasSpoilerField = "has_spoiler" 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/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 5a98fdf863..32b254f2ad 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 @@ -58,6 +58,7 @@ internal data class RawMessage( private val entities: RawMessageEntities? = null, private val caption: String? = null, private val caption_entities: RawMessageEntities? = null, + private val has_media_spoiler: Boolean? = null, private val audio: AudioFile? = null, private val document: DocumentFile? = null, private val animation: AnimationFile? = null, @@ -129,13 +130,15 @@ internal data class RawMessage( video != null -> VideoContent( video, caption, - adaptedCaptionEntities + adaptedCaptionEntities, + has_media_spoiler ?: false ) animation != null -> AnimationContent( animation, document, caption, - adaptedCaptionEntities + adaptedCaptionEntities, + has_media_spoiler ?: false ) document != null -> DocumentContent( document, @@ -150,7 +153,8 @@ internal data class RawMessage( photo != null -> PhotoContent( photo.toList(), caption, - adaptedCaptionEntities + adaptedCaptionEntities, + has_media_spoiler ?: false ) 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 d7087fc5c7..d6c60b1748 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 @@ -23,6 +23,7 @@ sealed interface MessageContent: ResendableContent { mediaGroupPartContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, textedMediaContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, mediaContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, + spoilerableMediaContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, mediaCollectionContentAdditionalBuilder: PolymorphicModuleBuilder>.() -> Unit = {}, additionalBuilder: PolymorphicModuleBuilder.() -> Unit = {} ) = SerializersModule { @@ -66,6 +67,13 @@ sealed interface MessageContent: ResendableContent { mediaContentAdditionalBuilder() } + polymorphic(SpoilerableMediaContent::class) { + subclass(VideoContent::class) + subclass(PhotoContent::class) + subclass(AnimationContent::class) + + spoilerableMediaContentAdditionalBuilder() + } polymorphic(TextedMediaContent::class) { subclass(PhotoContent::class) subclass(VoiceContent::class) @@ -111,6 +119,10 @@ sealed interface MediaContent: MessageContent { fun asTelegramMedia(): TelegramMedia } +sealed interface SpoilerableMediaContent : MediaContent { + val spoilered: Boolean +} + @ClassCastsIncluded sealed interface ResendableContent { fun createResend( 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 21dd74142f..724552a98f 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 @@ -39,6 +39,6 @@ sealed interface MediaGroupPartContent : TextedMediaContent { fun toMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia } -sealed interface VisualMediaGroupPartContent : MediaGroupPartContent { +sealed interface VisualMediaGroupPartContent : MediaGroupPartContent, SpoilerableMediaContent { 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 8c842f36c6..63b9d77466 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 @@ -18,8 +18,9 @@ data class AnimationContent( override val media: AnimationFile, val includedDocument: DocumentFile?, override val text: String?, - override val textSources: TextSourcesList = emptyList() -) : TextedMediaContent { + override val textSources: TextSourcesList = emptyList(), + override val spoilered: Boolean = false +) : TextedMediaContent, SpoilerableMediaContent { override fun createResend( chatId: ChatIdentifier, messageThreadId: MessageThreadId?, 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 75a488771e..497b5209b3 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 @@ -17,7 +17,8 @@ import kotlinx.serialization.Serializable data class PhotoContent( override val mediaCollection: Photo, override val text: String? = null, - override val textSources: TextSourcesList = emptyList() + override val textSources: TextSourcesList = emptyList(), + override val spoilered: Boolean = false ) : MediaCollectionContent, VisualMediaGroupPartContent { override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") 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 53312ed522..a99d3ff80a 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 @@ -17,7 +17,8 @@ import kotlinx.serialization.Serializable data class VideoContent( override val media: VideoFile, override val text: String? = null, - override val textSources: TextSourcesList = emptyList() + override val textSources: TextSourcesList = emptyList(), + override val spoilered: Boolean = false ) : VisualMediaGroupPartContent { override fun createResend( chatId: ChatIdentifier,