mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-25 00:36:15 +00:00
migration from CaptionedInput
This commit is contained in:
@@ -2,15 +2,23 @@ package dev.inmo.tgbotapi.CommonAbstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
|
||||
interface Captioned {
|
||||
const val CaptionDeprecation = "Captioned interface and others will be removed soon and not recommended to use"
|
||||
|
||||
@Deprecated(CaptionDeprecation)
|
||||
interface Captioned : Texted {
|
||||
@Deprecated(CaptionDeprecation)
|
||||
val caption: String?
|
||||
get() = text
|
||||
}
|
||||
|
||||
interface CaptionedInput : Captioned {
|
||||
@Deprecated(CaptionDeprecation)
|
||||
interface CaptionedInput : Captioned, TextedInput {
|
||||
/**
|
||||
* Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
*/
|
||||
@Deprecated(CaptionDeprecation)
|
||||
val captionEntities: List<TextPart>
|
||||
get() = textEntities
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ fun SendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
|
||||
@@ -20,7 +20,7 @@ fun SendAudio(
|
||||
chatId: ChatIdentifier,
|
||||
audio: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
performer: String? = null,
|
||||
|
||||
@@ -29,7 +29,7 @@ fun SendDocument(
|
||||
chatId: ChatIdentifier,
|
||||
document: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
|
||||
@@ -18,7 +18,7 @@ import kotlinx.serialization.*
|
||||
fun SendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photo: InputFile,
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
|
||||
@@ -20,7 +20,7 @@ fun SendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
|
||||
@@ -19,7 +19,7 @@ import kotlinx.serialization.*
|
||||
fun SendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: InputFile,
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
|
||||
@@ -62,7 +62,7 @@ data class InputMediaAudio internal constructor(
|
||||
}
|
||||
|
||||
fun AudioFile.toInputMediaAudio(
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
title: String? = this.title
|
||||
): InputMediaAudio = InputMediaAudio(
|
||||
|
||||
@@ -13,11 +13,11 @@ internal const val documentInputMediaType = "document"
|
||||
|
||||
fun InputMediaDocument(
|
||||
file: InputFile,
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
thumb: InputFile? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
) = InputMediaDocument(file, caption, parseMode, null, thumb, disableContentTypeDetection)
|
||||
) = InputMediaDocument(file, text, parseMode, null, thumb, disableContentTypeDetection)
|
||||
|
||||
fun InputMediaDocument(
|
||||
file: InputFile,
|
||||
@@ -62,11 +62,11 @@ data class InputMediaDocument internal constructor(
|
||||
}
|
||||
|
||||
fun DocumentFile.toInputMediaDocument(
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null
|
||||
) = InputMediaDocument(
|
||||
fileId,
|
||||
caption,
|
||||
text,
|
||||
parseMode,
|
||||
thumb ?.fileId
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ data class InputMediaPhoto internal constructor(
|
||||
}
|
||||
|
||||
fun PhotoSize.toInputMediaPhoto(
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null
|
||||
): InputMediaPhoto = InputMediaPhoto(
|
||||
fileId,
|
||||
|
||||
@@ -34,7 +34,7 @@ data class VideoFile(
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun VideoFile.toInputMediaVideo(
|
||||
caption: String? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null
|
||||
) = InputMediaVideo(
|
||||
fileId,
|
||||
|
||||
@@ -8,7 +8,7 @@ data class Game(
|
||||
override val title: String,
|
||||
val description: String,
|
||||
val photo: Photo,
|
||||
override val caption: String? = null,
|
||||
override val captionEntities: List<TextPart> = emptyList(),
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList(),
|
||||
val animation: AnimationFile? = null
|
||||
) : Titled, CaptionedInput
|
||||
) : Titled, CaptionedInput, TextedInput
|
||||
|
||||
@@ -16,9 +16,9 @@ internal data class RawGame(
|
||||
@SerialName(photoField)
|
||||
private val photo: Photo,
|
||||
@SerialName(textField)
|
||||
private val caption: String? = null,
|
||||
private val text: String? = null,
|
||||
@SerialName(textEntitiesField)
|
||||
private val captionEntities: RawMessageEntities = emptyList(),
|
||||
private val textEntities: RawMessageEntities = emptyList(),
|
||||
@SerialName(animationField)
|
||||
private val animation: AnimationFile? = null
|
||||
) {
|
||||
@@ -27,8 +27,8 @@ internal data class RawGame(
|
||||
title,
|
||||
description,
|
||||
photo,
|
||||
caption,
|
||||
caption ?.let { _ -> captionEntities.asTextParts(caption) } ?: emptyList(),
|
||||
text,
|
||||
text ?.let { _ -> textEntities.asTextParts(text) } ?: emptyList(),
|
||||
animation
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.message.content.abstracts
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput
|
||||
import dev.inmo.tgbotapi.types.InputMedia.*
|
||||
|
||||
interface MediaGroupContent : MediaContent, CaptionedInput {
|
||||
interface MediaGroupContent : MediaContent, CaptionedInput, TextedInput {
|
||||
fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
data class AnimationContent(
|
||||
override val media: AnimationFile,
|
||||
val includedDocument: DocumentFile?,
|
||||
override val caption: String?,
|
||||
override val captionEntities: List<TextPart>
|
||||
) : MediaContent, CaptionedInput {
|
||||
override val text: String?,
|
||||
override val textEntities: List<TextPart>
|
||||
) : MediaContent, CaptionedInput, TextedInput {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean,
|
||||
|
||||
@@ -15,8 +15,8 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent
|
||||
|
||||
data class AudioContent(
|
||||
override val media: AudioFile,
|
||||
override val caption: String? = null,
|
||||
override val captionEntities: List<TextPart> = emptyList()
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
) : AudioMediaGroupContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
||||
@@ -16,8 +16,8 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
|
||||
data class DocumentContent(
|
||||
override val media: DocumentFile,
|
||||
override val caption: String? = null,
|
||||
override val captionEntities: List<TextPart> = emptyList()
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
) : DocumentMediaGroupContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
@@ -43,10 +43,10 @@ data class DocumentContent(
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun MediaContent.asDocumentContent() = when (this) {
|
||||
is CaptionedInput -> DocumentContent(
|
||||
is TextedInput -> DocumentContent(
|
||||
media.asDocumentFile(),
|
||||
caption,
|
||||
captionEntities
|
||||
text,
|
||||
textEntities
|
||||
)
|
||||
else -> DocumentContent(
|
||||
media.asDocumentFile()
|
||||
|
||||
@@ -16,8 +16,8 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||
|
||||
data class PhotoContent(
|
||||
override val mediaCollection: Photo,
|
||||
override val caption: String? = null,
|
||||
override val captionEntities: List<TextPart> = emptyList()
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
) : MediaCollectionContent<PhotoSize>, VisualMediaGroupContent {
|
||||
override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content")
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||
|
||||
data class VideoContent(
|
||||
override val media: VideoFile,
|
||||
override val caption: String? = null,
|
||||
override val captionEntities: List<TextPart> = emptyList()
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
) : VisualMediaGroupContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
||||
@@ -13,9 +13,9 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
|
||||
data class VoiceContent(
|
||||
override val media: VoiceFile,
|
||||
override val caption: String? = null,
|
||||
override val captionEntities: List<TextPart> = emptyList()
|
||||
) : MediaContent, CaptionedInput {
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
) : MediaContent, CaptionedInput, TextedInput {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean,
|
||||
|
||||
Reference in New Issue
Block a user