diff --git a/CHANGELOG.md b/CHANGELOG.md index 1159bd916f..e9d7db5c17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ * `Klock`: `2.0.7` -> `2.1.2` * `UUID`: `0.2.3` -> `0.3.0` * `Ktor`: `1.5.4` -> `1.6.0` +* `Core`: + * `ForceReply` has been renamed to `ReplyForce` ## 0.34.1 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt index 6a51ef9cca..d22fbb4942 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt @@ -1,110 +1,79 @@ package dev.inmo.tgbotapi.CommonAbstracts -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourceSerializer -import dev.inmo.tgbotapi.types.MessageEntity.textsources.regular +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.captionLength import dev.inmo.tgbotapi.types.textLength -import kotlinx.serialization.Serializable +import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForCaption +import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage +import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForText +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString -const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods" +const val DirectInvocationOfTextSourceConstructor = + "It is strongly not recommended to use constructors directly instead of factory methods" -typealias TextSourcesList = List - -@Serializable(TextSourceSerializer::class) -interface TextSource { - val markdown: String - val markdownV2: String - val html: String - val source: String - - val asText: String - get() = source - - companion object { - fun serializer() = TextSourceSerializer - } -} - -@Suppress("NOTHING_TO_INLINE") -inline operator fun TextSource.plus(other: TextSource) = listOf(this, other) -@Suppress("NOTHING_TO_INLINE") -inline operator fun TextSource.plus(other: List) = listOf(this) + other -@Suppress("NOTHING_TO_INLINE") -inline operator fun TextSource.plus(text: String) = listOf(this, regular(text)) -@Suppress("NOTHING_TO_INLINE") -inline operator fun List.plus(text: String) = this + regular(text) - -@Serializable(TextSourceSerializer::class) -interface MultilevelTextSource : TextSource { - val subsources: List - - companion object { - fun serializer() = TextSourceSerializer - } -} - -@Deprecated("This class will be removed soon. Use TextSources instead") -data class TextPart( - val range: IntRange, - val source: TextSource +@Deprecated( + "Replaced", + ReplaceWith("TextSourcesList", "dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList") ) +typealias TextSourcesList = TextSourcesList -@Deprecated("This method is no longer required to work with TextSources") -fun List.justTextSources() = map { it.source } -internal fun List.toTextParts(preOffset: Int = 0): List { - var i = preOffset - return map { - TextPart( - i until (i + it.source.length), - it - ).also { - i = it.range.last + 1 - } - } -} +@Deprecated("Replaced", ReplaceWith("TextSource", "dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource")) +typealias TextSource = dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource -fun List.makeString() = joinToString("") { it.source } -fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null): List> { - if (isEmpty()) { - return emptyList() - } +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) +inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.plus(other: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = + listOf(this, other) - val resultList = mutableListOf>(mutableListOf()) - var currentPartLength = 0 - val maxSize = limit.last + 1 +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) +inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.plus(other: List) = + listOf(this) + other - for (current in this) { - if (current.source.length > maxSize) { - error("Currently unsupported parts with size more than target one-message parts (${current.source.length} > ${maxSize})") - } +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) +inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.plus(text: String) = + listOf(this, regular(text)) - if (currentPartLength + current.source.length > maxSize) { - if (numberOfParts == null || numberOfParts < resultList.size) { - resultList.add(mutableListOf()) - currentPartLength = 0 - } else { - break - } - } +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) +inline operator fun List.plus(text: String) = this + regular(text) - resultList.last().add(current) - currentPartLength += current.source.length - } +@Deprecated( + "Replaced", + ReplaceWith("MultilevelTextSource", "dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource") +) +typealias MultilevelTextSource = MultilevelTextSource - return resultList -} +@Deprecated("Replaced", ReplaceWith("makeString", "dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString")) +fun List.makeString() = makeString() + +@Deprecated( + "Replaced", + ReplaceWith("separateForMessage", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage") +) +fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null) = + separateForMessage(limit, numberOfParts) /** * This method will prepare [TextSource]s list for messages. Remember, that first part will be separated with * [captionLength] and all others with */ -fun List.separateForCaption(): List> { - val captionPart = separateForMessage(captionLength, 1).first() - return listOf(captionPart) + minus(captionPart).separateForMessage(textLength) -} +@Deprecated( + "Replaced", + ReplaceWith("separateForCaption", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForCaption") +) +fun List.separateForCaption() = separateForCaption() /** * This method will prepare [TextSource]s list for messages with [textLength] */ @Suppress("NOTHING_TO_INLINE") -inline fun List.separateForText(): List> = separateForMessage(textLength) +@Deprecated( + "Replaced", + ReplaceWith("separateForText", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForText") +) +inline fun List.separateForText() = separateForText() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt index 0274b688cf..f1f7dec69b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.CommonAbstracts +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode interface Texted { @@ -9,7 +10,7 @@ interface TextedWithTextSources : Texted { /** * Full list of [TextSource] built from source[TextedInput.textEntities] */ - val textSources: List? + val textSources: List? } interface ParsableOutput : Texted { @@ -17,7 +18,7 @@ interface ParsableOutput : Texted { } interface EntitiesOutput : TextedWithTextSources { - val entities: List? + val entities: List? get() = textSources } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditChatMessageCaption.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditChatMessageCaption.kt index 5e08caeda3..9a74b6823a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditChatMessageCaption.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditChatMessageCaption.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer @@ -33,7 +32,7 @@ fun EditChatMessageCaption( fun EditChatMessageCaption( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageCaption( chatId, @@ -59,7 +58,7 @@ data class EditChatMessageCaption internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditInlineMessageCaption.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditInlineMessageCaption.kt index cf5a2c7d20..1b93d918bc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditInlineMessageCaption.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/caption/EditInlineMessageCaption.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.types.* @@ -25,7 +24,7 @@ fun EditInlineMessageCaption( fun EditInlineMessageCaption( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageCaption( inlineMessageId, @@ -48,7 +47,7 @@ data class EditInlineMessageCaption internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt index a65d6de1a0..6f825dc46e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer @@ -35,7 +34,7 @@ fun EditChatMessageText( fun EditChatMessageText( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageText( @@ -65,7 +64,7 @@ data class EditChatMessageText internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt index df537101fb..89c8f1f4f5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.types.* @@ -27,7 +26,7 @@ fun EditInlineMessageText( fun EditInlineMessageText( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageText( @@ -54,7 +53,7 @@ data class EditInlineMessageText internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt index 877193c498..7c2484eaa4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -27,7 +28,7 @@ fun CopyMessage( fromChatId: ChatIdentifier, toChatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt index e6b72d7a00..6e5b019b13 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.send -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview import dev.inmo.tgbotapi.requests.send.abstracts.* @@ -41,7 +40,7 @@ fun SendTextMessage( fun SendTextMessage( chatId: ChatIdentifier, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -84,7 +83,7 @@ data class SendTextMessage internal constructor( TextableSendMessageRequest>, DisableWebPagePreview { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt index a464986417..f2d2f7c6a4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.send.abstracts.* @@ -66,7 +65,7 @@ fun SendAnimation( chatId: ChatIdentifier, animation: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -145,7 +144,7 @@ data class SendAnimationData internal constructor( DuratedSendMessageRequest>, SizedSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt index e18d8562fe..44640436ac 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -65,7 +66,7 @@ fun SendAudio( chatId: ChatIdentifier, audio: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, performer: String? = null, title: String? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt index 9bee0c53df..d6de45940d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.send.abstracts.* @@ -80,7 +79,7 @@ fun SendDocument( chatId: ChatIdentifier, document: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -158,7 +157,7 @@ data class SendDocumentData internal constructor( TextableSendMessageRequest>, ThumbedSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt index b0840dfc95..79dd2aa5c7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.send.abstracts.* @@ -48,7 +47,7 @@ fun SendPhoto( fun SendPhoto( chatId: ChatIdentifier, photo: InputFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -101,7 +100,7 @@ data class SendPhotoData internal constructor( ReplyingMarkupSendMessageRequest>, TextableSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt index 8d4dcfcc71..327bc141a0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.send.abstracts.* @@ -68,7 +67,7 @@ fun SendVideo( chatId: ChatIdentifier, video: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -151,7 +150,7 @@ data class SendVideoData internal constructor( DuratedSendMessageRequest>, SizedSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt index 0e8c0b28ab..f154ac84ae 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.send.abstracts.* @@ -57,7 +56,7 @@ fun SendVoice( fun SendVoice( chatId: ChatIdentifier, voice: InputFile, - entities: List, + entities: List, duration: Long? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -121,7 +120,7 @@ data class SendVoiceData internal constructor( TextableSendMessageRequest>, DuratedSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt index 844482379a..47f74c9f36 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageReques import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -267,7 +268,7 @@ fun SendQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, - entities: List, + entities: List, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt index 9d1fa68bcb..c5b6685505 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.CallbackQuery import dev.inmo.tgbotapi.types.CallbackQueryIdentifier import dev.inmo.tgbotapi.types.User -interface CallbackQuery { +sealed interface CallbackQuery { val id: CallbackQueryIdentifier val user: User val chatInstance: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt index 220a1b77ef..47bb6000b6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.types.CallbackQuery -interface DataCallbackQuery : CallbackQuery { +sealed interface DataCallbackQuery : CallbackQuery { val data: String } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/GameShortNameCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/GameShortNameCallbackQuery.kt index ab5a676363..512f5f02d4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/GameShortNameCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/GameShortNameCallbackQuery.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.types.CallbackQuery -interface GameShortNameCallbackQuery : CallbackQuery { +sealed interface GameShortNameCallbackQuery : CallbackQuery { val gameShortName: String } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdCallbackQuery.kt index 41f44a2c19..4c23c6d8d6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdCallbackQuery.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.CallbackQuery import dev.inmo.tgbotapi.types.InlineMessageIdentifier -interface InlineMessageIdCallbackQuery : CallbackQuery { +sealed interface InlineMessageIdCallbackQuery : CallbackQuery { val inlineMessageId: InlineMessageIdentifier -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageCallbackQuery.kt index f64bda7593..666d9b829c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageCallbackQuery.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.CallbackQuery import dev.inmo.tgbotapi.types.message.abstracts.Message -interface MessageCallbackQuery : CallbackQuery { +sealed interface MessageCallbackQuery : CallbackQuery { val message: Message -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMember.kt deleted file mode 100644 index 762f240f1b..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMember.kt +++ /dev/null @@ -1,12 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember - -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember -import kotlinx.serialization.* - -@Serializable -data class LeftChatMember(@SerialName(userField) override val user: User) : ChatMember { - @SerialName(statusField) - @Required - private val type: String = "left" -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt new file mode 100644 index 0000000000..471d7347c0 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.types.ChatMember + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember +import dev.inmo.tgbotapi.types.ChatMember.abstracts.LeftChatMember +import kotlinx.serialization.* + +@Serializable +data class LeftChatMemberImpl(@SerialName(userField) override val user: User) : LeftChatMember { + @SerialName(statusField) + @Required + private val type: String = "left" +} + +@Deprecated("Renamed", ReplaceWith("LeftChatMemberImpl", "dev.inmo.tgbotapi.types.ChatMember.LeftChatMemberImpl")) +typealias LeftChatMember = LeftChatMemberImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMember.kt deleted file mode 100644 index 13625f4077..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMember.kt +++ /dev/null @@ -1,12 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember - -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember -import kotlinx.serialization.* - -@Serializable -data class MemberChatMember(@SerialName(userField) override val user: User) : ChatMember { - @SerialName(statusField) - @Required - private val type: String = "member" -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt new file mode 100644 index 0000000000..35cafb6bd3 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.types.ChatMember + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember +import dev.inmo.tgbotapi.types.ChatMember.abstracts.MemberChatMember +import kotlinx.serialization.* + +@Serializable +data class MemberChatMemberImpl(@SerialName(userField) override val user: User) : MemberChatMember { + @SerialName(statusField) + @Required + private val type: String = "member" +} + +@Deprecated("Renamed", ReplaceWith("MemberChatMember", "dev.inmo.tgbotapi.types.ChatMember.MemberChatMemberImpl")) +typealias MemberChatMember = MemberChatMemberImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt index d7c3f9b0ce..e325c7999b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt @@ -13,7 +13,7 @@ import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.jsonPrimitive @Serializable(ChatMemberSerializer::class) -interface ChatMember { +sealed interface ChatMember { val user: User } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/LeftChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/LeftChatMember.kt new file mode 100644 index 0000000000..7a31dfc9a8 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/LeftChatMember.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.ChatMember.abstracts + +interface LeftChatMember : ChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/MemberChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/MemberChatMember.kt new file mode 100644 index 0000000000..665aeb04aa --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/MemberChatMember.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.ChatMember.abstracts + +interface MemberChatMember : ChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioCachedImpl.kt index c636fcc9f0..19a1abf34e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioCachedImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* @@ -26,7 +25,7 @@ fun InlineQueryResultAudioCachedImpl( fun InlineQueryResultAudioCachedImpl( id: InlineQueryIdentifier, fileId: FileId, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultAudioCachedImpl(id, fileId, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -49,7 +48,7 @@ data class InlineQueryResultAudioCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultAudioCached { override val type: String = inlineQueryResultAudioType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt index 0139a0ec13..b9536aa9ea 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultAudioImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio @@ -31,7 +30,7 @@ fun InlineQueryResultAudioImpl( title: String, performer: String? = null, duration: Int? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultAudioImpl(id, url, title, performer, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -60,7 +59,7 @@ data class InlineQueryResultAudioImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultAudio { override val type: String = inlineQueryResultAudioType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt index de9670b328..65cd621ac6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* @@ -30,7 +29,7 @@ fun InlineQueryResultDocumentCachedImpl( fileId: FileId, title: String, description: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultDocumentCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -57,7 +56,7 @@ data class InlineQueryResultDocumentCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultDocumentCached { override val type: String = inlineQueryResultDocumentType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt index ca5c132122..c17285846a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultDocumentImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument @@ -39,7 +38,7 @@ fun InlineQueryResultDocumentImpl( thumbWidth: Int? = null, thumbHeight: Int? = null, description: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultDocumentImpl(id, url, title, mimeType, thumbUrl, thumbWidth, thumbHeight, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -74,7 +73,7 @@ data class InlineQueryResultDocumentImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultDocument { override val type: String = inlineQueryResultDocumentType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt index b177ef247d..b08013b5d8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifCachedImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* @@ -28,7 +27,7 @@ fun InlineQueryResultGifCachedImpl( id: InlineQueryIdentifier, fileId: FileId, title: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultGifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -53,7 +52,7 @@ data class InlineQueryResultGifCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultGifCached { override val type: String = inlineQueryResultGifType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt index a09cf7c042..c9fbfd01bf 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultGifImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif @@ -38,7 +37,7 @@ fun InlineQueryResultGifImpl( height: Int? = null, duration: Int? = null, title: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultGifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -73,7 +72,7 @@ data class InlineQueryResultGifImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultGif { override val type: String = inlineQueryResultGifType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt index ba4722d6fb..9d4b3eaf71 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* @@ -28,7 +27,7 @@ fun InlineQueryResultMpeg4GifCachedImpl( id: InlineQueryIdentifier, fileId: FileId, title: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultMpeg4GifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -53,7 +52,7 @@ data class InlineQueryResultMpeg4GifCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultMpeg4GifCached { override val type: String = inlineQueryResultMpeg4GifType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt index 318a4299ce..7abd6fb13c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif @@ -38,7 +37,7 @@ fun InlineQueryResultMpeg4GifImpl( height: Int? = null, duration: Int? = null, title: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultMpeg4GifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -73,7 +72,7 @@ data class InlineQueryResultMpeg4GifImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultMpeg4Gif { override val type: String = inlineQueryResultMpeg4GifType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt index 8946df450c..8a55e29fde 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* @@ -30,7 +29,7 @@ fun InlineQueryResultPhotoCachedImpl( fileId: FileId, title: String? = null, description: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultPhotoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -57,7 +56,7 @@ data class InlineQueryResultPhotoCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultPhotoCached { override val type: String = inlineQueryResultPhotoType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt index e72a13ed81..fb1443a03e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultPhotoImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto @@ -35,7 +34,7 @@ fun InlineQueryResultPhotoImpl( height: Int? = null, title: String? = null, description: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultPhotoImpl(id, url, thumbUrl, width, height, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -68,7 +67,7 @@ data class InlineQueryResultPhotoImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultPhoto { override val type: String = inlineQueryResultPhotoType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt index 5211514940..bc50c0dc02 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoCachedImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* @@ -30,7 +29,7 @@ fun InlineQueryResultVideoCachedImpl( fileId: FileId, title: String, description: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVideoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -57,7 +56,7 @@ data class InlineQueryResultVideoCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVideoCached { override val type: String = inlineQueryResultVideoType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt index 85c68034b8..9677902fb2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVideoImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo @@ -41,7 +40,7 @@ fun InlineQueryResultVideoImpl( height: Int? = null, duration: Int? = null, description: String? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVideoImpl(id, url, thumbUrl, mimeType, title, width, height, duration, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -78,7 +77,7 @@ data class InlineQueryResultVideoImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVideo { override val type: String = inlineQueryResultVideoType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt index 1acbf64656..1d948491cd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* @@ -28,7 +27,7 @@ fun InlineQueryResultVoiceCachedImpl( id: InlineQueryIdentifier, fileId: FileId, title: String, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVoiceCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -53,7 +52,7 @@ data class InlineQueryResultVoiceCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVoiceCached { override val type: String = inlineQueryResultVoiceType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt index dd6781faff..8374fe7996 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVoiceImpl.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice @@ -39,7 +38,7 @@ fun InlineQueryResultVoiceImpl( url: String, title: String, duration: Int? = null, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVoiceImpl(id, url, title, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -66,7 +65,7 @@ data class InlineQueryResultVoiceImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVoice { override val type: String = inlineQueryResultVoiceType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputContactMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputContactMessageContent.kt index 84b23e806c..a410a5b375 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputContactMessageContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputContactMessageContent.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent import dev.inmo.tgbotapi.CommonAbstracts.CommonContactData import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -16,4 +15,4 @@ data class InputContactMessageContent( override val lastName: String? = null, @SerialName(vcardField) override val vcard: String? = null -) : CommonContactData, InputMessageContent \ No newline at end of file +) : CommonContactData, InputMessageContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputInvoiceMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputInvoiceMessageContent.kt index c02c3f7a03..9f129a847a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputInvoiceMessageContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputInvoiceMessageContent.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent import dev.inmo.tgbotapi.CommonAbstracts.CommonSendInvoiceData import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.LabeledPricesSerializer import dev.inmo.tgbotapi.types.payments.abstracts.Currency diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputLocationMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputLocationMessageContent.kt index eda3152abf..7f37707b9e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputLocationMessageContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputLocationMessageContent.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -20,4 +19,4 @@ data class InputLocationMessageContent( override val heading: Degrees? = null, @SerialName(proximityAlertRadiusField) override val proximityAlertRadius: Meters? = null -) : Locationed, HorizontallyAccured, ProximityAlertable, Livable, Headed, InputMessageContent \ No newline at end of file +) : Locationed, HorizontallyAccured, ProximityAlertable, Livable, Headed, InputMessageContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputMessageContent.kt new file mode 100644 index 0000000000..e440506ec2 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputMessageContent.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent + +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContentSerializer +import kotlinx.serialization.Serializable + +@Serializable(InputMessageContentSerializer::class) +sealed interface InputMessageContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt index 17b88fb49c..6e959bec6b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt @@ -3,8 +3,8 @@ package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.SerialName @@ -23,7 +23,7 @@ fun InputTextMessageContent( * Represents the [InputMessageContent] of a text message to be sent as the result of an inline query. */ fun InputTextMessageContent( - entities: List, + entities: List, disableWebPagePreview: Boolean? = null ) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview) @@ -41,4 +41,4 @@ data class InputTextMessageContent internal constructor( override val textSources: List? by lazy { rawEntities ?.asTextSources(text) } -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputVenueMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputVenueMessageContent.kt index e744c10404..7f88cc74ce 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputVenueMessageContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputVenueMessageContent.kt @@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent import dev.inmo.tgbotapi.CommonAbstracts.CommonVenueData import dev.inmo.tgbotapi.CommonAbstracts.Locationed import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InlineQuery.kt index d942a452d7..3b1bcdb3d3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InlineQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InlineQuery.kt @@ -1,13 +1,9 @@ package dev.inmo.tgbotapi.types.InlineQueries.abstracts +import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.InlineQueryIdentifier import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.chat.ChatType -interface InlineQuery { - val id: InlineQueryIdentifier - val from: User - val query: String - val offset: String - val chatType: ChatType? -} \ No newline at end of file +@Deprecated("Replaced", ReplaceWith("InlineQuery", "dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery")) +typealias InlineQuery = InlineQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InputMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InputMessageContent.kt index 77fa368bb3..fc790070f4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InputMessageContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InputMessageContent.kt @@ -1,7 +1,8 @@ package dev.inmo.tgbotapi.types.InlineQueries.abstracts +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContentSerializer import kotlinx.serialization.Serializable -@Serializable(InputMessageContentSerializer::class) -interface InputMessageContent +@Deprecated("Replaced", ReplaceWith("InputMessageContent", "dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent")) +typealias InputMessageContent = InputMessageContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery.kt index c127b2f1c1..f05f362400 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.query -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery import dev.inmo.tgbotapi.types.InlineQueryIdentifier import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.chat.ChatType diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery.kt new file mode 100644 index 0000000000..2e7c093d8d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.types.InlineQueries.query + +import dev.inmo.tgbotapi.types.InlineQueryIdentifier +import dev.inmo.tgbotapi.types.User +import dev.inmo.tgbotapi.types.chat.ChatType + +sealed interface InlineQuery { + val id: InlineQueryIdentifier + val from: User + val query: String + val offset: String + val chatType: ChatType? +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/LocationInlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/LocationInlineQuery.kt index 78200717bc..530e665eb7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/LocationInlineQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/LocationInlineQuery.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.query -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery import dev.inmo.tgbotapi.types.InlineQueryIdentifier import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.chat.ChatType diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/DuratedInputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/DuratedInputMedia.kt index 9b4cd6f25e..ed7af3d902 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/DuratedInputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/DuratedInputMedia.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.types.InputMedia -interface DuratedInputMedia : InputMedia { +sealed interface DuratedInputMedia : InputMedia { val duration: Long? -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMedia.kt index 81f0d88c33..5013f33f9c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMedia.kt @@ -4,8 +4,8 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile import kotlinx.serialization.Serializable @Serializable(InputMediaSerializer::class) -interface InputMedia { +sealed interface InputMedia { val type: String val file: InputFile val media: String -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt index bb65c3c173..093545046d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.SerialName @@ -22,7 +23,7 @@ fun InputMediaAnimation( fun InputMediaAnimation( file: InputFile, - entities: List, + entities: List, width: Int? = null, height: Int? = null, duration: Long? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt index 5b2ed4a6cb..52a432005e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.AudioFile @@ -14,7 +15,7 @@ internal const val audioInputMediaType = "audio" fun InputMediaAudio( file: InputFile, - entities: List, + entities: List, duration: Long? = null, performer: String? = null, title: String? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt index c695ed1363..ea8410de98 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.DocumentFile @@ -21,7 +22,7 @@ fun InputMediaDocument( fun InputMediaDocument( file: InputFile, - entities: List, + entities: List, thumb: InputFile? = null, disableContentTypeDetection: Boolean? = null ) = InputMediaDocument(file, entities.makeString(), null, entities.toRawMessageEntities(), thumb, disableContentTypeDetection) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt index 3bf3ff4ba7..1f80d4260c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.PhotoSize @@ -20,7 +21,7 @@ fun InputMediaPhoto( fun InputMediaPhoto( file: InputFile, - entities: List + entities: List ) = InputMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities()) @Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt index f5512043c1..3a8355a486 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend @@ -24,7 +23,7 @@ fun InputMediaVideo( fun InputMediaVideo( file: InputFile, - entities: List, + entities: List, width: Int? = null, height: Int? = null, duration: Long? = null, @@ -46,7 +45,7 @@ data class InputMediaVideo internal constructor ( override val thumb: InputFile? = null ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia { override val type: String = videoInputMediaType - override val textSources: List? by lazy { + override val textSources: List? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt index 77fa02d59b..21b30e4e02 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt @@ -15,12 +15,12 @@ internal fun T.buildArguments(withSerializer: SerializationStrategy) = ar ) @Serializable(MediaGroupMemberInputMediaSerializer::class) -interface MediaGroupMemberInputMedia : InputMedia, TextedOutput { +sealed interface MediaGroupMemberInputMedia : InputMedia, TextedOutput { fun serialize(format: StringFormat): String } -interface AudioMediaGroupMemberInputMedia: MediaGroupMemberInputMedia -interface DocumentMediaGroupMemberInputMedia: MediaGroupMemberInputMedia +sealed interface AudioMediaGroupMemberInputMedia: MediaGroupMemberInputMedia +sealed interface DocumentMediaGroupMemberInputMedia: MediaGroupMemberInputMedia @Serializable(MediaGroupMemberInputMediaSerializer::class) -interface VisualMediaGroupMemberInputMedia : MediaGroupMemberInputMedia +sealed interface VisualMediaGroupMemberInputMedia : MediaGroupMemberInputMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/SizedInputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/SizedInputMedia.kt index 4048b67d98..2af7a352d4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/SizedInputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/SizedInputMedia.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.InputMedia -interface SizedInputMedia : InputMedia { +sealed interface SizedInputMedia : InputMedia { val width: Int? val height: Int? -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/ThumbedInputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/ThumbedInputMedia.kt index e44851ad94..a377adb1cf 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/ThumbedInputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/ThumbedInputMedia.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.InputMedia import dev.inmo.tgbotapi.requests.abstracts.InputFile -interface ThumbedInputMedia : InputMedia { +sealed interface ThumbedInputMedia : InputMedia { val thumb: InputFile? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/TitledInputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/TitledInputMedia.kt index 77b9de662f..95a4b9ccc8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/TitledInputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/TitledInputMedia.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.types.InputMedia -interface TitledInputMedia : InputMedia { +sealed interface TitledInputMedia : InputMedia { val title: String? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt index c294fcbafb..f4572c11c7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.MessageEntity import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.User import kotlinx.serialization.Serializable @@ -22,8 +21,8 @@ internal data class RawMessageEntity( internal fun RawMessageEntity.asTextSource( source: String, - subParts: List -): TextSource { + subParts: List +): dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource { val sourceSubstring: String = source.substring(range) val subPartsWithRegulars by lazy { subParts.fillWithRegulars(sourceSubstring) @@ -40,8 +39,15 @@ internal fun RawMessageEntity.asTextSource( "italic" -> ItalicTextSource(sourceSubstring, subPartsWithRegulars) "code" -> CodeTextSource(sourceSubstring) "pre" -> PreTextSource(sourceSubstring, language) - "text_link" -> TextLinkTextSource(sourceSubstring, url ?: throw IllegalStateException("URL must not be null for text link")) - "text_mention" -> TextMentionTextSource(sourceSubstring, user ?: throw IllegalStateException("User must not be null for text mention"), subPartsWithRegulars) + "text_link" -> TextLinkTextSource( + sourceSubstring, + url ?: throw IllegalStateException("URL must not be null for text link") + ) + "text_mention" -> TextMentionTextSource( + sourceSubstring, + user ?: throw IllegalStateException("User must not be null for text mention"), + subPartsWithRegulars + ) "underline" -> UnderlineTextSource(sourceSubstring, subPartsWithRegulars) "strikethrough" -> StrikethroughTextSource(sourceSubstring, subPartsWithRegulars) else -> RegularTextSource(sourceSubstring) @@ -52,9 +58,9 @@ private inline operator fun > ClosedRange.contains(other: C return start <= other.start && endInclusive >= other.endInclusive } -internal fun List.fillWithRegulars(source: String): List { +internal fun List.fillWithRegulars(source: String): List { var index = 0 - val result = mutableListOf() + val result = mutableListOf() for (i in 0 until size) { val textSource = get(i) val thisSourceInStart = source.startsWith(textSource.source, index) @@ -74,9 +80,12 @@ internal fun List.fillWithRegulars(source: String): List return result } -private fun createTextSources(originalFullString: String, entities: RawMessageEntities): List { +private fun createTextSources( + originalFullString: String, + entities: RawMessageEntities +): List { val mutableEntities = entities.toMutableList().apply { sortBy { it.offset } } - val resultList = mutableListOf() + val resultList = mutableListOf() while (mutableEntities.isNotEmpty()) { var parent = mutableEntities.removeFirst() @@ -130,7 +139,7 @@ private fun createTextSources(originalFullString: String, entities: RawMessageEn return resultList } -internal fun TextSource.toRawMessageEntities(offset: Int = 0): List { +internal fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.toRawMessageEntities(offset: Int = 0): List { val source = source val length = source.length return listOfNotNull( @@ -160,23 +169,24 @@ internal fun TextSource.toRawMessageEntities(offset: Int = 0): List.toRawMessageEntities(preOffset: Int = 0): List { +internal fun List.toRawMessageEntities(preOffset: Int = 0): List { var i = preOffset return flatMap { textSource -> textSource.toRawMessageEntities(i).also { - i += it.maxByOrNull { it.length } ?.length ?: textSource.source.length + i += it.maxByOrNull { it.length }?.length ?: textSource.source.length } } } -fun String.removeLeading(word: String) = if (startsWith(word)){ +fun String.removeLeading(word: String) = if (startsWith(word)) { substring(word.length) } else { this } -internal fun List.toRawMessageEntities(): List = toRawMessageEntities(0) +internal fun List.toRawMessageEntities(): List = toRawMessageEntities(0) -internal fun RawMessageEntities.asTextSources(sourceString: String): List = createTextSources(sourceString, this).fillWithRegulars(sourceString) +internal fun RawMessageEntities.asTextSources(sourceString: String): List = + createTextSources(sourceString, this).fillWithRegulars(sourceString) internal typealias RawMessageEntities = List diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt index 1129a56e55..2b1ea32e05 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt index 8b3f90403d..472fa3bf7f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt index cabb84237d..de6f10874f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt index e96dc0f45c..b7dd572785 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt index 515d8dd343..dd45431454 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt index 506bc6a584..ffcc885cb1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt index 61bb66bde3..ab5846fb2f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt index 0dce181677..169f9aa784 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt index ae1ef0239f..fe329bfac0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt index a29ce643ea..63dd4f56c7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt index 18c69aafd9..002c1ffae6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt index a6c32d4302..2efea3020b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable @@ -23,4 +22,4 @@ inline fun strikethrough(parts: List) = StrikethroughTextSource(part @Suppress("NOTHING_TO_INLINE") inline fun strikethrough(vararg parts: TextSource) = strikethrough(parts.toList()) @Suppress("NOTHING_TO_INLINE") -inline fun strikethrough(text: String) = strikethrough(regular(text)) \ No newline at end of file +inline fun strikethrough(text: String) = strikethrough(regular(text)) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt index 3e3faa5430..7ea9747518 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt index 2bb5c59261..791ec21d88 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt new file mode 100644 index 0000000000..e909b2aed3 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt @@ -0,0 +1,88 @@ +package dev.inmo.tgbotapi.types.MessageEntity.textsources + +import dev.inmo.tgbotapi.types.captionLength +import dev.inmo.tgbotapi.types.textLength +import kotlinx.serialization.Serializable + +const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods" + +typealias TextSourcesList = List + +@Serializable(TextSourceSerializer::class) +sealed interface TextSource { + val markdown: String + val markdownV2: String + val html: String + val source: String + + val asText: String + get() = source + + companion object { + fun serializer() = TextSourceSerializer + } +} + +@Suppress("NOTHING_TO_INLINE") +inline operator fun TextSource.plus(other: TextSource) = listOf(this, other) +@Suppress("NOTHING_TO_INLINE") +inline operator fun TextSource.plus(other: List) = listOf(this) + other +@Suppress("NOTHING_TO_INLINE") +inline operator fun TextSource.plus(text: String) = listOf(this, regular(text)) +@Suppress("NOTHING_TO_INLINE") +inline operator fun List.plus(text: String) = this + regular(text) + +@Serializable(TextSourceSerializer::class) +sealed interface MultilevelTextSource : TextSource { + val subsources: List + + companion object { + fun serializer() = TextSourceSerializer + } +} + +fun List.makeString() = joinToString("") { it.source } +fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null): List> { + if (isEmpty()) { + return emptyList() + } + + val resultList = mutableListOf>(mutableListOf()) + var currentPartLength = 0 + val maxSize = limit.last + 1 + + for (current in this) { + if (current.source.length > maxSize) { + error("Currently unsupported parts with size more than target one-message parts (${current.source.length} > ${maxSize})") + } + + if (currentPartLength + current.source.length > maxSize) { + if (numberOfParts == null || numberOfParts < resultList.size) { + resultList.add(mutableListOf()) + currentPartLength = 0 + } else { + break + } + } + + resultList.last().add(current) + currentPartLength += current.source.length + } + + return resultList +} + +/** + * This method will prepare [TextSource]s list for messages. Remember, that first part will be separated with + * [captionLength] and all others with + */ +fun List.separateForCaption(): List> { + val captionPart = separateForMessage(captionLength, 1).first() + return listOf(captionPart) + minus(captionPart).separateForMessage(textLength) +} + +/** + * This method will prepare [TextSource]s list for messages with [textLength] + */ +@Suppress("NOTHING_TO_INLINE") +inline fun List.separateForText(): List> = separateForMessage(textLength) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt index 4af8f92fcd..4f081a9b5b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt @@ -1,14 +1,7 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.micro_utils.serialization.typed_serializer.TypedSerializer -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.Serializer -import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder private val baseSerializers: Map> = mapOf( "regular" to RegularTextSource.serializer(), diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt index cdfeb3d097..fcd68aa678 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt index b8f3f10510..969cda18ad 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable @@ -23,4 +22,4 @@ inline fun underline(parts: List) = UnderlineTextSource(parts.makeSt @Suppress("NOTHING_TO_INLINE") inline fun underline(vararg parts: TextSource) = underline(parts.toList()) @Suppress("NOTHING_TO_INLINE") -inline fun underline(text: String) = underline(regular(text)) \ No newline at end of file +inline fun underline(text: String) = underline(regular(text)) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt index 13f9606176..a889a1f1bb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt @@ -1,31 +1,33 @@ package dev.inmo.tgbotapi.types.ParseMode import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer +import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder internal const val parseModeField = "parse_mode" @Serializable(ParseModeSerializerObject::class) -sealed class ParseMode { - abstract val parseModeName: String +sealed interface ParseMode { + val parseModeName: String } @Serializable(ParseModeSerializerObject::class) -object MarkdownParseMode : ParseMode() { +object MarkdownParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "Markdown" } @Serializable(ParseModeSerializerObject::class) -object MarkdownV2ParseMode : ParseMode() { +object MarkdownV2ParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "MarkdownV2" } @Serializable(ParseModeSerializerObject::class) -object HTMLParseMode : ParseMode() { +object HTMLParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "HTML" @@ -45,6 +47,7 @@ var defaultParseMode: ParseMode = HTML @Serializer(ParseMode::class) internal object ParseModeSerializerObject : KSerializer { + override val descriptor: SerialDescriptor = String.serializer().descriptor override fun deserialize(decoder: Decoder): ParseMode { return when (decoder.decodeString()) { Markdown.parseModeName -> Markdown diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ForceReply.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ForceReply.kt deleted file mode 100644 index c04cdfbd9c..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ForceReply.kt +++ /dev/null @@ -1,12 +0,0 @@ -package dev.inmo.tgbotapi.types.buttons - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class ForceReply( - val selective: Boolean? = null -) : KeyboardMarkup { - @SerialName("force_reply") - val forceReply: Boolean = true -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt index ec9ce5892b..c7e3016b09 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt @@ -3,30 +3,31 @@ package dev.inmo.tgbotapi.types.buttons import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* +import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.* @Serializable(KeyboardButtonSerializer::class) -sealed class KeyboardButton { - abstract val text: String +sealed interface KeyboardButton { + val text: String } @Serializable data class SimpleKeyboardButton( override val text: String -) : KeyboardButton() +) : KeyboardButton @Serializable data class UnknownKeyboardButton internal constructor( override val text: String, val raw: String -) : KeyboardButton() +) : KeyboardButton @Serializable data class RequestContactKeyboardButton( override val text: String -) : KeyboardButton() { +) : KeyboardButton { @SerialName(requestContactField) val requestContact: Boolean = true } @@ -34,7 +35,7 @@ data class RequestContactKeyboardButton( @Serializable data class RequestLocationKeyboardButton( override val text: String -) : KeyboardButton() { +) : KeyboardButton { @SerialName(requestLocationField) val requestLocation: Boolean = true } @@ -44,12 +45,15 @@ data class RequestPollKeyboardButton( override val text: String, @SerialName(requestPollField) val requestPoll: KeyboardButtonPollType -) : KeyboardButton() +) : KeyboardButton @Serializer(KeyboardButton::class) internal object KeyboardButtonSerializer : KSerializer { + private val internalSerializer = JsonElement.serializer() + override val descriptor: SerialDescriptor = internalSerializer.descriptor + override fun deserialize(decoder: Decoder): KeyboardButton { - val asJson = JsonElement.serializer().deserialize(decoder) + val asJson = internalSerializer.deserialize(decoder) return when { asJson is JsonPrimitive -> SimpleKeyboardButton(asJson.content) @@ -62,7 +66,7 @@ internal object KeyboardButtonSerializer : KSerializer { asJson is JsonObject && asJson[requestPollField] != null -> RequestPollKeyboardButton( asJson[textField]!!.jsonPrimitive.content, nonstrictJsonFormat.decodeFromJsonElement( - KeyboardButtonPollType.serializer(), + KeyboardButtonPollTypeSerializer, asJson[requestPollField] ?.jsonObject ?: buildJsonObject { } ) ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonPollType.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonPollType.kt index 297899d8cf..c3b68fb990 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonPollType.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonPollType.kt @@ -2,34 +2,36 @@ package dev.inmo.tgbotapi.types.buttons import dev.inmo.tgbotapi.types.* import kotlinx.serialization.* +import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.* @Serializable(KeyboardButtonPollTypeSerializer::class) -sealed class KeyboardButtonPollType { - abstract val type: String +sealed interface KeyboardButtonPollType { + val type: String } @Serializable -class UnknownKeyboardButtonPollType internal constructor(override val type: String): KeyboardButtonPollType() +class UnknownKeyboardButtonPollType internal constructor(override val type: String): KeyboardButtonPollType @Serializable -object RegularKeyboardButtonPollType : KeyboardButtonPollType() { +object RegularKeyboardButtonPollType : KeyboardButtonPollType { override val type: String = regularPollType } @Serializable -object QuizKeyboardButtonPollType : KeyboardButtonPollType() { +object QuizKeyboardButtonPollType : KeyboardButtonPollType { override val type: String = quizPollType } @Serializer(KeyboardButtonPollType::class) internal object KeyboardButtonPollTypeSerializer : KSerializer { - override fun deserialize(decoder: Decoder): KeyboardButtonPollType { - val asJson = JsonElement.serializer().deserialize(decoder) + private val internalSerializer = JsonElement.serializer() + override val descriptor: SerialDescriptor = internalSerializer.descriptor - val type = when (asJson) { + override fun deserialize(decoder: Decoder): KeyboardButtonPollType { + val type = when (val asJson = internalSerializer.deserialize(decoder)) { is JsonPrimitive -> asJson.content else -> asJson.jsonObject[typeField] ?.jsonPrimitive ?.content ?: "absent" } @@ -45,7 +47,7 @@ internal object KeyboardButtonPollTypeSerializer : KSerializer { ) override fun serialize(encoder: Encoder, value: KeyboardMarkup) { when(value) { - is ForceReply -> ForceReply.serializer().serialize(encoder, value) + is ReplyForce -> ReplyForce.serializer().serialize(encoder, value) is InlineKeyboardMarkup -> InlineKeyboardMarkup.serializer().serialize(encoder, value) is ReplyKeyboardMarkup -> ReplyKeyboardMarkup.serializer().serialize(encoder, value) is ReplyKeyboardRemove -> ReplyKeyboardRemove.serializer().serialize(encoder, value) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt new file mode 100644 index 0000000000..ad6c101b45 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt @@ -0,0 +1,21 @@ +package dev.inmo.tgbotapi.types.buttons + +import kotlinx.serialization.* + +@Serializable +data class ReplyForce( + val selective: Boolean? = null +) : KeyboardMarkup { + @SerialName("force_reply") + @Required + val forceReply: Boolean = true + + companion object { + val ReplyForceSelective = ReplyForce(true) + val ReplyForceNonSelective = ReplyForce(false) + val ReplyForceDefault = ReplyForce() + } +} + +@Deprecated("Renamed", ReplaceWith("ReplyForce", "dev.inmo.tgbotapi.types.buttons.ReplyForce")) +typealias ForceReply = ReplyForce diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove.kt index 84b0d7cec3..16bbce7dad 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove.kt @@ -1,12 +1,12 @@ package dev.inmo.tgbotapi.types.buttons -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* @Serializable data class ReplyKeyboardRemove( val selective: Boolean? = null ) : KeyboardMarkup { @SerialName("remove_keyboard") + @Required val removeKeyboard: Boolean = true } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt index badb22cb29..2d59847d95 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/DiceAnimationType.kt @@ -7,42 +7,42 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @Serializable(DiceAnimationTypeSerializer::class) -sealed class DiceAnimationType { - abstract val emoji: String - abstract val valueLimits: IntRange +sealed interface DiceAnimationType { + val emoji: String + val valueLimits: IntRange } @Serializable(DiceAnimationTypeSerializer::class) -object CubeDiceAnimationType : DiceAnimationType() { +object CubeDiceAnimationType : DiceAnimationType { override val emoji: String = "\uD83C\uDFB2" override val valueLimits: IntRange get() = dartsCubeAndBowlingDiceResultLimit } @Serializable(DiceAnimationTypeSerializer::class) -object DartsDiceAnimationType : DiceAnimationType() { +object DartsDiceAnimationType : DiceAnimationType { override val emoji: String = "\uD83C\uDFAF" override val valueLimits: IntRange get() = dartsCubeAndBowlingDiceResultLimit } @Serializable(DiceAnimationTypeSerializer::class) -object BasketballDiceAnimationType : DiceAnimationType() { +object BasketballDiceAnimationType : DiceAnimationType { override val emoji: String = "\uD83C\uDFC0" override val valueLimits: IntRange get() = basketballAndFootballDiceResultLimit } @Serializable(DiceAnimationTypeSerializer::class) -object FootballDiceAnimationType : DiceAnimationType() { +object FootballDiceAnimationType : DiceAnimationType { override val emoji: String = "⚽" override val valueLimits: IntRange get() = basketballAndFootballDiceResultLimit } @Serializable(DiceAnimationTypeSerializer::class) -object BowlingDiceAnimationType : DiceAnimationType() { +object BowlingDiceAnimationType : DiceAnimationType { override val emoji: String = "\uD83C\uDFB3" override val valueLimits: IntRange get() = dartsCubeAndBowlingDiceResultLimit } @Serializable(DiceAnimationTypeSerializer::class) -object SlotMachineDiceAnimationType : DiceAnimationType() { +object SlotMachineDiceAnimationType : DiceAnimationType { override val emoji: String = "\uD83C\uDFB0" override val valueLimits: IntRange get() = slotMachineDiceResultLimit @@ -50,7 +50,7 @@ object SlotMachineDiceAnimationType : DiceAnimationType() { @Serializable(DiceAnimationTypeSerializer::class) data class CustomDiceAnimationType( override val emoji: String -) : DiceAnimationType() { +) : DiceAnimationType { override val valueLimits: IntRange get() = error("Custom dice animation type have unknown value limits") } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt index b8b9878429..7707da1616 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt @@ -4,13 +4,14 @@ import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* +import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.JsonNull import kotlinx.serialization.json.JsonObject @Serializable(LocationSerializer::class) -sealed class Location : Locationed, HorizontallyAccured +sealed interface Location : Locationed, HorizontallyAccured @Serializable data class StaticLocation( @@ -20,7 +21,7 @@ data class StaticLocation( override val latitude: Double, @SerialName(horizontalAccuracyField) override val horizontalAccuracy: Meters? = null -) : Location() +) : Location @Serializable data class LiveLocation( @@ -36,11 +37,13 @@ data class LiveLocation( override val heading: Degrees? = null, @SerialName(proximityAlertRadiusField) override val proximityAlertRadius: Meters? = null -) : Location(), Livable, ProximityAlertable, Headed +) : Location, Livable, ProximityAlertable, Headed @Serializer(Location::class) object LocationSerializer : KSerializer { - override fun deserialize(decoder: Decoder): Location = JsonObject.serializer().deserialize(decoder).let { + private val internalSerializer = JsonObject.serializer() + override val descriptor: SerialDescriptor = internalSerializer.descriptor + override fun deserialize(decoder: Decoder): Location = internalSerializer.deserialize(decoder).let { if (it.containsKey(livePeriodField) && it[livePeriodField] != JsonNull) { nonstrictJsonFormat.decodeFromJsonElement(LiveLocation.serializer(), it) } else { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt index 60dff15177..80b283109e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt @@ -2,10 +2,10 @@ package dev.inmo.tgbotapi.types.polls import com.soywiz.klock.DateTime import com.soywiz.klock.TimeSpan -import dev.inmo.tgbotapi.CommonAbstracts.ExplainedInput -import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor @@ -13,19 +13,19 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.* -sealed class ScheduledCloseInfo { - abstract val closeDateTime: DateTime +sealed interface ScheduledCloseInfo { + val closeDateTime: DateTime } data class ExactScheduledCloseInfo( override val closeDateTime: DateTime -) : ScheduledCloseInfo() +) : ScheduledCloseInfo data class ApproximateScheduledCloseInfo( val openDuration: TimeSpan, @Suppress("MemberVisibilityCanBePrivate") val startPoint: DateTime = DateTime.now() -) : ScheduledCloseInfo() { +) : ScheduledCloseInfo { override val closeDateTime: DateTime = startPoint + openDuration } @@ -42,18 +42,18 @@ val LongSeconds.asExactScheduledCloseInfo ) @Serializable(PollSerializer::class) -sealed class Poll { - abstract val id: PollIdentifier - abstract val question: String - abstract val options: List - abstract val votesCount: Int - abstract val isClosed: Boolean - abstract val isAnonymous: Boolean - abstract val scheduledCloseInfo: ScheduledCloseInfo? +sealed interface Poll { + val id: PollIdentifier + val question: String + val options: List + val votesCount: Int + val isClosed: Boolean + val isAnonymous: Boolean + val scheduledCloseInfo: ScheduledCloseInfo? } @Serializable(PollSerializer::class) -sealed class MultipleAnswersPoll : Poll() +sealed interface MultipleAnswersPoll : Poll @Serializable private class RawPoll( @@ -105,7 +105,7 @@ data class UnknownPollType internal constructor( override val isAnonymous: Boolean = false, @Serializable val raw: JsonObject -) : Poll() { +) : Poll { @Transient override val scheduledCloseInfo: ScheduledCloseInfo? = (raw[closeDateField] ?: raw[openPeriodField]) ?.jsonPrimitive @@ -123,7 +123,7 @@ data class RegularPoll( override val isAnonymous: Boolean = false, val allowMultipleAnswers: Boolean = false, override val scheduledCloseInfo: ScheduledCloseInfo? = null -) : MultipleAnswersPoll() +) : MultipleAnswersPoll @Serializable(PollSerializer::class) data class QuizPoll( @@ -140,7 +140,7 @@ data class QuizPoll( override val isClosed: Boolean = false, override val isAnonymous: Boolean = false, override val scheduledCloseInfo: ScheduledCloseInfo? = null -) : Poll(), ExplainedInput +) : Poll, TextedInput @Serializer(Poll::class) internal object PollSerializer : KSerializer { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt index 8ded23db22..a74b53a5e9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt @@ -1,17 +1,16 @@ package dev.inmo.tgbotapi.utils.internal import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.link import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Link import dev.inmo.tgbotapi.utils.extensions.toHtml -private fun List.joinSubSourcesMarkdownV2() = joinToString("") { +private fun List.joinSubSourcesMarkdownV2() = joinToString("") { it.markdownV2 } -private fun List.joinSubSourcesHtml() = joinToString("") { +private fun List.joinSubSourcesHtml() = joinToString("") { it.html } diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt index 08092c0350..7092b31e0f 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import kotlin.test.assertTrue @@ -40,7 +39,7 @@ internal val testTextEntities = listOf( ) ) -fun List.testTextSources() { +fun List.testTextSources() { assertTrue (first() is RegularTextSource) assertTrue (get(1) is BoldTextSource) assertTrue (get(2) is RegularTextSource) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt index f7b15a854a..d817adc266 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.plus import dev.inmo.tgbotapi.extensions.utils.formatting.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.* @@ -40,7 +39,7 @@ class StringFormattingTests { @Test fun testThatCreatingOfStringWithSimpleDSLWorksCorrectly() { - val sources: List = regular("It ") + + val sources: List = regular("It ") + bold(italic("is") + " " + strikethrough(underline("simple"))) + diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt index 3f1b2a4b16..b3f0158702 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.TestsJsonFormat import dev.inmo.tgbotapi.extensions.utils.formatting.* @@ -34,4 +33,4 @@ class TextSourcesTests { assertEquals(testList, deserialized) assertEquals(testList.makeString(), deserialized.makeString()) } -} \ No newline at end of file +} diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt index 9d28dc4288..81d730056a 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.caption.EditChatMessageCaption import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -41,7 +42,7 @@ suspend fun TelegramBot.editMessageCaption( suspend fun TelegramBot.editMessageCaption( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null ) = execute( EditChatMessageCaption(chatId, messageId, entities, replyMarkup) @@ -50,7 +51,7 @@ suspend fun TelegramBot.editMessageCaption( suspend fun TelegramBot.editMessageCaption( chat: Chat, messageId: MessageIdentifier, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null ) = editMessageCaption(chat.id, messageId, entities, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt index 00df5eea1e..d30a399696 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.caption.EditInlineMessageCaption import dev.inmo.tgbotapi.types.InlineMessageIdentifier @@ -16,6 +15,6 @@ suspend fun TelegramBot.editMessageCaption( suspend fun TelegramBot.editMessageCaption( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: List, replyMarkup: InlineKeyboardMarkup? = null ) = execute(EditInlineMessageCaption(inlineMessageId, entities, replyMarkup)) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt index 1e9f460310..0fe253ff0b 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText import dev.inmo.tgbotapi.types.ChatIdentifier @@ -42,7 +41,7 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute( @@ -52,14 +51,14 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( chat: Chat, messageId: MessageIdentifier, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup) suspend fun TelegramBot.editMessageText( message: ContentMessage, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) \ No newline at end of file +) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt index f100fa861e..3d734cf303 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText import dev.inmo.tgbotapi.types.InlineMessageIdentifier @@ -17,7 +16,7 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup)) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt index 73874634de..82e04f308e 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.CopyMessage import dev.inmo.tgbotapi.types.ChatIdentifier @@ -87,7 +86,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, toChatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -100,7 +99,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, toChatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -111,7 +110,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, toChat: Chat, messageId: MessageIdentifier, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -122,7 +121,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, toChat: Chat, messageId: MessageIdentifier, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -132,7 +131,7 @@ suspend inline fun TelegramBot.copyMessage( suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, message: Message, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -142,7 +141,7 @@ suspend inline fun TelegramBot.copyMessage( suspend inline fun TelegramBot.copyMessage( toChat: Chat, message: Message, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt index ccfae79987..6c30653a50 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.types.ChatIdentifier @@ -61,7 +60,7 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -73,7 +72,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -85,7 +84,7 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendMessage( chat: Chat, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -96,7 +95,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendTextMessage( chat: Chat, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -124,7 +123,7 @@ suspend inline fun TelegramBot.reply( ) suspend inline fun TelegramBot.reply( to: Message, - entities: List, + entities: List, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt index 95a4c4bcdc..058b2a57b1 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendAnimation @@ -145,7 +144,7 @@ suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -172,7 +171,7 @@ suspend fun TelegramBot.sendAnimation( suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: AnimationFile, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -188,7 +187,7 @@ suspend fun TelegramBot.sendAnimation( chat: Chat, animation: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -201,7 +200,7 @@ suspend fun TelegramBot.sendAnimation( suspend fun TelegramBot.sendAnimation( chat: Chat, animation: AnimationFile, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -215,7 +214,7 @@ suspend inline fun TelegramBot.replyWithAnimation( to: Message, animation: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -239,7 +238,7 @@ suspend inline fun TelegramBot.replyWithAnimation( suspend inline fun TelegramBot.replyWithAnimation( to: Message, animation: AnimationFile, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -251,7 +250,7 @@ suspend inline fun TelegramBot.replyWithAnimation( suspend inline fun TelegramBot.reply( to: Message, animation: AnimationFile, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt index e6cfab19f9..019e8ec048 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendAudio @@ -122,7 +121,7 @@ suspend inline fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, performer: String? = null, title: String? = null, @@ -150,7 +149,7 @@ suspend inline fun TelegramBot.sendAudio( chat: Chat, audio: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, performer: String? = null, title: String? = null, @@ -163,7 +162,7 @@ suspend inline fun TelegramBot.sendAudio( suspend inline fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: AudioFile, - entities: List, + entities: List, title: String? = audio.title, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -174,7 +173,7 @@ suspend inline fun TelegramBot.sendAudio( suspend inline fun TelegramBot.sendAudio( chat: Chat, audio: AudioFile, - entities: List, + entities: List, title: String? = audio.title, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -186,7 +185,7 @@ suspend inline fun TelegramBot.replyWithAudio( to: Message, audio: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, performer: String? = null, title: String? = null, @@ -198,7 +197,7 @@ suspend inline fun TelegramBot.replyWithAudio( suspend inline fun TelegramBot.replyWithAudio( to: Message, audio: AudioFile, - entities: List, + entities: List, title: String? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -208,7 +207,7 @@ suspend inline fun TelegramBot.replyWithAudio( suspend inline fun TelegramBot.reply( to: Message, audio: AudioFile, - entities: List, + entities: List, title: String? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt index 1fab4cc11b..88be4feb78 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendDocument @@ -116,7 +115,7 @@ suspend inline fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -140,7 +139,7 @@ suspend inline fun TelegramBot.sendDocument( chat: Chat, document: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -151,7 +150,7 @@ suspend inline fun TelegramBot.sendDocument( suspend inline fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: DocumentFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -164,7 +163,7 @@ suspend inline fun TelegramBot.sendDocument( suspend inline fun TelegramBot.sendDocument( chat: Chat, document: DocumentFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -176,7 +175,7 @@ suspend inline fun TelegramBot.replyWithDocument( to: Message, document: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, @@ -186,7 +185,7 @@ suspend inline fun TelegramBot.replyWithDocument( suspend inline fun TelegramBot.replyWithDocument( to: Message, document: DocumentFile, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, @@ -196,7 +195,7 @@ suspend inline fun TelegramBot.replyWithDocument( suspend inline fun TelegramBot.reply( to: Message, document: DocumentFile, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt index c641033456..565098825e 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendPhoto @@ -102,7 +101,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -122,7 +121,7 @@ suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -132,7 +131,7 @@ suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -142,7 +141,7 @@ suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -152,7 +151,7 @@ suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.replyWithPhoto( to: Message, fileId: InputFile, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null @@ -161,7 +160,7 @@ suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.replyWithPhoto( to: Message, photo: Photo, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null @@ -170,7 +169,7 @@ suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.reply( to: Message, photo: Photo, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt index 962b265ace..a11bb412a8 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVideo @@ -120,7 +119,7 @@ suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -148,7 +147,7 @@ suspend inline fun TelegramBot.sendVideo( suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: VideoFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -159,7 +158,7 @@ suspend inline fun TelegramBot.sendVideo( chat: Chat, video: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -173,7 +172,7 @@ suspend inline fun TelegramBot.sendVideo( suspend inline fun TelegramBot.sendVideo( chat: Chat, video: VideoFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -184,7 +183,7 @@ suspend inline fun TelegramBot.replyWithVideo( to: Message, video: InputFile, thumb: InputFile? = null, - entities: List, + entities: List, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -196,7 +195,7 @@ suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.replyWithVideo( to: Message, video: VideoFile, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null @@ -205,7 +204,7 @@ suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.reply( to: Message, video: VideoFile, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt index 21b87b0e66..4f8566aa4f 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVoice @@ -107,7 +106,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: InputFile, - entities: List, + entities: List, duration: Long? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -129,7 +128,7 @@ suspend inline fun TelegramBot.sendVoice( suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: InputFile, - entities: List, + entities: List, duration: Long? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -140,7 +139,7 @@ suspend inline fun TelegramBot.sendVoice( suspend inline fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: VoiceFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -152,7 +151,7 @@ suspend inline fun TelegramBot.sendVoice( suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: VoiceFile, - entities: List, + entities: List, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -162,7 +161,7 @@ suspend inline fun TelegramBot.sendVoice( suspend inline fun TelegramBot.replyWithVoice( to: Message, voice: InputFile, - entities: List, + entities: List, duration: Long? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -172,7 +171,7 @@ suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.replyWithVoice( to: Message, voice: VoiceFile, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null @@ -181,7 +180,7 @@ suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.reply( to: Message, voice: VoiceFile, - entities: List, + entities: List, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt index d95c63c464..a69923e6ad 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.api.send.polls -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll @@ -162,7 +161,7 @@ suspend inline fun TelegramBot.sendQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, - entities: List, + entities: List, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -181,7 +180,7 @@ suspend inline fun TelegramBot.sendQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, - entities: List, + entities: List, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -199,7 +198,7 @@ suspend inline fun TelegramBot.sendQuizPoll( options: List = quizPoll.options.map { it.text }, correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), isAnonymous: Boolean = quizPoll.isAnonymous, - entities: List, + entities: List, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -217,7 +216,7 @@ suspend inline fun TelegramBot.sendQuizPoll( options: List = quizPoll.options.map { it.text }, correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), isAnonymous: Boolean = quizPoll.isAnonymous, - entities: List, + entities: List, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -292,7 +291,7 @@ suspend inline fun TelegramBot.replyWithQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, - entities: List, + entities: List, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -307,7 +306,7 @@ suspend inline fun TelegramBot.replyWithQuizPoll( options: List = quizPoll.options.map { it.text }, correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), isAnonymous: Boolean = quizPoll.isAnonymous, - entities: List, + entities: List, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 9811b1ab8b..79aa77dccc 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -981,9 +981,9 @@ inline fun TelegramMediaFile.asThumbedMediaFile(): ThumbedMediaFile? = this as? @PreviewFeature inline fun TelegramMediaFile.requireThumbedMediaFile(): ThumbedMediaFile = this as ThumbedMediaFile @PreviewFeature -inline fun KeyboardMarkup.asForceReply(): ForceReply? = this as? ForceReply +inline fun KeyboardMarkup.asForceReply(): ReplyForce? = this as? ReplyForce @PreviewFeature -inline fun KeyboardMarkup.requireForceReply(): ForceReply = this as ForceReply +inline fun KeyboardMarkup.requireForceReply(): ReplyForce = this as ReplyForce @PreviewFeature inline fun KeyboardMarkup.asInlineKeyboardMarkup(): InlineKeyboardMarkup? = this as? InlineKeyboardMarkup @PreviewFeature diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt index 8fa69aadad..d49f366f75 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.extensions import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.TextContent diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt index c9b23384c1..b6f4bcefd9 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt @@ -2,10 +2,9 @@ package dev.inmo.tgbotapi.extensions.utils.formatting -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.types.User -fun buildEntities(init: EntitiesBuilder.() -> Unit): List = EntitiesBuilder().apply(init).build() +fun buildEntities(init: EntitiesBuilder.() -> Unit): List = EntitiesBuilder().apply(init).build() /** * This builder can be used to provide building of [TextSource]s [List] @@ -13,33 +12,35 @@ fun buildEntities(init: EntitiesBuilder.() -> Unit): List = Entities * @see buildEntities */ class EntitiesBuilder internal constructor( - private val entitiesList: MutableList = mutableListOf() + private val entitiesList: MutableList = mutableListOf() ) { /** * It is not safe field which contains potentially changeable [List] */ - val entities: List + val entities: List get() = entitiesList /** * @return New immutable list which will be deattached from this builder */ - fun build(): List = entities.toList() + fun build(): List = entities.toList() - fun add(source: TextSource) { entitiesList.add(source) } + fun add(source: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) { + entitiesList.add(source) + } - operator fun TextSource.unaryPlus() = add(this) - operator fun List.unaryPlus() = entitiesList.addAll(this) - operator fun invoke(vararg source: TextSource) = entitiesList.addAll(source) + operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.unaryPlus() = add(this) + operator fun List.unaryPlus() = entitiesList.addAll(this) + operator fun invoke(vararg source: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = entitiesList.addAll(source) operator fun String.unaryPlus() { add(dev.inmo.tgbotapi.types.MessageEntity.textsources.regular(this)) } } -inline fun EntitiesBuilder.bold(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(parts)) +inline fun EntitiesBuilder.bold(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(parts)) -inline fun EntitiesBuilder.bold(vararg parts: TextSource) = +inline fun EntitiesBuilder.bold(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(*parts)) inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(text)) @@ -47,63 +48,66 @@ inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.Mess inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.botCommand(command)) -inline fun EntitiesBuilder.cashTag(parts: List) = +inline fun EntitiesBuilder.cashTag(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(parts)) -inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = +inline fun EntitiesBuilder.cashTag(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(*parts)) inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(text)) inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.code(code)) -inline fun EntitiesBuilder.email(parts: List) = +inline fun EntitiesBuilder.email(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(parts)) -inline fun EntitiesBuilder.email(vararg parts: TextSource) = +inline fun EntitiesBuilder.email(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(*parts)) inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(emailAddress)) -inline fun EntitiesBuilder.hashtag(parts: List) = +inline fun EntitiesBuilder.hashtag(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(parts)) -inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = +inline fun EntitiesBuilder.hashtag(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(*parts)) inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(hashtag)) -inline fun EntitiesBuilder.italic(parts: List) = +inline fun EntitiesBuilder.italic(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(parts)) -inline fun EntitiesBuilder.italic(vararg parts: TextSource) = +inline fun EntitiesBuilder.italic(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(*parts)) inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(text)) -inline fun EntitiesBuilder.mention(parts: List) = +inline fun EntitiesBuilder.mention(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(parts)) -inline fun EntitiesBuilder.mention(vararg parts: TextSource) = +inline fun EntitiesBuilder.mention(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(*parts)) inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(whoToMention)) -inline fun EntitiesBuilder.mention(parts: List, user: User) = +inline fun EntitiesBuilder.mention(parts: List, user: User) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(parts, user)) -inline fun EntitiesBuilder.mention(user: User, vararg parts: TextSource) = +inline fun EntitiesBuilder.mention( + user: User, + vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(user, *parts)) inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(text, user)) -inline fun EntitiesBuilder.phone(parts: List) = +inline fun EntitiesBuilder.phone(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(parts)) -inline fun EntitiesBuilder.phone(vararg parts: TextSource) = +inline fun EntitiesBuilder.phone(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(*parts)) inline fun EntitiesBuilder.phone(number: String) = @@ -115,10 +119,10 @@ inline fun EntitiesBuilder.pre(code: String, language: String?) = inline fun EntitiesBuilder.regular(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.regular(text)) -inline fun EntitiesBuilder.strikethrough(parts: List) = +inline fun EntitiesBuilder.strikethrough(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(parts)) -inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = +inline fun EntitiesBuilder.strikethrough(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(*parts)) inline fun EntitiesBuilder.strikethrough(text: String) = @@ -130,10 +134,10 @@ inline fun EntitiesBuilder.link(text: String, url: String) = inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.link(url)) -inline fun EntitiesBuilder.underline(parts: List) = +inline fun EntitiesBuilder.underline(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(parts)) -inline fun EntitiesBuilder.underline(vararg parts: TextSource) = +inline fun EntitiesBuilder.underline(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(*parts)) inline fun EntitiesBuilder.underline(text: String) = diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt index 749ae68aef..2380f9071a 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.utils.shortcuts -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.extensions.utils.onlyTextContentMessages import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt index 192b612055..1bfe7b70b0 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.utils.updates -import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.extensions.utils.onlyTextContentMessages import dev.inmo.tgbotapi.extensions.utils.shortcuts.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource @@ -60,4 +59,4 @@ fun Flow.filterCommandsInsideTextMessages( */ fun Flow.filterCommandsWithArgs( commandRegex: Regex -): Flow, List>> = textMessages().filterCommandsWithArgs(commandRegex) +): Flow, List>> = textMessages().filterCommandsWithArgs(commandRegex)