diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index d81c42fbc3..6547d1db14 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -410,6 +410,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, @@ -424,6 +425,7 @@ suspend inline fun TelegramBot.replyWithAnimation( thumb, text, parseMode, + spoilered, duration, width, height, @@ -441,6 +443,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, @@ -449,13 +452,14 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(toChatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( toChatId: IdChatIdentifier, toMessageId: MessageId, animation: InputFile, entities: TextSourcesList, + spoilered: Boolean = false, thumb: InputFile? = null, duration: Long? = null, width: Int? = null, @@ -470,6 +474,7 @@ suspend inline fun TelegramBot.replyWithAnimation( animation, thumb, entities, + spoilered, duration, width, height, @@ -486,6 +491,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, animation: AnimationFile, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -494,7 +500,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Audio @@ -671,12 +677,13 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -684,12 +691,13 @@ suspend inline fun TelegramBot.reply( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -697,12 +705,13 @@ suspend inline fun TelegramBot.reply( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -710,36 +719,39 @@ suspend inline fun TelegramBot.replyWithPhoto( toMessageId: MessageId, fileId: InputFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, photo: Photo, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, photoSize: PhotoSize, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Sticker @@ -776,6 +788,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, @@ -784,7 +797,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -792,12 +805,13 @@ suspend inline fun TelegramBot.reply( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + spoilered: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithVideo( toChatId: IdChatIdentifier, @@ -805,6 +819,7 @@ suspend inline fun TelegramBot.replyWithVideo( video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -813,19 +828,20 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, video: VideoFile, entities: TextSourcesList, + spoilered: Boolean = false, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // VideoNotes 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 a99d3ff80a..15d877b916 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 @@ -33,6 +33,7 @@ data class VideoContent( media.fileId, media.thumb ?.fileId, textSources, + spoilered, media.duration, media.width, media.height, diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index 60b258a418..500b28a94b 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -213,6 +213,7 @@ import dev.inmo.tgbotapi.types.media.DocumentMediaGroupMemberTelegramMedia import dev.inmo.tgbotapi.types.media.DuratedTelegramMedia import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia import dev.inmo.tgbotapi.types.media.SizedTelegramMedia +import dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramMediaAnimation import dev.inmo.tgbotapi.types.media.TelegramMediaAudio @@ -251,7 +252,11 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled @@ -315,6 +320,7 @@ import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.PhotoContent import dev.inmo.tgbotapi.types.message.content.PollContent import dev.inmo.tgbotapi.types.message.content.ResendableContent +import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent import dev.inmo.tgbotapi.types.message.content.StaticLocationContent import dev.inmo.tgbotapi.types.message.content.StickerContent import dev.inmo.tgbotapi.types.message.content.TextContent @@ -2643,6 +2649,16 @@ public inline fun TelegramMedia.sizedTelegramMediaOrThrow(): SizedTelegramMedia public inline fun TelegramMedia.ifSizedTelegramMedia(block: (SizedTelegramMedia) -> T): T? = sizedTelegramMediaOrNull() ?.let(block) +public inline fun TelegramMedia.spoilerableTelegramMediaOrNull(): SpoilerableTelegramMedia? = this + as? dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia + +public inline fun TelegramMedia.spoilerableTelegramMediaOrThrow(): SpoilerableTelegramMedia = this + as dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia + +public inline fun + TelegramMedia.ifSpoilerableTelegramMedia(block: (SpoilerableTelegramMedia) -> T): T? = + spoilerableTelegramMediaOrNull() ?.let(block) + public inline fun TelegramMedia.telegramMediaAnimationOrNull(): TelegramMediaAnimation? = this as? dev.inmo.tgbotapi.types.media.TelegramMediaAnimation @@ -2923,6 +2939,15 @@ public inline fun ChatEvent.forumTopicCreatedOrThrow(): ForumTopicCreated = this public inline fun ChatEvent.ifForumTopicCreated(block: (ForumTopicCreated) -> T): T? = forumTopicCreatedOrNull() ?.let(block) +public inline fun ChatEvent.forumTopicEditedOrNull(): ForumTopicEdited? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited + +public inline fun ChatEvent.forumTopicEditedOrThrow(): ForumTopicEdited = this as + dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited + +public inline fun ChatEvent.ifForumTopicEdited(block: (ForumTopicEdited) -> T): T? = + forumTopicEditedOrNull() ?.let(block) + public inline fun ChatEvent.forumTopicReopenedOrNull(): ForumTopicReopened? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened @@ -2932,6 +2957,34 @@ public inline fun ChatEvent.forumTopicReopenedOrThrow(): ForumTopicReopened = th public inline fun ChatEvent.ifForumTopicReopened(block: (ForumTopicReopened) -> T): T? = forumTopicReopenedOrNull() ?.let(block) +public inline fun ChatEvent.generalForumTopicHiddenOrNull(): GeneralForumTopicHidden? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden + +public inline fun ChatEvent.generalForumTopicHiddenOrThrow(): GeneralForumTopicHidden = this as + dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden + +public inline fun ChatEvent.ifGeneralForumTopicHidden(block: (GeneralForumTopicHidden) -> T): T? + = generalForumTopicHiddenOrNull() ?.let(block) + +public inline fun ChatEvent.generalForumTopicUnhiddenOrNull(): GeneralForumTopicUnhidden? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden + +public inline fun ChatEvent.generalForumTopicUnhiddenOrThrow(): GeneralForumTopicUnhidden = this as + dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden + +public inline fun + ChatEvent.ifGeneralForumTopicUnhidden(block: (GeneralForumTopicUnhidden) -> T): T? = + generalForumTopicUnhiddenOrNull() ?.let(block) + +public inline fun ChatEvent.writeAccessAllowedOrNull(): WriteAccessAllowed? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed + +public inline fun ChatEvent.writeAccessAllowedOrThrow(): WriteAccessAllowed = this as + dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed + +public inline fun ChatEvent.ifWriteAccessAllowed(block: (WriteAccessAllowed) -> T): T? = + writeAccessAllowedOrNull() ?.let(block) + public inline fun ChatEvent.videoChatEndedOrNull(): VideoChatEnded? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded @@ -3516,6 +3569,16 @@ public inline fun ResendableContent.mediaContentOrThrow(): MediaContent = this a public inline fun ResendableContent.ifMediaContent(block: (MediaContent) -> T): T? = mediaContentOrNull() ?.let(block) +public inline fun ResendableContent.spoilerableMediaContentOrNull(): SpoilerableMediaContent? = this + as? dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent + +public inline fun ResendableContent.spoilerableMediaContentOrThrow(): SpoilerableMediaContent = this + as dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent + +public inline fun + ResendableContent.ifSpoilerableMediaContent(block: (SpoilerableMediaContent) -> T): T? = + spoilerableMediaContentOrNull() ?.let(block) + public inline fun ResendableContent.audioMediaGroupPartContentOrNull(): AudioMediaGroupPartContent? = this as? dev.inmo.tgbotapi.types.message.content.AudioMediaGroupPartContent