mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
deprecate Explained
This commit is contained in:
parent
f447be02dc
commit
ab060d02ea
15
CHANGELOG.md
15
CHANGELOG.md
@ -8,13 +8,18 @@ _**ALL OLD DEPRECATIONS WERE REMOVED**_
|
|||||||
* `Core`:
|
* `Core`:
|
||||||
* `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor
|
* `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor
|
||||||
* New interface `CommonSendInvoiceData` has been added
|
* New interface `CommonSendInvoiceData` has been added
|
||||||
* Fields `CommonSendInvoiceData#maxTipAmount` and `CommonSendInvoiceData#suggestedTipAmounts` have been added
|
* Fields `CommonSendInvoiceData#maxTipAmount` and `CommonSendInvoiceData#suggestedTipAmounts` have been added
|
||||||
* New type `InputInvoiceMessageContent` has been added
|
* New type `InputInvoiceMessageContent` has been added
|
||||||
* Interface `Captioned` and `CaptionedInput` now is deprecated
|
* New interface `TextedWithTextSources` on top of `Texted` interface
|
||||||
|
* Interface `TextedInput` now extends `TextedWithTextSources` with overriding of `textSources` field as not
|
||||||
|
nullable
|
||||||
|
* `textSources` become main field in `TextedInput`
|
||||||
|
* **MIGRATION** Remove all `import dev.inmo.tgbotapi.CommonAbstracts.textSources` in your project
|
||||||
|
* `textEntities` become are calculable property in `TextedInput`
|
||||||
|
* Interface `Captioned` and `CaptionedInput` now is deprecated
|
||||||
|
* Most of captions usages were replaced with texts
|
||||||
|
* Interface `Explained` and `ExplainedInput` now is deprecated
|
||||||
* Most of captions usages were replaced with texts
|
* Most of captions usages were replaced with texts
|
||||||
* `textSources` become main field in `TextedInput`
|
|
||||||
* **MIGRATION** Remove all `import dev.inmo.tgbotapi.CommonAbstracts.textSources` in your project
|
|
||||||
* `textEntities` become are calculable property in `TextedInput`
|
|
||||||
* Interface `VoiceChatEvent` now is `CommonEvent`
|
* Interface `VoiceChatEvent` now is `CommonEvent`
|
||||||
|
|
||||||
## 0.33.4
|
## 0.33.4
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
@Deprecated("Will be removed soon")
|
||||||
|
interface Explained : Texted {
|
||||||
interface Explained {
|
|
||||||
val explanation: String?
|
val explanation: String?
|
||||||
|
get() = text
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ParsableExplainedOutput : Explained {
|
@Deprecated("Will be removed soon")
|
||||||
val parseMode: ParseMode?
|
interface ParsableExplainedOutput : Explained, TextedOutput
|
||||||
}
|
|
||||||
|
|
||||||
interface EntitiesExplainedOutput : Explained {
|
@Deprecated("Will be removed soon")
|
||||||
val entities: List<TextSource>?
|
interface EntitiesExplainedOutput : Explained, EntitiesOutput
|
||||||
}
|
|
||||||
|
|
||||||
|
@Deprecated("Will be removed soon")
|
||||||
interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput
|
interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput
|
||||||
|
|
||||||
|
@Deprecated("Will be removed soon")
|
||||||
interface ExplainedInput : Explained {
|
interface ExplainedInput : Explained {
|
||||||
val textSources: TextSourcesList
|
val textSources: TextSourcesList
|
||||||
/**
|
/**
|
||||||
|
@ -5,22 +5,26 @@ import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
|||||||
interface Texted {
|
interface Texted {
|
||||||
val text: String?
|
val text: String?
|
||||||
}
|
}
|
||||||
|
interface TextedWithTextSources : Texted {
|
||||||
|
/**
|
||||||
|
* Full list of [TextSource] built from source[TextedInput.textEntities]
|
||||||
|
*/
|
||||||
|
val textSources: List<TextSource>?
|
||||||
|
}
|
||||||
|
|
||||||
interface ParsableOutput : Texted {
|
interface ParsableOutput : Texted {
|
||||||
val parseMode: ParseMode?
|
val parseMode: ParseMode?
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EntitiesOutput : Texted {
|
interface EntitiesOutput : TextedWithTextSources {
|
||||||
val entities: List<TextSource>?
|
val entities: List<TextSource>?
|
||||||
|
get() = textSources
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TextedOutput : ParsableOutput, EntitiesOutput
|
interface TextedOutput : ParsableOutput, EntitiesOutput
|
||||||
|
|
||||||
interface TextedInput : Texted {
|
interface TextedInput : TextedWithTextSources {
|
||||||
/**
|
override val textSources: List<TextSource>
|
||||||
* Full list of [TextSource] built from source[TextedInput.textEntities]
|
|
||||||
*/
|
|
||||||
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
|
||||||
|
@ -59,7 +59,7 @@ data class EditChatMessageCaption internal constructor(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
|
) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ data class EditInlineMessageCaption internal constructor(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
|
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ data class EditChatMessageText internal constructor(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ data class EditInlineMessageText internal constructor(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ data class CopyMessage internal constructor(
|
|||||||
TextedOutput {
|
TextedOutput {
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
get() = fromChatId
|
get() = fromChatId
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ data class SendTextMessage internal constructor(
|
|||||||
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
||||||
DisableWebPagePreview
|
DisableWebPagePreview
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ data class SendAnimationData internal constructor(
|
|||||||
DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
|
DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||||
SizedSendMessageRequest<ContentMessage<AnimationContent>>
|
SizedSendMessageRequest<ContentMessage<AnimationContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ data class SendAudioData internal constructor(
|
|||||||
DuratedSendMessageRequest<ContentMessage<AudioContent>>,
|
DuratedSendMessageRequest<ContentMessage<AudioContent>>,
|
||||||
Performerable
|
Performerable
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ data class SendDocumentData internal constructor(
|
|||||||
TextableSendMessageRequest<ContentMessage<DocumentContent>>,
|
TextableSendMessageRequest<ContentMessage<DocumentContent>>,
|
||||||
ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
|
ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ data class SendPhotoData internal constructor(
|
|||||||
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
|
||||||
TextableSendMessageRequest<ContentMessage<PhotoContent>>
|
TextableSendMessageRequest<ContentMessage<PhotoContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ data class SendVideoData internal constructor(
|
|||||||
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
|
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
|
||||||
SizedSendMessageRequest<ContentMessage<VideoContent>>
|
SizedSendMessageRequest<ContentMessage<VideoContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ data class SendVoiceData internal constructor(
|
|||||||
TextableSendMessageRequest<ContentMessage<VoiceContent>>,
|
TextableSendMessageRequest<ContentMessage<VoiceContent>>,
|
||||||
DuratedSendMessageRequest<ContentMessage<VoiceContent>>
|
DuratedSendMessageRequest<ContentMessage<VoiceContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ data class SendQuizPoll internal constructor(
|
|||||||
@SerialName(isClosedField)
|
@SerialName(isClosedField)
|
||||||
override val isClosed: Boolean = false,
|
override val isClosed: Boolean = false,
|
||||||
@SerialName(explanationField)
|
@SerialName(explanationField)
|
||||||
override val explanation: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(explanationParseModeField)
|
@SerialName(explanationParseModeField)
|
||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(explanationEntitiesField)
|
@SerialName(explanationEntitiesField)
|
||||||
@ -355,12 +355,12 @@ data class SendQuizPoll internal constructor(
|
|||||||
override val allowSendingWithoutReply: Boolean? = null,
|
override val allowSendingWithoutReply: Boolean? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendPoll(), ExplainedOutput {
|
) : SendPoll(), ExplainedOutput, TextedOutput {
|
||||||
override val type: String = quizPollType
|
override val type: String = quizPollType
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(explanation ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -371,9 +371,9 @@ data class SendQuizPoll internal constructor(
|
|||||||
throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " +
|
throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " +
|
||||||
"value is $correctOptionId")
|
"value is $correctOptionId")
|
||||||
}
|
}
|
||||||
if (explanation != null && explanation.length !in explanationLimit) {
|
if (text != null && text.length !in explanationLimit) {
|
||||||
error("Quiz poll explanation size must be in range $explanationLimit," +
|
error("Quiz poll explanation size must be in range $explanationLimit," +
|
||||||
"but actual explanation contains ${explanation.length} symbols")
|
"but actual explanation contains ${text.length} symbols")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ data class InlineQueryResultAudioCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultAudioCached {
|
) : InlineQueryResultAudioCached {
|
||||||
override val type: String = inlineQueryResultAudioType
|
override val type: String = inlineQueryResultAudioType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ data class InlineQueryResultAudioImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultAudio {
|
) : InlineQueryResultAudio {
|
||||||
override val type: String = inlineQueryResultAudioType
|
override val type: String = inlineQueryResultAudioType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ data class InlineQueryResultDocumentCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultDocumentCached {
|
) : InlineQueryResultDocumentCached {
|
||||||
override val type: String = inlineQueryResultDocumentType
|
override val type: String = inlineQueryResultDocumentType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ data class InlineQueryResultDocumentImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultDocument {
|
) : InlineQueryResultDocument {
|
||||||
override val type: String = inlineQueryResultDocumentType
|
override val type: String = inlineQueryResultDocumentType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ data class InlineQueryResultGifCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultGifCached {
|
) : InlineQueryResultGifCached {
|
||||||
override val type: String = inlineQueryResultGifType
|
override val type: String = inlineQueryResultGifType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ data class InlineQueryResultGifImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultGif {
|
) : InlineQueryResultGif {
|
||||||
override val type: String = inlineQueryResultGifType
|
override val type: String = inlineQueryResultGifType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ data class InlineQueryResultMpeg4GifCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultMpeg4GifCached {
|
) : InlineQueryResultMpeg4GifCached {
|
||||||
override val type: String = inlineQueryResultMpeg4GifType
|
override val type: String = inlineQueryResultMpeg4GifType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ data class InlineQueryResultMpeg4GifImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultMpeg4Gif {
|
) : InlineQueryResultMpeg4Gif {
|
||||||
override val type: String = inlineQueryResultMpeg4GifType
|
override val type: String = inlineQueryResultMpeg4GifType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ data class InlineQueryResultPhotoCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultPhotoCached {
|
) : InlineQueryResultPhotoCached {
|
||||||
override val type: String = inlineQueryResultPhotoType
|
override val type: String = inlineQueryResultPhotoType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -68,7 +68,7 @@ data class InlineQueryResultPhotoImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultPhoto {
|
) : InlineQueryResultPhoto {
|
||||||
override val type: String = inlineQueryResultPhotoType
|
override val type: String = inlineQueryResultPhotoType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ data class InlineQueryResultVideoCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultVideoCached {
|
) : InlineQueryResultVideoCached {
|
||||||
override val type: String = inlineQueryResultVideoType
|
override val type: String = inlineQueryResultVideoType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ data class InlineQueryResultVideoImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultVideo {
|
) : InlineQueryResultVideo {
|
||||||
override val type: String = inlineQueryResultVideoType
|
override val type: String = inlineQueryResultVideoType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ data class InlineQueryResultVoiceCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultVoiceCached {
|
) : InlineQueryResultVoiceCached {
|
||||||
override val type: String = inlineQueryResultVoiceType
|
override val type: String = inlineQueryResultVoiceType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ data class InlineQueryResultVoiceImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultVoice {
|
) : InlineQueryResultVoice {
|
||||||
override val type: String = inlineQueryResultVoiceType
|
override val type: String = inlineQueryResultVoiceType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ data class InputTextMessageContent internal constructor(
|
|||||||
@SerialName(disableWebPagePreviewField)
|
@SerialName(disableWebPagePreviewField)
|
||||||
override val disableWebPagePreview: Boolean? = null
|
override val disableWebPagePreview: Boolean? = null
|
||||||
) : TextedOutput, DisableWebPagePreview, InputMessageContent {
|
) : TextedOutput, DisableWebPagePreview, InputMessageContent {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -44,7 +44,7 @@ data class InputMediaAnimation internal constructor(
|
|||||||
override val thumb: InputFile? = null
|
override val thumb: InputFile? = null
|
||||||
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput {
|
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput {
|
||||||
override val type: String = "animation"
|
override val type: String = "animation"
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ data class InputMediaAudio internal constructor(
|
|||||||
override val thumb: InputFile? = null
|
override val thumb: InputFile? = null
|
||||||
) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, Performerable {
|
) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, Performerable {
|
||||||
override val type: String = audioInputMediaType
|
override val type: String = audioInputMediaType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ data class InputMediaDocument internal constructor(
|
|||||||
val disableContentTypeDetection: Boolean? = null
|
val disableContentTypeDetection: Boolean? = null
|
||||||
) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia {
|
) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia {
|
||||||
override val type: String = documentInputMediaType
|
override val type: String = documentInputMediaType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ data class InputMediaPhoto internal constructor(
|
|||||||
private val rawEntities: List<RawMessageEntity>? = null
|
private val rawEntities: List<RawMessageEntity>? = null
|
||||||
) : InputMedia, VisualMediaGroupMemberInputMedia {
|
) : InputMedia, VisualMediaGroupMemberInputMedia {
|
||||||
override val type: String = photoInputMediaType
|
override val type: String = photoInputMediaType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ data class InputMediaVideo internal constructor (
|
|||||||
override val thumb: InputFile? = null
|
override val thumb: InputFile? = null
|
||||||
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia {
|
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia {
|
||||||
override val type: String = videoInputMediaType
|
override val type: String = videoInputMediaType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,13 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.typed_serializer.TypedSerializer
|
import dev.inmo.micro_utils.serialization.typed_serializer.TypedSerializer
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.types.MessageEntity.RawMessageEntity
|
||||||
|
import dev.inmo.tgbotapi.types.MessageEntity.asTextSources
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.Serializer
|
||||||
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
|
||||||
private val baseSerializers: Map<String, KSerializer<out TextSource>> = mapOf(
|
private val baseSerializers: Map<String, KSerializer<out TextSource>> = mapOf(
|
||||||
"regular" to RegularTextSource.serializer(),
|
"regular" to RegularTextSource.serializer(),
|
||||||
@ -23,6 +29,7 @@ private val baseSerializers: Map<String, KSerializer<out TextSource>> = mapOf(
|
|||||||
"cashtag" to CashTagTextSource.serializer(),
|
"cashtag" to CashTagTextSource.serializer(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializer(TextSource::class)
|
||||||
object TextSourceSerializer : TypedSerializer<TextSource>(TextSource::class, baseSerializers) {
|
object TextSourceSerializer : TypedSerializer<TextSource>(TextSource::class, baseSerializers) {
|
||||||
override fun <T: TextSource> include(type: String, serializer: KSerializer<T>) {
|
override fun <T: TextSource> include(type: String, serializer: KSerializer<T>) {
|
||||||
require(type !in baseSerializers.keys)
|
require(type !in baseSerializers.keys)
|
||||||
|
@ -135,7 +135,7 @@ data class QuizPoll(
|
|||||||
* Nullable due to documentation (https://core.telegram.org/bots/api#poll)
|
* Nullable due to documentation (https://core.telegram.org/bots/api#poll)
|
||||||
*/
|
*/
|
||||||
val correctOptionId: Int? = null,
|
val correctOptionId: Int? = null,
|
||||||
override val explanation: String? = null,
|
override val text: String? = null,
|
||||||
override val textSources: List<TextSource> = emptyList(),
|
override val textSources: List<TextSource> = emptyList(),
|
||||||
override val isClosed: Boolean = false,
|
override val isClosed: Boolean = false,
|
||||||
override val isAnonymous: Boolean = false,
|
override val isAnonymous: Boolean = false,
|
||||||
@ -210,7 +210,7 @@ internal object PollSerializer : KSerializer<Poll> {
|
|||||||
value.isAnonymous,
|
value.isAnonymous,
|
||||||
regularPollType,
|
regularPollType,
|
||||||
correctOptionId = value.correctOptionId,
|
correctOptionId = value.correctOptionId,
|
||||||
explanation = value.explanation,
|
explanation = value.text,
|
||||||
explanationEntities = value.textSources.toRawMessageEntities(),
|
explanationEntities = value.textSources.toRawMessageEntities(),
|
||||||
openPeriod = (closeInfo as? ApproximateScheduledCloseInfo) ?.openDuration ?.seconds ?.toLong(),
|
openPeriod = (closeInfo as? ApproximateScheduledCloseInfo) ?.openDuration ?.seconds ?.toLong(),
|
||||||
closeDate = (closeInfo as? ExactScheduledCloseInfo) ?.closeDateTime ?.unixMillisLong ?.div(1000L)
|
closeDate = (closeInfo as? ExactScheduledCloseInfo) ?.closeDateTime ?.unixMillisLong ?.div(1000L)
|
||||||
|
@ -47,7 +47,7 @@ fun TextedInput.parseCommandsWithParams(
|
|||||||
*/
|
*/
|
||||||
fun TextedOutput.parseCommandsWithParams(
|
fun TextedOutput.parseCommandsWithParams(
|
||||||
argsSeparator: Regex = defaultArgsSeparator
|
argsSeparator: Regex = defaultArgsSeparator
|
||||||
) = entities ?.parseCommandsWithParams(argsSeparator) ?: emptyMap()
|
) = textSources ?.parseCommandsWithParams(argsSeparator) ?: emptyMap()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse commands and their args. Logic will find command, get all subsequent data as args until new command
|
* Parse commands and their args. Logic will find command, get all subsequent data as args until new command
|
||||||
|
Loading…
Reference in New Issue
Block a user