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