1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

Common Captioned

This commit is contained in:
InsanusMokrassar 2019-06-28 18:43:54 +08:00
parent 04ddb6c7b8
commit 1926a9141b
27 changed files with 67 additions and 46 deletions

View File

@ -11,6 +11,9 @@
### 0.16.1 ### 0.16.1
* Now old uncommon `CaptionedMediaContent` and `CaptionedInputMedia` are replaced by almost the same
interfaces `CaptionedInput` and `CaptionedOutput`. They are both implementing `Captioned` interface
## 0.15.0 ## 0.15.0
* Old `UpdatesPoller` removed (was deprecated) * Old `UpdatesPoller` removed (was deprecated)

View File

@ -1,8 +1,16 @@
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
interface Captioned { interface Captioned {
val caption: String? val caption: String?
}
interface CaptionedOutput : Captioned {
val parseMode: ParseMode? val parseMode: ParseMode?
} }
interface CaptionedInput : Captioned {
val captionEntities: List<MessageEntity>
}

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.audio package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.audio
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult
const val inlineQueryResultAudioType = "audio" const val inlineQueryResultAudioType = "audio"
interface InlineQueryResultAudioCommon : InlineQueryResult, interface InlineQueryResultAudioCommon : InlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.document package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.document
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultDocumentType = "document" const val inlineQueryResultDocumentType = "document"
@ -8,5 +8,5 @@ const val inlineQueryResultDocumentType = "document"
interface InlineQueryResultDocumentCommon : InlineQueryResult, interface InlineQueryResultDocumentCommon : InlineQueryResult,
TitledInlineQueryResult, TitledInlineQueryResult,
DescribedInlineQueryResult, DescribedInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.gif package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.gif
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultGifType = "gif" const val inlineQueryResultGifType = "gif"
interface InlineQueryResultGifCommon : InlineQueryResult, interface InlineQueryResultGifCommon : InlineQueryResult,
OptionallyTitledInlineQueryResult, OptionallyTitledInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultMpeg4GifType = "mpeg4_gif" const val inlineQueryResultMpeg4GifType = "mpeg4_gif"
interface InlineQueryResultMpeg4GifCommon : InlineQueryResult, interface InlineQueryResultMpeg4GifCommon : InlineQueryResult,
OptionallyTitledInlineQueryResult, OptionallyTitledInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.photo package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.photo
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultPhotoType = "photo" const val inlineQueryResultPhotoType = "photo"
@ -8,5 +8,5 @@ const val inlineQueryResultPhotoType = "photo"
interface InlineQueryResultPhotoCommon : InlineQueryResult, interface InlineQueryResultPhotoCommon : InlineQueryResult,
OptionallyTitledInlineQueryResult, OptionallyTitledInlineQueryResult,
DescribedInlineQueryResult, DescribedInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultVideoType = "video" const val inlineQueryResultVideoType = "video"
@ -8,5 +8,5 @@ const val inlineQueryResultVideoType = "video"
interface InlineQueryResultVideoCommon : InlineQueryResult, interface InlineQueryResultVideoCommon : InlineQueryResult,
TitledInlineQueryResult, TitledInlineQueryResult,
DescribedInlineQueryResult, DescribedInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultVoiceType = "voice" const val inlineQueryResultVoiceType = "voice"
interface InlineQueryResultVoiceCommon : InlineQueryResult, interface InlineQueryResultVoiceCommon : InlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult, WithInputMessageContentInlineQueryResult,
TitledInlineQueryResult TitledInlineQueryResult

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InputMessageContent package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InputMessageContent
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
@ -18,4 +18,4 @@ data class InputTextMessageContent(
override val parseMode: ParseMode? = null, override val parseMode: ParseMode? = null,
@SerialName(disableWebPagePreviewField) @SerialName(disableWebPagePreviewField)
override val disableWebPagePreview: Boolean? = null override val disableWebPagePreview: Boolean? = null
) : Captioned, DisableWebPagePreview, InputMessageContent ) : CaptionedOutput, DisableWebPagePreview, InputMessageContent

View File

@ -1,8 +1,9 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
interface CaptionedInputMedia: InputMedia { @Deprecated(
val caption: String? "Deprecated due to replace by common type CaptionedOutput",
val parseMode: ParseMode? ReplaceWith("CaptionedOutput", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput")
} )
typealias CaptionedInputMedia = CaptionedOutput

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
@ -17,7 +18,7 @@ data class InputMediaAnimation(
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
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia { ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedOutput {
override val type: String = "animation" override val type: String = "animation"
@SerialName(mediaField) @SerialName(mediaField)

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
@ -18,7 +19,7 @@ data class InputMediaAudio(
override val performer: String? = null, override val performer: String? = null,
override val title: String? = null, override val title: String? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, CaptionedInputMedia, Performerable { ) : InputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, CaptionedOutput, Performerable {
override val type: String = "audio" override val type: String = "audio"
@SerialName(mediaField) @SerialName(mediaField)

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
@ -14,7 +15,7 @@ data class InputMediaDocument(
@SerialName(parseModeField) @SerialName(parseModeField)
override val parseMode: ParseMode? = null, override val parseMode: ParseMode? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, ThumbedInputMedia, CaptionedInputMedia { ) : InputMedia, ThumbedInputMedia, CaptionedOutput {
override val type: String = "document" override val type: String = "document"
@SerialName(mediaField) @SerialName(mediaField)

View File

@ -13,7 +13,7 @@ data class InputMediaPhoto(
override val caption: String? = null, override val caption: String? = null,
@SerialName(parseModeField) @SerialName(parseModeField)
override val parseMode: ParseMode? = null override val parseMode: ParseMode? = null
) : InputMedia, CaptionedInputMedia, MediaGroupMemberInputMedia { ) : InputMedia, MediaGroupMemberInputMedia {
override val type: String = "photo" override val type: String = "photo"
override fun serialize(format: StringFormat): String = format.stringify(serializer(), this) override fun serialize(format: StringFormat): String = format.stringify(serializer(), this)

View File

@ -16,7 +16,7 @@ data class InputMediaVideo(
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
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia, MediaGroupMemberInputMedia { ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, MediaGroupMemberInputMedia {
override val type: String = "video" override val type: String = "video"
override fun serialize(format: StringFormat): String = format.stringify(serializer(), this) override fun serialize(format: StringFormat): String = format.stringify(serializer(), this)

View File

@ -1,10 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.StringFormat import kotlinx.serialization.StringFormat
@Serializable(MediaGroupMemberInputMediaSerializer::class) @Serializable(MediaGroupMemberInputMediaSerializer::class)
interface MediaGroupMemberInputMedia: InputMedia { interface MediaGroupMemberInputMedia : InputMedia, CaptionedOutput {
fun serialize(format: StringFormat): String fun serialize(format: StringFormat): String
val arguments: Map<String, Any?> val arguments: Map<String, Any?>
} }

View File

@ -1,8 +1,9 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
interface CaptionedMediaContent { @Deprecated(
val caption: String? "Deprecated due to replace by common type CaptionedInput",
val captionEntities: List<MessageEntity> ReplaceWith("CaptionedInput", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput")
} )
typealias CaptionedMediaContent = CaptionedInput

View File

@ -1,7 +1,8 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia
interface MediaGroupContent : MediaContent { interface MediaGroupContent : MediaContent, CaptionedInput {
fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia
} }

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
@ -17,7 +18,7 @@ data class AudioContent(
override val media: AudioFile, override val media: AudioFile,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : MediaContent, CaptionedMediaContent { ) : MediaContent, CaptionedInput {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
@ -17,7 +18,7 @@ data class DocumentContent(
override val media: DocumentFile, override val media: DocumentFile,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : MediaContent, CaptionedMediaContent { ) : MediaContent, CaptionedInput {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,

View File

@ -19,7 +19,7 @@ data class PhotoContent(
override val mediaCollection: List<PhotoSize>, override val mediaCollection: List<PhotoSize>,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : MediaCollectionContent<PhotoSize>, CaptionedMediaContent, MediaGroupContent { ) : MediaCollectionContent<PhotoSize>, MediaGroupContent {
override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content")
override fun createResend( override fun createResend(

View File

@ -19,7 +19,7 @@ data class VideoContent(
override val media: VideoFile, override val media: VideoFile,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : CaptionedMediaContent, MediaGroupContent { ) : MediaGroupContent {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
@ -17,7 +18,7 @@ data class VoiceContent(
override val media: VoiceFile, override val media: VoiceFile,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : MediaContent, CaptionedMediaContent { ) : MediaContent, CaptionedInput {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,

View File

@ -1,12 +1,12 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RegularTextMessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RegularTextMessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
fun CaptionedMediaContent.fullEntitiesList(): List<MessageEntity> = caption ?.let { fun CaptionedInput.fullEntitiesList(): List<MessageEntity> = caption ?.let {
convertToFullMessageEntityList(it, captionEntities) convertToFullMessageEntityList(it, captionEntities)
} ?: emptyList() } ?: emptyList()

View File

@ -1,10 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.textLength import com.github.insanusmokrassar.TelegramBotAPI.types.textLength
fun createHtmlText( fun createHtmlText(
@ -12,7 +12,7 @@ fun createHtmlText(
partLength: Int = 4096 partLength: Int = 4096
): List<String> = createFormattedText(entities, partLength, HTMLParseMode) ): List<String> = createFormattedText(entities, partLength, HTMLParseMode)
fun CaptionedMediaContent.toHtmlCaptions(): List<String> = createHtmlText( fun CaptionedInput.toHtmlCaptions(): List<String> = createHtmlText(
fullEntitiesList(), fullEntitiesList(),
captionLength.endInclusive + 1 captionLength.endInclusive + 1
) )

View File

@ -1,10 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.textLength import com.github.insanusmokrassar.TelegramBotAPI.types.textLength
@Deprecated( @Deprecated(
@ -31,9 +31,9 @@ fun createMarkdownText(
"com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions" "com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions"
) )
) )
fun CaptionedMediaContent.toMarkdownCaption(): String? = toMarkdownCaptions().firstOrNull() fun CaptionedInput.toMarkdownCaption(): String? = toMarkdownCaptions().firstOrNull()
fun CaptionedMediaContent.toMarkdownCaptions(): List<String> = createMarkdownText( fun CaptionedInput.toMarkdownCaptions(): List<String> = createMarkdownText(
fullEntitiesList(), fullEntitiesList(),
captionLength.endInclusive + 1 captionLength.endInclusive + 1
) )