mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
add spoilered in telegrammedia
This commit is contained in:
parent
febd6ce63c
commit
8b5da90e28
@ -0,0 +1,5 @@
|
|||||||
|
package dev.inmo.tgbotapi.abstracts
|
||||||
|
|
||||||
|
interface SpoilerableData {
|
||||||
|
val spoilered: Boolean
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.abstracts
|
package dev.inmo.tgbotapi.requests.send.abstracts
|
||||||
|
|
||||||
interface OptionallyWithSpoilerRequest {
|
import dev.inmo.tgbotapi.abstracts.SpoilerableData
|
||||||
val spoilered: Boolean
|
|
||||||
}
|
interface OptionallyWithSpoilerRequest : SpoilerableData
|
||||||
|
@ -34,11 +34,13 @@ data class VideoFile(
|
|||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun VideoFile.toTelegramMediaVideo(
|
inline fun VideoFile.toTelegramMediaVideo(
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null
|
parseMode: ParseMode? = null,
|
||||||
|
spoilered: Boolean = false
|
||||||
) = TelegramMediaVideo(
|
) = TelegramMediaVideo(
|
||||||
fileId,
|
fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
|
spoilered,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
duration,
|
duration,
|
||||||
@ -47,10 +49,12 @@ inline fun VideoFile.toTelegramMediaVideo(
|
|||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun VideoFile.toTelegramMediaVideo(
|
inline fun VideoFile.toTelegramMediaVideo(
|
||||||
textSources: TextSourcesList
|
textSources: TextSourcesList,
|
||||||
|
spoilered: Boolean = false
|
||||||
) = TelegramMediaVideo(
|
) = TelegramMediaVideo(
|
||||||
fileId,
|
fileId,
|
||||||
textSources,
|
textSources,
|
||||||
|
spoilered,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
duration,
|
duration,
|
||||||
|
@ -20,4 +20,4 @@ sealed interface AudioMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMed
|
|||||||
sealed interface DocumentMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMedia
|
sealed interface DocumentMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMedia
|
||||||
|
|
||||||
@Serializable(MediaGroupMemberTelegramMediaSerializer::class)
|
@Serializable(MediaGroupMemberTelegramMediaSerializer::class)
|
||||||
sealed interface VisualMediaGroupMemberTelegramMedia : MediaGroupMemberTelegramMedia
|
sealed interface VisualMediaGroupMemberTelegramMedia : MediaGroupMemberTelegramMedia, SpoilerableTelegramMedia
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.media
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.SpoilerableData
|
||||||
|
|
||||||
|
sealed interface SpoilerableTelegramMedia : TelegramMedia, SpoilerableData
|
@ -18,15 +18,17 @@ fun TelegramMediaAnimation(
|
|||||||
file: InputFile,
|
file: InputFile,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
|
spoilered: Boolean = false,
|
||||||
width: Int? = null,
|
width: Int? = null,
|
||||||
height: Int? = null,
|
height: Int? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
thumb: InputFile? = null
|
thumb: InputFile? = null
|
||||||
) = TelegramMediaAnimation(file, text, parseMode, null, width, height, duration, thumb)
|
) = TelegramMediaAnimation(file, text, parseMode, null, spoilered, width, height, duration, thumb)
|
||||||
|
|
||||||
fun TelegramMediaAnimation(
|
fun TelegramMediaAnimation(
|
||||||
file: InputFile,
|
file: InputFile,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
|
spoilered: Boolean = false,
|
||||||
width: Int? = null,
|
width: Int? = null,
|
||||||
height: Int? = null,
|
height: Int? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
@ -36,6 +38,7 @@ fun TelegramMediaAnimation(
|
|||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
|
spoilered,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
duration,
|
duration,
|
||||||
@ -51,11 +54,13 @@ data class TelegramMediaAnimation internal constructor(
|
|||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(captionEntitiesField)
|
@SerialName(captionEntitiesField)
|
||||||
private val rawEntities: List<RawMessageEntity>? = null,
|
private val rawEntities: List<RawMessageEntity>? = null,
|
||||||
|
@SerialName(hasSpoilerField)
|
||||||
|
override val spoilered: Boolean = false,
|
||||||
override val width: Int? = null,
|
override val width: Int? = null,
|
||||||
override val height: Int? = null,
|
override val height: Int? = null,
|
||||||
override val duration: Long? = null,
|
override val duration: Long? = null,
|
||||||
override val thumb: InputFile? = null
|
override val thumb: InputFile? = null
|
||||||
) : TelegramMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TextedOutput {
|
) : TelegramMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TextedOutput, SpoilerableTelegramMedia {
|
||||||
override val type: String = "animation"
|
override val type: String = "animation"
|
||||||
override val textSources: TextSourcesList? by lazy {
|
override val textSources: TextSourcesList? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
|
@ -18,13 +18,15 @@ internal const val photoTelegramMediaType = "photo"
|
|||||||
fun TelegramMediaPhoto(
|
fun TelegramMediaPhoto(
|
||||||
file: InputFile,
|
file: InputFile,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null
|
parseMode: ParseMode? = null,
|
||||||
) = TelegramMediaPhoto(file, text, parseMode, null)
|
spoilered: Boolean = false
|
||||||
|
) = TelegramMediaPhoto(file, text, parseMode, null, spoilered)
|
||||||
|
|
||||||
fun TelegramMediaPhoto(
|
fun TelegramMediaPhoto(
|
||||||
file: InputFile,
|
file: InputFile,
|
||||||
entities: TextSourcesList
|
entities: TextSourcesList,
|
||||||
) = TelegramMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities())
|
spoilered: Boolean = false
|
||||||
|
) = TelegramMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities(), spoilered)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class TelegramMediaPhoto internal constructor(
|
data class TelegramMediaPhoto internal constructor(
|
||||||
@ -34,7 +36,9 @@ data class TelegramMediaPhoto internal constructor(
|
|||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(captionEntitiesField)
|
@SerialName(captionEntitiesField)
|
||||||
private val rawEntities: List<RawMessageEntity>? = null
|
private val rawEntities: List<RawMessageEntity>? = null,
|
||||||
|
@SerialName(hasSpoilerField)
|
||||||
|
override val spoilered: Boolean = false,
|
||||||
) : TelegramMedia, VisualMediaGroupMemberTelegramMedia {
|
) : TelegramMedia, VisualMediaGroupMemberTelegramMedia {
|
||||||
override val type: String = photoTelegramMediaType
|
override val type: String = photoTelegramMediaType
|
||||||
override val textSources: TextSourcesList? by lazy {
|
override val textSources: TextSourcesList? by lazy {
|
||||||
@ -50,16 +54,20 @@ data class TelegramMediaPhoto internal constructor(
|
|||||||
|
|
||||||
fun PhotoSize.toTelegramMediaPhoto(
|
fun PhotoSize.toTelegramMediaPhoto(
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null
|
parseMode: ParseMode? = null,
|
||||||
|
spoilered: Boolean = false
|
||||||
): TelegramMediaPhoto = TelegramMediaPhoto(
|
): TelegramMediaPhoto = TelegramMediaPhoto(
|
||||||
fileId,
|
fileId,
|
||||||
text,
|
text,
|
||||||
parseMode
|
parseMode,
|
||||||
|
spoilered
|
||||||
)
|
)
|
||||||
|
|
||||||
fun PhotoSize.toTelegramMediaPhoto(
|
fun PhotoSize.toTelegramMediaPhoto(
|
||||||
textSources: TextSourcesList = emptyList()
|
textSources: TextSourcesList = emptyList(),
|
||||||
|
spoilered: Boolean = false
|
||||||
): TelegramMediaPhoto = TelegramMediaPhoto(
|
): TelegramMediaPhoto = TelegramMediaPhoto(
|
||||||
fileId,
|
fileId,
|
||||||
textSources
|
textSources,
|
||||||
|
spoilered
|
||||||
)
|
)
|
||||||
|
@ -18,20 +18,22 @@ fun TelegramMediaVideo(
|
|||||||
file: InputFile,
|
file: InputFile,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
|
spoilered: Boolean = false,
|
||||||
width: Int? = null,
|
width: Int? = null,
|
||||||
height: Int? = null,
|
height: Int? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
thumb: InputFile? = null
|
thumb: InputFile? = null
|
||||||
) = TelegramMediaVideo(file, text, parseMode, null, width, height, duration, thumb)
|
) = TelegramMediaVideo(file, text, parseMode, null, spoilered, width, height, duration, thumb)
|
||||||
|
|
||||||
fun TelegramMediaVideo(
|
fun TelegramMediaVideo(
|
||||||
file: InputFile,
|
file: InputFile,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
|
spoilered: Boolean = false,
|
||||||
width: Int? = null,
|
width: Int? = null,
|
||||||
height: Int? = null,
|
height: Int? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
thumb: InputFile? = null
|
thumb: InputFile? = null
|
||||||
) = TelegramMediaVideo(file, entities.makeString(), null, entities.toRawMessageEntities(), width, height, duration, thumb)
|
) = TelegramMediaVideo(file, entities.makeString(), null, entities.toRawMessageEntities(), spoilered, width, height, duration, thumb)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class TelegramMediaVideo internal constructor (
|
data class TelegramMediaVideo internal constructor (
|
||||||
@ -42,6 +44,8 @@ data class TelegramMediaVideo internal constructor (
|
|||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(captionEntitiesField)
|
@SerialName(captionEntitiesField)
|
||||||
private val rawEntities: List<RawMessageEntity>? = null,
|
private val rawEntities: List<RawMessageEntity>? = null,
|
||||||
|
@SerialName(hasSpoilerField)
|
||||||
|
override val spoilered: Boolean = false,
|
||||||
override val width: Int? = null,
|
override val width: Int? = null,
|
||||||
override val height: Int? = null,
|
override val height: Int? = null,
|
||||||
override val duration: Long? = null,
|
override val duration: Long? = null,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types.message.content
|
package dev.inmo.tgbotapi.types.message.content
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.SpoilerableData
|
||||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
@ -119,9 +120,7 @@ sealed interface MediaContent: MessageContent {
|
|||||||
fun asTelegramMedia(): TelegramMedia
|
fun asTelegramMedia(): TelegramMedia
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed interface SpoilerableMediaContent : MediaContent {
|
sealed interface SpoilerableMediaContent : MediaContent, SpoilerableData
|
||||||
val spoilered: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded
|
||||||
sealed interface ResendableContent {
|
sealed interface ResendableContent {
|
||||||
|
@ -34,6 +34,7 @@ data class AnimationContent(
|
|||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
textSources,
|
textSources,
|
||||||
|
spoilered,
|
||||||
media.duration,
|
media.duration,
|
||||||
media.width,
|
media.width,
|
||||||
media.height,
|
media.height,
|
||||||
@ -48,6 +49,7 @@ data class AnimationContent(
|
|||||||
override fun asTelegramMedia(): TelegramMediaAnimation = TelegramMediaAnimation(
|
override fun asTelegramMedia(): TelegramMediaAnimation = TelegramMediaAnimation(
|
||||||
media.fileId,
|
media.fileId,
|
||||||
textSources,
|
textSources,
|
||||||
|
spoilered,
|
||||||
media.width,
|
media.width,
|
||||||
media.height,
|
media.height,
|
||||||
media.duration,
|
media.duration,
|
||||||
|
@ -34,6 +34,7 @@ data class PhotoContent(
|
|||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
textSources,
|
textSources,
|
||||||
|
spoilered,
|
||||||
messageThreadId,
|
messageThreadId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
@ -44,5 +45,5 @@ data class PhotoContent(
|
|||||||
|
|
||||||
override fun toMediaGroupMemberTelegramMedia(): TelegramMediaPhoto = asTelegramMedia()
|
override fun toMediaGroupMemberTelegramMedia(): TelegramMediaPhoto = asTelegramMedia()
|
||||||
|
|
||||||
override fun asTelegramMedia(): TelegramMediaPhoto = media.toTelegramMediaPhoto(textSources)
|
override fun asTelegramMedia(): TelegramMediaPhoto = media.toTelegramMediaPhoto(textSources, spoilered)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user