mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
textSources now is main property
This commit is contained in:
parent
70f96ac8fa
commit
eb3f180cc6
@ -6,6 +6,8 @@
|
||||
* `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor
|
||||
* Fields `SendInvoice#maxTipAmount` and `SendInvoice#suggestedTipAmounts` have been added
|
||||
* New type `InputInvoiceMessageContent` has been added
|
||||
* `textSources` become main field in `TextedInput`
|
||||
* `textEntities` become are calculable property in `TextedInput`
|
||||
|
||||
## 0.33.4
|
||||
|
||||
|
@ -20,10 +20,3 @@ interface CaptionedInput : Captioned, TextedInput {
|
||||
val captionEntities: List<TextPart>
|
||||
get() = textEntities
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CaptionedInput.captionEntities
|
||||
* @see justTextSources
|
||||
*/
|
||||
val CaptionedInput.textSources
|
||||
get() = captionEntities.justTextSources()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.CommonAbstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.toTextParts
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
|
||||
interface Texted {
|
||||
@ -17,19 +18,17 @@ interface EntitiesOutput : Texted {
|
||||
interface TextedOutput : ParsableOutput, EntitiesOutput
|
||||
|
||||
interface TextedInput : Texted {
|
||||
/**
|
||||
* Full list of [TextSource] built from source[TextedInput.textEntities]
|
||||
*
|
||||
* @see justTextSources
|
||||
*/
|
||||
val textSources: List<TextSource>
|
||||
/**
|
||||
* Here must be full list of entities. This list must contains [TextPart]s with
|
||||
* [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of
|
||||
* regular text
|
||||
*/
|
||||
val textEntities: List<TextPart>
|
||||
get() = textSources.toTextParts()
|
||||
}
|
||||
|
||||
/**
|
||||
* Full list of [TextSource] built from source[TextedInput.textEntities]
|
||||
*
|
||||
* @see TextedInput.textEntities
|
||||
* @see justTextSources
|
||||
*/
|
||||
val TextedInput.textSources
|
||||
get() = textEntities.justTextSources()
|
||||
|
@ -9,6 +9,6 @@ data class Game(
|
||||
val description: String,
|
||||
val photo: Photo,
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList(),
|
||||
override val textSources: TextSourcesList = emptyList(),
|
||||
val animation: AnimationFile? = null
|
||||
) : Titled, CaptionedInput, TextedInput
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.games
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.justTextSources
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.RawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.asTextParts
|
||||
@ -28,7 +29,7 @@ internal data class RawGame(
|
||||
description,
|
||||
photo,
|
||||
text,
|
||||
text ?.let { _ -> textEntities.asTextParts(text) } ?: emptyList(),
|
||||
text ?.let { _ -> textEntities.asTextParts(text).justTextSources() } ?: emptyList(),
|
||||
animation
|
||||
)
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.justTextSources
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.RawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.asTextParts
|
||||
@ -102,11 +103,11 @@ internal data class RawMessage(
|
||||
) {
|
||||
private val content: MessageContent? by lazy {
|
||||
val adaptedCaptionEntities = caption ?.let {
|
||||
(caption_entities ?: emptyList()).asTextParts(caption)
|
||||
(caption_entities ?: emptyList()).asTextParts(caption).justTextSources()
|
||||
} ?: emptyList()
|
||||
|
||||
when {
|
||||
text != null -> TextContent(text, (entities ?: emptyList()).asTextParts(text))
|
||||
text != null -> TextContent(text, (entities ?: emptyList()).asTextParts(text).justTextSources())
|
||||
audio != null -> AudioContent(
|
||||
audio,
|
||||
caption,
|
||||
|
@ -13,7 +13,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class TextContent(
|
||||
override val text: String,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
override val textSources: TextSourcesList = emptyList(),
|
||||
) : MessageContent, TextedInput {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
@ -16,7 +16,7 @@ data class AnimationContent(
|
||||
override val media: AnimationFile,
|
||||
val includedDocument: DocumentFile?,
|
||||
override val text: String?,
|
||||
override val textEntities: List<TextPart>
|
||||
override val textSources: TextSourcesList = emptyList()
|
||||
) : MediaContent, CaptionedInput, TextedInput {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.textSources
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendAudio
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
@ -16,7 +15,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent
|
||||
data class AudioContent(
|
||||
override val media: AudioFile,
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
override val textSources: TextSourcesList = emptyList()
|
||||
) : AudioMediaGroupContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
@ -17,7 +17,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
data class DocumentContent(
|
||||
override val media: DocumentFile,
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
override val textSources: TextSourcesList = emptyList()
|
||||
) : DocumentMediaGroupContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
@ -46,7 +46,7 @@ inline fun MediaContent.asDocumentContent() = when (this) {
|
||||
is TextedInput -> DocumentContent(
|
||||
media.asDocumentFile(),
|
||||
text,
|
||||
textEntities
|
||||
textSources
|
||||
)
|
||||
else -> DocumentContent(
|
||||
media.asDocumentFile()
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.textSources
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendPhoto
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
@ -17,7 +16,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||
data class PhotoContent(
|
||||
override val mediaCollection: Photo,
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
override val textSources: TextSourcesList = emptyList()
|
||||
) : MediaCollectionContent<PhotoSize>, VisualMediaGroupContent {
|
||||
override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content")
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.textSources
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVideo
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
@ -16,7 +15,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||
data class VideoContent(
|
||||
override val media: VideoFile,
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
override val textSources: TextSourcesList = emptyList()
|
||||
) : VisualMediaGroupContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
@ -14,7 +14,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
data class VoiceContent(
|
||||
override val media: VoiceFile,
|
||||
override val text: String? = null,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
override val textSources: TextSourcesList = emptyList()
|
||||
) : MediaContent, CaptionedInput, TextedInput {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
Loading…
Reference in New Issue
Block a user