From 2dc8beba8a6ebec5e6007280084218c920d5563b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 16 Apr 2021 22:00:45 +0600 Subject: [PATCH 01/63] update classcasts --- .../kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt | 4 ++++ 1 file changed, 4 insertions(+) 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 999f165c15..21fc99db2e 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 @@ -513,6 +513,10 @@ inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommon @PreviewFeature inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = this as PossiblySentViaBotCommonMessage @PreviewFeature +inline fun Message.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage +@PreviewFeature +inline fun Message.requireFromUserMessage(): FromUserMessage = this as FromUserMessage +@PreviewFeature inline fun BotAction.asFindLocationAction(): FindLocationAction? = this as? FindLocationAction @PreviewFeature inline fun BotAction.requireFindLocationAction(): FindLocationAction = this as FindLocationAction From 03f8d65bb6b6a70a923a06ae000e2b8afbe88b33 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 17 Apr 2021 11:14:35 +0600 Subject: [PATCH 02/63] fix of build --- .../types/MessageEntity/textsources/TextSourceSerializer.kt | 1 - 1 file changed, 1 deletion(-) 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 f3474b1363..a9f76a93ad 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 @@ -30,7 +30,6 @@ private val baseSerializers: Map> = mapOf( "cashtag" to CashTagTextSource.serializer(), ) -@Serializer(TextSource::class) object TextSourceSerializer : TypedSerializer(TextSource::class, baseSerializers) { override fun include(type: String, serializer: KSerializer) { require(type !in baseSerializers.keys) From 61be689acaa6ed8ff8cb5764ab6cfaa497ac4fd6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 17 Apr 2021 14:36:23 +0600 Subject: [PATCH 03/63] fix of build --- build.gradle | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build.gradle b/build.gradle index 84867b4dad..1e47f88a68 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,17 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false } +// temporal crutch until legacy tests will be stabled or legacy target will be removed +allprojects { + if (it != rootProject.findProject("docs")) { + tasks.whenTaskAdded { task -> + if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") { + task.enabled = false + } + } + } +} + private String getCurrentVersionChangelog() { OutputStream changelogDataOS = new ByteArrayOutputStream() exec { From 1846d20b0d8501d08945728fa68237869c0057ea Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 19:15:55 +0600 Subject: [PATCH 04/63] start 0.34.0 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20e22e133d..a510447bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.34.0 + ## 0.33.4 * `Common`: diff --git a/gradle.properties b/gradle.properties index a74e4d5857..5e93b2b6b2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.35 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.33.4 +library_version=0.34.0 github_release_plugin_version=2.2.12 From cd3066025643d0b5163d81ecfc947ca99a405df9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 19:28:19 +0600 Subject: [PATCH 05/63] update SendInvoice --- CHANGELOG.md | 3 +++ .../tgbotapi/requests/send/payments/SendInvoice.kt | 4 ++-- .../extensions/api/send/payments/SendInvoice.kt | 12 ++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a510447bc4..f70820e6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.34.0 +* `Core`: + * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor + ## 0.33.4 * `Common`: diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt index af6bc6e0da..6d7d490321 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt @@ -30,13 +30,13 @@ data class SendInvoice( val payload: String, @SerialName(providerTokenField) val providerToken: String, - @SerialName(startParameterField) - val startParameter: StartParameter, @SerialName(currencyField) override val currency: Currency, @Serializable(LabeledPricesSerializer::class) @SerialName(pricesField) override val prices: List, + @SerialName(startParameterField) + val startParameter: StartParameter? = null, @SerialName(providerDataField) val providerData: String? = null, @SerialName(requireNameField) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt index 3af85856f1..9812c7e83c 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt @@ -14,9 +14,9 @@ suspend fun TelegramBot.sendInvoice( description: String, payload: String, providerToken: String, - startParameter: StartParameter, currency: Currency, prices: List, + startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, requirePhoneNumber: Boolean = false, @@ -30,7 +30,7 @@ suspend fun TelegramBot.sendInvoice( allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute( - SendInvoice(chatId, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendInvoice(chatId, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) suspend fun TelegramBot.sendInvoice( @@ -39,9 +39,9 @@ suspend fun TelegramBot.sendInvoice( description: String, payload: String, providerToken: String, - startParameter: StartParameter, currency: Currency, prices: List, + startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, requirePhoneNumber: Boolean = false, @@ -54,7 +54,7 @@ suspend fun TelegramBot.sendInvoice( replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(user.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithInvoice( to: Message, @@ -62,9 +62,9 @@ suspend inline fun TelegramBot.replyWithInvoice( description: String, payload: String, providerToken: String, - startParameter: StartParameter, currency: Currency, prices: List, + startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, requirePhoneNumber: Boolean = false, @@ -76,4 +76,4 @@ suspend inline fun TelegramBot.replyWithInvoice( disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(to.chat.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) From a26568aa29b96120b16354904779b247c979426e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 20:01:14 +0600 Subject: [PATCH 06/63] maxTipAmounts and suggestedTipAmounts support in SendInvoice --- CHANGELOG.md | 1 + .../requests/send/payments/SendInvoice.kt | 15 +++++++++++++++ .../extensions/api/send/payments/SendInvoice.kt | 12 +++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f70820e6db..19b18d22a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * `Core`: * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor + * Fields `SendInvoice#maxTipAmount` and `SendInvoice#suggestedTipAmounts` have been added ## 0.33.4 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt index 6d7d490321..ff4439c0b3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt @@ -35,6 +35,10 @@ data class SendInvoice( @Serializable(LabeledPricesSerializer::class) @SerialName(pricesField) override val prices: List, + @SerialName(maxTipAmountField) + val maxTipAmount: Int? = null, + @SerialName(suggestedTipAmountsField) + val suggestedTipAmounts: List? = null, @SerialName(startParameterField) val startParameter: StartParameter? = null, @SerialName(providerDataField) @@ -88,6 +92,17 @@ data class SendInvoice( var photoHeight: Int? = null private set + init { + suggestedTipAmounts ?.let { _ -> + require(suggestedTipAmounts.size in suggestedTipAmountsLimit) + maxTipAmount ?.let { _ -> + require( + suggestedTipAmounts.none { it > maxTipAmount } + ) + } + } + } + fun setPhoto( photoUrl: String, photoSize: Long? = null, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt index 9812c7e83c..1fdce04371 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt @@ -16,6 +16,8 @@ suspend fun TelegramBot.sendInvoice( providerToken: String, currency: Currency, prices: List, + maxTipAmount: Int? = null, + suggestedTipAmounts: List? = null, startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, @@ -30,7 +32,7 @@ suspend fun TelegramBot.sendInvoice( allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute( - SendInvoice(chatId, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) suspend fun TelegramBot.sendInvoice( @@ -41,6 +43,8 @@ suspend fun TelegramBot.sendInvoice( providerToken: String, currency: Currency, prices: List, + maxTipAmount: Int? = null, + suggestedTipAmounts: List? = null, startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, @@ -54,7 +58,7 @@ suspend fun TelegramBot.sendInvoice( replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithInvoice( to: Message, @@ -64,6 +68,8 @@ suspend inline fun TelegramBot.replyWithInvoice( providerToken: String, currency: Currency, prices: List, + maxTipAmount: Int? = null, + suggestedTipAmounts: List? = null, startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, @@ -76,4 +82,4 @@ suspend inline fun TelegramBot.replyWithInvoice( disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) From 6a3588bb8d4a8de2ece829d7887bb4d0a2abdbfa Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 20:23:26 +0600 Subject: [PATCH 07/63] InputInvoiceMessageContent --- CHANGELOG.md | 1 + .../CommonAbstracts/CommonSendInvoiceData.kt | 35 ++++++++ .../requests/send/payments/SendInvoice.kt | 50 ++++++------ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 5 ++ .../InputInvoiceMessageContent.kt | 80 +++++++++++++++++++ .../InputMessageContentSerializer.kt | 1 + 6 files changed, 147 insertions(+), 25 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputInvoiceMessageContent.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 19b18d22a8..f1f7b08b50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * `Core`: * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor * Fields `SendInvoice#maxTipAmount` and `SendInvoice#suggestedTipAmounts` have been added + * New type `InputInvoiceMessageContent` has been added ## 0.33.4 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt new file mode 100644 index 0000000000..557da34271 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt @@ -0,0 +1,35 @@ +package dev.inmo.tgbotapi.CommonAbstracts + +import dev.inmo.tgbotapi.types.payments.abstracts.* + +interface CommonSendInvoiceData : Titled, Currencied, Priced { + val description: String + val payload: String + val providerToken: String + val maxTipAmount: Int? + val suggestedTipAmounts: List? + val providerData: String? + val requireName: Boolean + val requirePhoneNumber: Boolean + val requireEmail: Boolean + val requireShippingAddress: Boolean + val shouldSendPhoneNumberToProvider: Boolean + val shouldSendEmailToProvider: Boolean + val priceDependOnShipAddress: Boolean + + val photoUrl: String? + val photoSize: Long? + val photoWidth: Int? + val photoHeight: Int? + + + + fun setPhoto( + photoUrl: String, + photoSize: Long? = null, + photoWidth: Int? = null, + photoHeight: Int? = null + ) + + fun unsetPhoto() +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt index ff4439c0b3..f804fdf561 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.requests.send.payments +import dev.inmo.tgbotapi.CommonAbstracts.CommonSendInvoiceData import dev.inmo.tgbotapi.CommonAbstracts.types.* import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.types.* @@ -23,40 +24,40 @@ data class SendInvoice( @SerialName(chatIdField) override val chatId: ChatId, @SerialName(titleField) - val title: String, + override val title: String, @SerialName(descriptionField) - val description: String, + override val description: String, @SerialName(payloadField) - val payload: String, + override val payload: String, @SerialName(providerTokenField) - val providerToken: String, + override val providerToken: String, @SerialName(currencyField) override val currency: Currency, @Serializable(LabeledPricesSerializer::class) @SerialName(pricesField) override val prices: List, @SerialName(maxTipAmountField) - val maxTipAmount: Int? = null, + override val maxTipAmount: Int? = null, @SerialName(suggestedTipAmountsField) - val suggestedTipAmounts: List? = null, + override val suggestedTipAmounts: List? = null, @SerialName(startParameterField) val startParameter: StartParameter? = null, @SerialName(providerDataField) - val providerData: String? = null, + override val providerData: String? = null, @SerialName(requireNameField) - val requireName: Boolean = false, + override val requireName: Boolean = false, @SerialName(requirePhoneNumberField) - val requirePhoneNumber: Boolean = false, + override val requirePhoneNumber: Boolean = false, @SerialName(requireEmailField) - val requireEmail: Boolean = false, + override val requireEmail: Boolean = false, @SerialName(requireShippingAddressField) - val requireShippingAddress: Boolean = false, + override val requireShippingAddress: Boolean = false, @SerialName(shouldSendPhoneNumberToProviderField) - val shouldSendPhoneNumberToProvider: Boolean = false, + override val shouldSendPhoneNumberToProvider: Boolean = false, @SerialName(shouldSendEmailToProviderField) - val shouldSendEmailToProvider: Boolean = false, + override val shouldSendEmailToProvider: Boolean = false, @SerialName(priceDependOnShipAddressField) - val priceDependOnShipAddress: Boolean = false, + override val priceDependOnShipAddress: Boolean = false, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(replyToMessageIdField) @@ -65,8 +66,7 @@ data class SendInvoice( override val allowSendingWithoutReply: Boolean? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null -) : Currencied, - Priced, +) : CommonSendInvoiceData, ChatRequest, DisableNotification, ReplyMessageId, @@ -79,17 +79,17 @@ data class SendInvoice( get() = serializer() @SerialName(photoUrlField) - var photoUrl: String? = null + override var photoUrl: String? = null private set @SerialName(photoSizeField) - var photoSize: Long? = null + override var photoSize: Long? = null private set @SerialName(photoWidthField) - var photoWidth: Int? = null + override var photoWidth: Int? = null private set @SerialName(photoHeightField) - var photoHeight: Int? = null + override var photoHeight: Int? = null private set init { @@ -103,11 +103,11 @@ data class SendInvoice( } } - fun setPhoto( + override fun setPhoto( photoUrl: String, - photoSize: Long? = null, - photoWidth: Int? = null, - photoHeight: Int? = null + photoSize: Long?, + photoWidth: Int?, + photoHeight: Int? ) { this.photoUrl = photoUrl this.photoSize = photoSize @@ -115,7 +115,7 @@ data class SendInvoice( this.photoHeight = photoHeight } - fun unsetPhoto() { + override fun unsetPhoto() { photoUrl = null photoSize = null photoWidth = null diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index c1c935fb26..51a3dd4859 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -80,6 +80,8 @@ val openPeriodPollSecondsLimit = 5 .. 600 val membersLimit = 1 .. 99999 +val suggestedTipAmountsLimit = 1 .. 4 + const val botActionActualityTime: Seconds = 5 // Made as lazy for correct work in K/JS @@ -315,6 +317,9 @@ const val xShiftField = "x_shift" const val yShiftField = "y_shift" const val scaleField = "scale" +const val maxTipAmountField = "max_tip_amount" +const val suggestedTipAmountsField = "suggested_tip_amounts" + const val explanationEntitiesField = "explanation_entities" const val explanationParseModeField = "explanation_parse_mode" const val openPeriodField = "open_period" 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 new file mode 100644 index 0000000000..c02c3f7a03 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputInvoiceMessageContent.kt @@ -0,0 +1,80 @@ +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 +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +class InputInvoiceMessageContent( + @SerialName(titleField) + override val title: String, + @SerialName(descriptionField) + override val description: String, + @SerialName(payloadField) + override val payload: String, + @SerialName(providerTokenField) + override val providerToken: String, + @SerialName(currencyField) + override val currency: Currency, + @Serializable(LabeledPricesSerializer::class) + @SerialName(pricesField) + override val prices: List, + @SerialName(maxTipAmountField) + override val maxTipAmount: Int? = null, + @SerialName(suggestedTipAmountsField) + override val suggestedTipAmounts: List? = null, + @SerialName(providerDataField) + override val providerData: String? = null, + @SerialName(requireNameField) + override val requireName: Boolean = false, + @SerialName(requirePhoneNumberField) + override val requirePhoneNumber: Boolean = false, + @SerialName(requireEmailField) + override val requireEmail: Boolean = false, + @SerialName(requireShippingAddressField) + override val requireShippingAddress: Boolean = false, + @SerialName(shouldSendPhoneNumberToProviderField) + override val shouldSendPhoneNumberToProvider: Boolean = false, + @SerialName(shouldSendEmailToProviderField) + override val shouldSendEmailToProvider: Boolean = false, + @SerialName(priceDependOnShipAddressField) + override val priceDependOnShipAddress: Boolean = false +) : InputMessageContent, CommonSendInvoiceData { + @SerialName(photoUrlField) + override var photoUrl: String? = null + private set + @SerialName(photoSizeField) + override var photoSize: Long? = null + private set + + @SerialName(photoWidthField) + override var photoWidth: Int? = null + private set + @SerialName(photoHeightField) + override var photoHeight: Int? = null + private set + + override fun setPhoto( + photoUrl: String, + photoSize: Long?, + photoWidth: Int?, + photoHeight: Int? + ) { + this.photoUrl = photoUrl + this.photoSize = photoSize + this.photoWidth = photoWidth + this.photoHeight = photoHeight + } + + override fun unsetPhoto() { + photoUrl = null + photoSize = null + photoWidth = null + photoHeight = null + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt index 58e4c76a13..39052ffbc4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt @@ -17,6 +17,7 @@ internal object InputMessageContentSerializer : KSerializer is InputLocationMessageContent -> InputLocationMessageContent.serializer().serialize(encoder, value) is InputTextMessageContent -> InputTextMessageContent.serializer().serialize(encoder, value) is InputVenueMessageContent -> InputVenueMessageContent.serializer().serialize(encoder, value) + is InputInvoiceMessageContent -> InputInvoiceMessageContent.serializer().serialize(encoder, value) else -> throw IllegalArgumentException("Unknown for serializing InputContactMessageContent") } } From 694bec22a2872f8bcc1096ea86c706993d2b1ede Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 20:42:26 +0600 Subject: [PATCH 08/63] include chat_type --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../InlineQueries/abstracts/InlineQuery.kt | 2 + .../InlineQueries/query/BaseInlineQuery.kt | 4 +- .../query/LocationInlineQuery.kt | 3 + .../InlineQueries/query/RawInlineQuery.kt | 12 ++-- .../tgbotapi/types/chat/ChatSerializers.kt | 66 +++++++++++++++---- .../chat/abstracts/extended/ExtendedChat.kt | 10 ++- 7 files changed, 78 insertions(+), 20 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 51a3dd4859..1aec90b33c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -319,6 +319,7 @@ const val scaleField = "scale" const val maxTipAmountField = "max_tip_amount" const val suggestedTipAmountsField = "suggested_tip_amounts" +const val chatTypeField = "chat_type" const val explanationEntitiesField = "explanation_entities" const val explanationParseModeField = "explanation_parse_mode" 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 c785cf5801..d942a452d7 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 @@ -2,10 +2,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.abstracts 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 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 ba1e09280a..c127b2f1c1 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 @@ -3,10 +3,12 @@ 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 data class BaseInlineQuery( override val id: InlineQueryIdentifier, override val from: User, override val query: String, - override val offset: String + override val offset: String, + override val chatType: ChatType? ) : InlineQuery 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 fe94c7e34d..89ce364dbf 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 @@ -3,12 +3,15 @@ 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 import dev.inmo.tgbotapi.types.location.Location +import kotlinx.serialization.Serializable data class LocationInlineQuery( override val id: InlineQueryIdentifier, override val from: User, override val query: String, override val offset: String, + override val chatType: ChatType?, val location: Location ) : InlineQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/RawInlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/RawInlineQuery.kt index eaf43fca71..e660c71882 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/RawInlineQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/RawInlineQuery.kt @@ -1,9 +1,10 @@ package dev.inmo.tgbotapi.types.InlineQueries.query import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.ChatType +import dev.inmo.tgbotapi.types.chat.ChatTypeSerializer import dev.inmo.tgbotapi.types.location.Location -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* @Serializable internal data class RawInlineQuery( @@ -15,12 +16,15 @@ internal data class RawInlineQuery( val query: String, @SerialName(offsetField) val offset: String, + @SerialName(chatTypeField) + @Serializable(ChatTypeSerializer::class) + val chatType: ChatType? = null, @SerialName(locationField) val location: Location? = null ) { val asInlineQuery by lazy { location ?.let { - LocationInlineQuery(id, from, query, offset, location) - } ?: BaseInlineQuery(id, from, query, offset) + LocationInlineQuery(id, from, query, offset, chatType, location) + } ?: BaseInlineQuery(id, from, query, offset, chatType) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt index 23a27339a0..56a0c78fb1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt @@ -4,10 +4,10 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.chat.abstracts.UnknownChatType import dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat +import dev.inmo.tgbotapi.types.chat.abstracts.extended.UnknownExtendedChat import dev.inmo.tgbotapi.types.chat.extended.* import dev.inmo.tgbotapi.utils.nonstrictJsonFormat -import kotlinx.serialization.InternalSerializationApi -import kotlinx.serialization.KSerializer +import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder @@ -17,6 +17,40 @@ import kotlinx.serialization.json.* private val formatter get() = nonstrictJsonFormat +@Serializable(ChatTypeSerializer::class) +sealed class ChatType { + abstract val stringified: String + @Serializable(ChatTypeSerializer::class) + object PrivateChatType : ChatType() { override val stringified = "private" } + @Serializable(ChatTypeSerializer::class) + object GroupChatType : ChatType() { override val stringified = "group" } + @Serializable(ChatTypeSerializer::class) + object SupergroupChatType : ChatType() { override val stringified = "supergroup" } + @Serializable(ChatTypeSerializer::class) + object ChannelChatType : ChatType() { override val stringified = "channel" } + @Serializable(ChatTypeSerializer::class) + class UnknownChatType(override val stringified: String) : ChatType() +} +val String.asChatType + get() = when (this) { + ChatType.PrivateChatType.stringified -> ChatType.PrivateChatType + ChatType.GroupChatType.stringified -> ChatType.GroupChatType + ChatType.SupergroupChatType.stringified -> ChatType.SupergroupChatType + ChatType.ChannelChatType.stringified -> ChatType.ChannelChatType + else -> ChatType.UnknownChatType(this) + } +@Serializer(ChatType::class) +object ChatTypeSerializer : KSerializer { + override val descriptor: SerialDescriptor = String.serializer().descriptor + override fun deserialize(decoder: Decoder): ChatType { + return decoder.decodeString().asChatType + } + + override fun serialize(encoder: Encoder, value: ChatType) { + encoder.encodeString(value.stringified) + } +} + internal object PreviewChatSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) @@ -24,14 +58,14 @@ internal object PreviewChatSerializer : KSerializer { override fun deserialize(decoder: Decoder): Chat { val decodedJson = JsonObject.serializer().deserialize(decoder) - val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?: error("Field $typeField must be presented, but absent in $decodedJson") + val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson") return when (type) { - "private" -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson) - "group" -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson) - "supergroup" -> formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson) - "channel" -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson) - else -> UnknownChatType( + ChatType.PrivateChatType -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson) + ChatType.GroupChatType -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson) + ChatType.SupergroupChatType -> formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson) + ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson) + is ChatType.UnknownChatType -> UnknownChatType( formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(), decodedJson.toString() ) @@ -56,14 +90,18 @@ internal object ExtendedChatSerializer : KSerializer { override fun deserialize(decoder: Decoder): ExtendedChat { val decodedJson = JsonObject.serializer().deserialize(decoder) - val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?: error("Field $typeField must be presented, but absent in $decodedJson") + val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson") return when (type) { - "private" -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson) - "group" -> formatter.decodeFromJsonElement(ExtendedGroupChatImpl.serializer(), decodedJson) - "supergroup" -> formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson) - "channel" -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson) - else -> throw IllegalArgumentException("Unknown type of chat") +// else -> throw IllegalArgumentException("Unknown type of chat") + ChatType.PrivateChatType -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson) + ChatType.GroupChatType -> formatter.decodeFromJsonElement(ExtendedGroupChatImpl.serializer(), decodedJson) + ChatType.SupergroupChatType -> formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson) + ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson) + is ChatType.UnknownChatType -> UnknownExtendedChat( + formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(), + decodedJson.toString() + ) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/extended/ExtendedChat.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/extended/ExtendedChat.kt index 9a888d273c..dea56901e6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/extended/ExtendedChat.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/extended/ExtendedChat.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.chat.abstracts.extended +import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.ChatPhoto import dev.inmo.tgbotapi.types.chat.ExtendedChatSerializer import dev.inmo.tgbotapi.types.chat.abstracts.Chat @@ -8,4 +9,11 @@ import kotlinx.serialization.Serializable @Serializable(ExtendedChatSerializer::class) interface ExtendedChat : Chat { val chatPhoto: ChatPhoto? -} \ No newline at end of file +} + +data class UnknownExtendedChat( + override val id: ChatId, + val raw: String +) : ExtendedChat { + override val chatPhoto: ChatPhoto? = null +} From df63ccfe07ca1f12122593a7941d3160f74e0cc1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 20:47:03 +0600 Subject: [PATCH 09/63] VoiceChatScheduled --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../message/ChatEvents/voice/VoiceChatScheduled.kt | 12 ++++++++++++ .../dev/inmo/tgbotapi/types/message/RawMessage.kt | 2 ++ 3 files changed, 15 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 1aec90b33c..8c89fdf0d5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -355,6 +355,7 @@ const val providerPaymentChargeIdField = "provider_payment_charge_id" const val providerTokenField = "provider_token" const val providerDataField = "provider_data" const val usersField = "users" +const val startDateField = "start_date" const val requireNameField = "need_name" const val requirePhoneNumberField = "need_phone_number" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt new file mode 100644 index 0000000000..548eea8e92 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.voice + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class VoiceChatScheduled( + @SerialName(startDateField) + val startDate: TelegramDate +) : VoiceChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 2d3ebdc703..4209fa119d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -83,6 +83,7 @@ internal data class RawMessage( private val successful_payment: SuccessfulPayment? = null, // Voice Chat Service Messages + private val voice_chat_scheduled: VoiceChatScheduled? = null, private val voice_chat_started: VoiceChatStarted? = null, private val voice_chat_ended: VoiceChatEnded? = null, private val voice_chat_participants_invited: VoiceChatParticipantsInvited? = null, @@ -182,6 +183,7 @@ internal data class RawMessage( new_chat_title != null -> NewChatTitle(new_chat_title) new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList()) voice_chat_started != null -> voice_chat_started + voice_chat_scheduled != null -> voice_chat_scheduled message_auto_delete_timer_changed != null -> message_auto_delete_timer_changed voice_chat_ended != null -> voice_chat_ended voice_chat_participants_invited != null -> voice_chat_participants_invited From b2770e3ecc4e6b7e689b724c46fe4dc5445debbe Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 20:52:20 +0600 Subject: [PATCH 10/63] record_voice and upload_voice --- .../inmo/tgbotapi/types/actions/BotAction.kt | 22 +++++++++++++++++++ .../extensions/api/send/SendAction.kt | 16 ++++++++++++++ .../extensions/api/send/SendActionDSL.kt | 4 ++++ .../tgbotapi/extensions/utils/ClassCasts.kt | 8 +++++++ 4 files changed, 50 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt index 6732f68fad..ed9d95b567 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt @@ -101,6 +101,28 @@ inline val uploadAudio get() = UploadAudioAction inline fun BotAction.asUploadAudio() = this as? UploadAudioAction +/** + * Will notify user that bot is recording some audio + */ +@Serializable(BotActionSerializer::class) +object RecordVoiceAction : BotAction() { + override val actionName: String = "record_voice" +} +inline val recordVoice + get() = RecordVoiceAction +inline fun BotAction.asRecordVoice() = this as? RecordVoiceAction + +/** + * Will notify user that bot is uploading some audio + */ +@Serializable(BotActionSerializer::class) +object UploadVoiceAction : BotAction() { + override val actionName: String = "upload_voice" +} +inline val uploadVoice + get() = UploadVoiceAction +inline fun BotAction.asUploadVoice() = this as? UploadVoiceAction + /** * Will notify user that bot is uploading some document */ diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt index 05ab7eb80f..237f91f4fd 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt @@ -43,6 +43,14 @@ suspend fun TelegramBot.sendActionUploadAudio( chatId: ChatIdentifier ) = sendBotAction(chatId, UploadAudioAction) +suspend fun TelegramBot.sendActionRecordVoice( + chatId: ChatIdentifier +) = sendBotAction(chatId, RecordVoiceAction) + +suspend fun TelegramBot.sendActionUploadVoice( + chatId: ChatIdentifier +) = sendBotAction(chatId, UploadVoiceAction) + suspend fun TelegramBot.sendActionUploadDocument( chatId: ChatIdentifier ) = sendBotAction(chatId, UploadDocumentAction) @@ -84,6 +92,14 @@ suspend fun TelegramBot.sendActionUploadAudio( chat: Chat ) = sendBotAction(chat, UploadAudioAction) +suspend fun TelegramBot.sendActionRecordVoice( + chat: Chat +) = sendBotAction(chat, RecordVoiceAction) + +suspend fun TelegramBot.sendActionUploadVoice( + chat: Chat +) = sendBotAction(chat, UploadVoiceAction) + suspend fun TelegramBot.sendActionUploadDocument( chat: Chat ) = sendBotAction(chat, UploadDocumentAction) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt index 13e964debe..84dbede24a 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt @@ -58,6 +58,8 @@ suspend fun TelegramBot.withRecordVideoAction(chatId: ChatId, block: Telegra suspend fun TelegramBot.withUploadVideoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadVideoAction, block) suspend fun TelegramBot.withRecordAudioAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordAudioAction, block) suspend fun TelegramBot.withUploadAudioAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadAudioAction, block) +suspend fun TelegramBot.withRecordVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordVoiceAction, block) +suspend fun TelegramBot.withUploadVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadVoiceAction, block) suspend fun TelegramBot.withUploadDocumentAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadDocumentAction, block) suspend fun TelegramBot.withFindLocationAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, FindLocationAction, block) suspend fun TelegramBot.withRecordVideoNoteAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordVideoNoteAction, block) @@ -70,6 +72,8 @@ suspend fun TelegramBot.withRecordVideoAction(chat: Chat, block: TelegramBot suspend fun TelegramBot.withUploadVideoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadVideoAction, block) suspend fun TelegramBot.withRecordAudioAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordAudioAction, block) suspend fun TelegramBot.withUploadAudioAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadAudioAction, block) +suspend fun TelegramBot.withRecordVoiceAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordVoiceAction, block) +suspend fun TelegramBot.withUploadVoiceAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadVoiceAction, block) suspend fun TelegramBot.withUploadDocumentAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadDocumentAction, block) suspend fun TelegramBot.withFindLocationAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, FindLocationAction, block) suspend fun TelegramBot.withRecordVideoNoteAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordVideoNoteAction, block) 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 21fc99db2e..aa0e254bbe 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 @@ -525,6 +525,10 @@ inline fun BotAction.asRecordAudioAction(): RecordAudioAction? = this as? Record @PreviewFeature inline fun BotAction.requireRecordAudioAction(): RecordAudioAction = this as RecordAudioAction @PreviewFeature +inline fun BotAction.asRecordVoiceAction(): RecordVoiceAction? = this as? RecordVoiceAction +@PreviewFeature +inline fun BotAction.requireRecordVoiceAction(): RecordVoiceAction = this as RecordVoiceAction +@PreviewFeature inline fun BotAction.asRecordVideoAction(): RecordVideoAction? = this as? RecordVideoAction @PreviewFeature inline fun BotAction.requireRecordVideoAction(): RecordVideoAction = this as RecordVideoAction @@ -541,6 +545,10 @@ inline fun BotAction.asUploadAudioAction(): UploadAudioAction? = this as? Upload @PreviewFeature inline fun BotAction.requireUploadAudioAction(): UploadAudioAction = this as UploadAudioAction @PreviewFeature +inline fun BotAction.asUploadVoiceAction(): UploadVoiceAction? = this as? UploadVoiceAction +@PreviewFeature +inline fun BotAction.requireUploadVoiceAction(): UploadVoiceAction = this as UploadVoiceAction +@PreviewFeature inline fun BotAction.asUploadDocumentAction(): UploadDocumentAction? = this as? UploadDocumentAction @PreviewFeature inline fun BotAction.requireUploadDocumentAction(): UploadDocumentAction = this as UploadDocumentAction From 87071ca52c9ed7ea7a3c644147ede82d9f45e2a6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 21:02:11 +0600 Subject: [PATCH 11/63] deprecation of an old record audio and upload audio bot actions --- .../inmo/tgbotapi/types/actions/BotAction.kt | 26 +++++++++++++++++++ .../extensions/api/send/SendAction.kt | 16 ++++++++++++ .../extensions/api/send/SendActionDSL.kt | 16 ++++++++++++ 3 files changed, 58 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt index ed9d95b567..ea15453612 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt @@ -26,6 +26,8 @@ internal object BotActionSerializer: KSerializer { UploadVideoAction.actionName -> UploadVideoAction RecordAudioAction.actionName -> RecordAudioAction UploadAudioAction.actionName -> UploadAudioAction + RecordVoiceAction.actionName -> RecordVoiceAction + UploadVoiceAction.actionName -> UploadVoiceAction UploadDocumentAction.actionName -> UploadDocumentAction FindLocationAction.actionName -> FindLocationAction RecordVideoNoteAction.actionName -> RecordVideoNoteAction @@ -83,22 +85,46 @@ inline fun BotAction.asUploadVideo() = this as? UploadVideoAction * Will notify user that bot is recording some audio */ @Serializable(BotActionSerializer::class) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("RecordVoiceAction", "dev.inmo.tgbotapi.types.actions.RecordVoiceAction") +) object RecordAudioAction : BotAction() { override val actionName: String = "record_audio" } +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("recordVoice", "dev.inmo.tgbotapi.types.actions.recordVoice") +) inline val recordAudio get() = RecordAudioAction +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("asRecordVoice", "dev.inmo.tgbotapi.types.actions.asRecordVoice") +) inline fun BotAction.asRecordAudio() = this as? RecordAudioAction /** * Will notify user that bot is uploading some audio */ @Serializable(BotActionSerializer::class) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("UploadVoiceAction", "dev.inmo.tgbotapi.types.actions.UploadVoiceAction") +) object UploadAudioAction : BotAction() { override val actionName: String = "upload_audio" } +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("uploadVoice", "dev.inmo.tgbotapi.types.actions.uploadVoice") +) inline val uploadAudio get() = UploadAudioAction +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("asUploadVoice", "dev.inmo.tgbotapi.types.actions.asUploadVoice") +) inline fun BotAction.asUploadAudio() = this as? UploadAudioAction /** diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt index 237f91f4fd..71e11aef1c 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt @@ -35,10 +35,18 @@ suspend fun TelegramBot.sendActionUploadVideo( chatId: ChatIdentifier ) = sendBotAction(chatId, UploadVideoAction) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("sendActionRecordVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionRecordVoice") +) suspend fun TelegramBot.sendActionRecordAudio( chatId: ChatIdentifier ) = sendBotAction(chatId, RecordAudioAction) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("sendActionUploadVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionUploadVoice") +) suspend fun TelegramBot.sendActionUploadAudio( chatId: ChatIdentifier ) = sendBotAction(chatId, UploadAudioAction) @@ -84,10 +92,18 @@ suspend fun TelegramBot.sendActionUploadVideo( chat: Chat ) = sendBotAction(chat, UploadVideoAction) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("sendActionRecordVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionRecordVoice") +) suspend fun TelegramBot.sendActionRecordAudio( chat: Chat ) = sendBotAction(chat, RecordAudioAction) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("sendActionUploadVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionUploadVoice") +) suspend fun TelegramBot.sendActionUploadAudio( chat: Chat ) = sendBotAction(chat, UploadAudioAction) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt index 84dbede24a..0e9f1fb94e 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt @@ -56,7 +56,15 @@ suspend fun TelegramBot.withTypingAction(chatId: ChatId, block: TelegramBotA suspend fun TelegramBot.withUploadPhotoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadPhotoAction, block) suspend fun TelegramBot.withRecordVideoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordVideoAction, block) suspend fun TelegramBot.withUploadVideoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadVideoAction, block) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("withRecordVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withRecordVoiceAction") +) suspend fun TelegramBot.withRecordAudioAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordAudioAction, block) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("withUploadVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withUploadVoiceAction") +) suspend fun TelegramBot.withUploadAudioAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadAudioAction, block) suspend fun TelegramBot.withRecordVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordVoiceAction, block) suspend fun TelegramBot.withUploadVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadVoiceAction, block) @@ -70,7 +78,15 @@ suspend fun TelegramBot.withTypingAction(chat: Chat, block: TelegramBotActio suspend fun TelegramBot.withUploadPhotoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadPhotoAction, block) suspend fun TelegramBot.withRecordVideoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordVideoAction, block) suspend fun TelegramBot.withUploadVideoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadVideoAction, block) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("withRecordVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withRecordVoiceAction") +) suspend fun TelegramBot.withRecordAudioAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordAudioAction, block) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("withUploadVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withUploadVoiceAction") +) suspend fun TelegramBot.withUploadAudioAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadAudioAction, block) suspend fun TelegramBot.withRecordVoiceAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordVoiceAction, block) suspend fun TelegramBot.withUploadVoiceAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadVoiceAction, block) From 7da315dbaf599e7ba814310c0ade5caf3e90d4fa Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 21:08:52 +0600 Subject: [PATCH 12/63] fix botaction tests --- .../kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt index 0b5ed05d2c..ac102469a5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt @@ -6,11 +6,6 @@ interface Captioned { val caption: String? } -@Deprecated("This interface is not used in library and will be removed soon") -interface CaptionedOutput : Captioned { - val parseMode: ParseMode? -} - interface CaptionedInput : Captioned { /** * Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] From 946b0222df42496a0eb1cf4e1c2e99ae97fe0123 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 21:10:38 +0600 Subject: [PATCH 13/63] fix botaction tests --- .../kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt index a0f688c821..8dd4d8f159 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt @@ -22,6 +22,8 @@ class BotActionTests { UploadVideoAction -> example.botAction.actionName RecordAudioAction -> example.botAction.actionName UploadAudioAction -> example.botAction.actionName + RecordVoiceAction -> example.botAction.actionName + UploadVoiceAction -> example.botAction.actionName UploadDocumentAction -> example.botAction.actionName FindLocationAction -> example.botAction.actionName RecordVideoNoteAction -> example.botAction.actionName @@ -51,6 +53,8 @@ class BotActionTests { UploadVideoAction.example(), RecordAudioAction.example(), UploadAudioAction.example(), + RecordVoiceAction.example(), + UploadVoiceAction.example(), UploadDocumentAction.example(), FindLocationAction.example(), RecordVideoNoteAction.example(), From d69b2e09d50f689abbb76636f01202f891341ad2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 21:25:52 +0600 Subject: [PATCH 14/63] migration from CaptionedInput --- .../tgbotapi/CommonAbstracts/Captioned.kt | 12 ++++++-- .../requests/send/media/SendAnimation.kt | 2 +- .../tgbotapi/requests/send/media/SendAudio.kt | 2 +- .../requests/send/media/SendDocument.kt | 2 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 2 +- .../tgbotapi/requests/send/media/SendVideo.kt | 2 +- .../tgbotapi/requests/send/media/SendVoice.kt | 2 +- .../types/InputMedia/InputMediaAudio.kt | 2 +- .../types/InputMedia/InputMediaDocument.kt | 8 +++--- .../types/InputMedia/InputMediaPhoto.kt | 2 +- .../inmo/tgbotapi/types/files/VideoFile.kt | 2 +- .../dev/inmo/tgbotapi/types/games/Game.kt | 6 ++-- .../dev/inmo/tgbotapi/types/games/RawGame.kt | 8 +++--- .../content/abstracts/MediaGroupContent.kt | 2 +- .../message/content/media/AnimationContent.kt | 6 ++-- .../message/content/media/AudioContent.kt | 4 +-- .../message/content/media/DocumentContent.kt | 10 +++---- .../message/content/media/PhotoContent.kt | 4 +-- .../message/content/media/VideoContent.kt | 4 +-- .../message/content/media/VoiceContent.kt | 6 ++-- .../edit/caption/EditChatMessageCaption.kt | 7 ++--- .../extensions/api/send/media/SendPhoto.kt | 28 +++++++++---------- 22 files changed, 65 insertions(+), 58 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt index ac102469a5..1e3bfc3a08 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt @@ -2,15 +2,23 @@ package dev.inmo.tgbotapi.CommonAbstracts import dev.inmo.tgbotapi.types.ParseMode.ParseMode -interface Captioned { +const val CaptionDeprecation = "Captioned interface and others will be removed soon and not recommended to use" + +@Deprecated(CaptionDeprecation) +interface Captioned : Texted { + @Deprecated(CaptionDeprecation) val caption: String? + get() = text } -interface CaptionedInput : Captioned { +@Deprecated(CaptionDeprecation) +interface CaptionedInput : Captioned, TextedInput { /** * Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] */ + @Deprecated(CaptionDeprecation) val captionEntities: List + get() = textEntities } /** 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 4e58cc23a4..4e8ea44666 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 @@ -20,7 +20,7 @@ fun SendAnimation( chatId: ChatIdentifier, animation: InputFile, thumb: InputFile? = null, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, width: Int? = 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 82e15305a9..8cd2d2cf15 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 @@ -20,7 +20,7 @@ fun SendAudio( chatId: ChatIdentifier, audio: InputFile, thumb: InputFile? = null, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, performer: 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 6a515be8a4..d562c93175 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 @@ -29,7 +29,7 @@ fun SendDocument( chatId: ChatIdentifier, document: InputFile, thumb: InputFile? = null, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = 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 c492456f31..81c2de4b79 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 @@ -18,7 +18,7 @@ import kotlinx.serialization.* fun SendPhoto( chatId: ChatIdentifier, photo: InputFile, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = 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 52e7ae8ba3..ec7849eba6 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 @@ -20,7 +20,7 @@ fun SendVideo( chatId: ChatIdentifier, video: InputFile, thumb: InputFile? = null, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, width: Int? = 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 69e6d0f756..b382478398 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 @@ -19,7 +19,7 @@ import kotlinx.serialization.* fun SendVoice( chatId: ChatIdentifier, voice: InputFile, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, disableNotification: Boolean = false, 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 5dc1aba16f..f6674becbb 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 @@ -62,7 +62,7 @@ data class InputMediaAudio internal constructor( } fun AudioFile.toInputMediaAudio( - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, title: String? = this.title ): InputMediaAudio = InputMediaAudio( 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 94e5af6b31..6772614459 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 @@ -13,11 +13,11 @@ internal const val documentInputMediaType = "document" fun InputMediaDocument( file: InputFile, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, thumb: InputFile? = null, disableContentTypeDetection: Boolean? = null -) = InputMediaDocument(file, caption, parseMode, null, thumb, disableContentTypeDetection) +) = InputMediaDocument(file, text, parseMode, null, thumb, disableContentTypeDetection) fun InputMediaDocument( file: InputFile, @@ -62,11 +62,11 @@ data class InputMediaDocument internal constructor( } fun DocumentFile.toInputMediaDocument( - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null ) = InputMediaDocument( fileId, - caption, + text, parseMode, thumb ?.fileId ) 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 05ba4fb671..1442965791 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 @@ -46,7 +46,7 @@ data class InputMediaPhoto internal constructor( } fun PhotoSize.toInputMediaPhoto( - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null ): InputMediaPhoto = InputMediaPhoto( fileId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index 45b4525896..aaff39b344 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -34,7 +34,7 @@ data class VideoFile( @Suppress("NOTHING_TO_INLINE") inline fun VideoFile.toInputMediaVideo( - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null ) = InputMediaVideo( fileId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt index 34043f6ad6..104411f5f1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt @@ -8,7 +8,7 @@ data class Game( override val title: String, val description: String, val photo: Photo, - override val caption: String? = null, - override val captionEntities: List = emptyList(), + override val text: String? = null, + override val textEntities: List = emptyList(), val animation: AnimationFile? = null -) : Titled, CaptionedInput +) : Titled, CaptionedInput, TextedInput diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt index a48c195f78..7861092005 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt @@ -16,9 +16,9 @@ internal data class RawGame( @SerialName(photoField) private val photo: Photo, @SerialName(textField) - private val caption: String? = null, + private val text: String? = null, @SerialName(textEntitiesField) - private val captionEntities: RawMessageEntities = emptyList(), + private val textEntities: RawMessageEntities = emptyList(), @SerialName(animationField) private val animation: AnimationFile? = null ) { @@ -27,8 +27,8 @@ internal data class RawGame( title, description, photo, - caption, - caption ?.let { _ -> captionEntities.asTextParts(caption) } ?: emptyList(), + text, + text ?.let { _ -> textEntities.asTextParts(text) } ?: emptyList(), animation ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt index 7cf2eb6b16..7d80e16de4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.message.content.abstracts import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput import dev.inmo.tgbotapi.types.InputMedia.* -interface MediaGroupContent : MediaContent, CaptionedInput { +interface MediaGroupContent : MediaContent, CaptionedInput, TextedInput { fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt index edbcb2312b..411446772e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt @@ -15,9 +15,9 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent data class AnimationContent( override val media: AnimationFile, val includedDocument: DocumentFile?, - override val caption: String?, - override val captionEntities: List -) : MediaContent, CaptionedInput { + override val text: String?, + override val textEntities: List +) : MediaContent, CaptionedInput, TextedInput { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt index 2d4f9a7148..f72f68b065 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt @@ -15,8 +15,8 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent data class AudioContent( override val media: AudioFile, - override val caption: String? = null, - override val captionEntities: List = emptyList() + override val text: String? = null, + override val textEntities: List = emptyList() ) : AudioMediaGroupContent { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt index 747cc77fdb..9a9be3d0cb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt @@ -16,8 +16,8 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent data class DocumentContent( override val media: DocumentFile, - override val caption: String? = null, - override val captionEntities: List = emptyList() + override val text: String? = null, + override val textEntities: List = emptyList() ) : DocumentMediaGroupContent { override fun createResend( chatId: ChatIdentifier, @@ -43,10 +43,10 @@ data class DocumentContent( @Suppress("NOTHING_TO_INLINE") inline fun MediaContent.asDocumentContent() = when (this) { - is CaptionedInput -> DocumentContent( + is TextedInput -> DocumentContent( media.asDocumentFile(), - caption, - captionEntities + text, + textEntities ) else -> DocumentContent( media.asDocumentFile() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt index 27fc6102fa..95ee54ddd4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt @@ -16,8 +16,8 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent data class PhotoContent( override val mediaCollection: Photo, - override val caption: String? = null, - override val captionEntities: List = emptyList() + override val text: String? = null, + override val textEntities: List = emptyList() ) : MediaCollectionContent, VisualMediaGroupContent { override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt index 5b1ec9197b..86d794e3b4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt @@ -15,8 +15,8 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent data class VideoContent( override val media: VideoFile, - override val caption: String? = null, - override val captionEntities: List = emptyList() + override val text: String? = null, + override val textEntities: List = emptyList() ) : VisualMediaGroupContent { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt index 421f2b6a75..0c682a34a2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt @@ -13,9 +13,9 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent data class VoiceContent( override val media: VoiceFile, - override val caption: String? = null, - override val captionEntities: List = emptyList() -) : MediaContent, CaptionedInput { + override val text: String? = null, + override val textEntities: List = emptyList() +) : MediaContent, CaptionedInput, TextedInput { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, 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 1becc8e0d3..f5b5fd554e 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 @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput -import dev.inmo.tgbotapi.CommonAbstracts.TextSource +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 @@ -35,7 +34,7 @@ suspend fun TelegramBot.editMessageCaption( text: String, parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null -): ContentMessage where T : CaptionedInput, T : MediaContent { +): ContentMessage where T : TextedInput, T : MediaContent { return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) } @@ -59,6 +58,6 @@ suspend fun TelegramBot.editMessageCaption( message: ContentMessage, entities: List, replyMarkup: InlineKeyboardMarkup? = null -): ContentMessage where T : CaptionedInput, T : MediaContent { +): ContentMessage where T : TextedInput, T : MediaContent { return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup) } 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 d4ee9ed59d..c641033456 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 @@ -16,7 +16,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message suspend fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -26,7 +26,7 @@ suspend fun TelegramBot.sendPhoto( SendPhoto( chatId, fileId, - caption, + text, parseMode, disableNotification, replyToMessageId, @@ -38,65 +38,65 @@ suspend fun TelegramBot.sendPhoto( suspend fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, caption, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, fileId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), caption, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, caption, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photo, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( to: Message, fileId: InputFile, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, caption, parseMode, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, fileId, text, parseMode, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( to: Message, photo: Photo, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, caption, parseMode, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photo, text, parseMode, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, photo: Photo, - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithPhoto(to, photo, caption, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) +) = replyWithPhoto(to, photo, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.sendPhoto( From 70f96ac8fa0b90dc41764e525aa654a991a31f8c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 21:34:13 +0600 Subject: [PATCH 15/63] completing of captioned input deprecation --- .../dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt | 2 +- .../kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt | 2 +- .../dev/inmo/tgbotapi/requests/send/media/SendDocument.kt | 2 +- .../kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt | 2 +- .../kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt | 2 +- .../kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt | 2 +- .../dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt | 2 +- .../dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt | 2 +- .../kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt | 2 +- .../types/message/content/abstracts/MediaGroupContent.kt | 1 + 10 files changed, 10 insertions(+), 9 deletions(-) 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 4e8ea44666..6a26483056 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 @@ -39,7 +39,7 @@ fun SendAnimation( chatId, animationAsFileId, thumbAsFileId, - caption, + text, parseMode, null, duration, 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 8cd2d2cf15..c95d7e7f7c 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 @@ -39,7 +39,7 @@ fun SendAudio( chatId, audioAsFileId, thumbAsFileId, - caption, + text, parseMode, null, duration, 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 d562c93175..8c7d0a9cc2 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 @@ -46,7 +46,7 @@ fun SendDocument( chatId, documentAsFileId, thumbAsFileId, - caption, + text, parseMode, null, disableNotification, 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 81c2de4b79..66d388ee91 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 @@ -28,7 +28,7 @@ fun SendPhoto( val data = SendPhotoData( chatId, (photo as? FileId) ?.fileId, - caption, + text, parseMode, null, disableNotification, 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 ec7849eba6..e50686c5dc 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 @@ -40,7 +40,7 @@ fun SendVideo( chatId, videoAsFileId, thumbAsFileId, - caption, + text, parseMode, null, duration, 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 b382478398..79b17c98e4 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 @@ -33,7 +33,7 @@ fun SendVoice( val data = SendVoiceData( chatId, voiceAsFileId, - caption, + text, parseMode, null, duration, 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 f6674becbb..598e0ddc4a 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 @@ -67,7 +67,7 @@ fun AudioFile.toInputMediaAudio( title: String? = this.title ): InputMediaAudio = InputMediaAudio( fileId, - caption, + text, parseMode, duration, performer, 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 1442965791..b3d56b4574 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 @@ -50,7 +50,7 @@ fun PhotoSize.toInputMediaPhoto( parseMode: ParseMode? = null ): InputMediaPhoto = InputMediaPhoto( fileId, - caption, + text, parseMode ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index aaff39b344..c3f761259b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -38,7 +38,7 @@ inline fun VideoFile.toInputMediaVideo( parseMode: ParseMode? = null ) = InputMediaVideo( fileId, - caption, + text, parseMode, width, height, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt index 7d80e16de4..354fb20903 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.message.content.abstracts import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.types.InputMedia.* interface MediaGroupContent : MediaContent, CaptionedInput, TextedInput { From eb3f180cc6cd91f757c5cc41254cbbf1daa9461d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Apr 2021 16:08:36 +0600 Subject: [PATCH 16/63] textSources now is main property --- CHANGELOG.md | 2 ++ .../inmo/tgbotapi/CommonAbstracts/Captioned.kt | 7 ------- .../dev/inmo/tgbotapi/CommonAbstracts/Texted.kt | 17 ++++++++--------- .../dev/inmo/tgbotapi/types/games/Game.kt | 2 +- .../dev/inmo/tgbotapi/types/games/RawGame.kt | 3 ++- .../inmo/tgbotapi/types/message/RawMessage.kt | 5 +++-- .../types/message/content/TextContent.kt | 2 +- .../message/content/media/AnimationContent.kt | 2 +- .../types/message/content/media/AudioContent.kt | 5 ++--- .../message/content/media/DocumentContent.kt | 4 ++-- .../types/message/content/media/PhotoContent.kt | 5 ++--- .../types/message/content/media/VideoContent.kt | 5 ++--- .../types/message/content/media/VoiceContent.kt | 2 +- 13 files changed, 27 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1f7b08b50..1ac97f9341 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor * Fields `SendInvoice#maxTipAmount` and `SendInvoice#suggestedTipAmounts` have been added * New type `InputInvoiceMessageContent` has been added + * `textSources` become main field in `TextedInput` + * `textEntities` become are calculable property in `TextedInput` ## 0.33.4 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt index 1e3bfc3a08..7d5b10c30e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt @@ -20,10 +20,3 @@ interface CaptionedInput : Captioned, TextedInput { val captionEntities: List get() = textEntities } - -/** - * @see CaptionedInput.captionEntities - * @see justTextSources - */ -val CaptionedInput.textSources - get() = captionEntities.justTextSources() 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 0b556444e5..1518631721 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.toTextParts import dev.inmo.tgbotapi.types.ParseMode.ParseMode interface Texted { @@ -17,19 +18,17 @@ interface EntitiesOutput : Texted { interface TextedOutput : ParsableOutput, EntitiesOutput interface TextedInput : Texted { + /** + * Full list of [TextSource] built from source[TextedInput.textEntities] + * + * @see justTextSources + */ + val textSources: List /** * Here must be full list of entities. This list must contains [TextPart]s with * [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of * regular text */ val textEntities: List + get() = textSources.toTextParts() } - -/** - * Full list of [TextSource] built from source[TextedInput.textEntities] - * - * @see TextedInput.textEntities - * @see justTextSources - */ -val TextedInput.textSources - get() = textEntities.justTextSources() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt index 104411f5f1..63c3c00241 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt @@ -9,6 +9,6 @@ data class Game( val description: String, val photo: Photo, override val text: String? = null, - override val textEntities: List = emptyList(), + override val textSources: TextSourcesList = emptyList(), val animation: AnimationFile? = null ) : Titled, CaptionedInput, TextedInput diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt index 7861092005..cf2225cd3a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.games +import dev.inmo.tgbotapi.CommonAbstracts.justTextSources import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.RawMessageEntities import dev.inmo.tgbotapi.types.MessageEntity.asTextParts @@ -28,7 +29,7 @@ internal data class RawGame( description, photo, text, - text ?.let { _ -> textEntities.asTextParts(text) } ?: emptyList(), + text ?.let { _ -> textEntities.asTextParts(text).justTextSources() } ?: emptyList(), animation ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 4209fa119d..4c93700cd7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.message +import dev.inmo.tgbotapi.CommonAbstracts.justTextSources import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.RawMessageEntities import dev.inmo.tgbotapi.types.MessageEntity.asTextParts @@ -102,11 +103,11 @@ internal data class RawMessage( ) { private val content: MessageContent? by lazy { val adaptedCaptionEntities = caption ?.let { - (caption_entities ?: emptyList()).asTextParts(caption) + (caption_entities ?: emptyList()).asTextParts(caption).justTextSources() } ?: emptyList() when { - text != null -> TextContent(text, (entities ?: emptyList()).asTextParts(text)) + text != null -> TextContent(text, (entities ?: emptyList()).asTextParts(text).justTextSources()) audio != null -> AudioContent( audio, caption, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index abc204e63e..d83ddd701b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -13,7 +13,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent data class TextContent( override val text: String, - override val textEntities: List = emptyList() + override val textSources: TextSourcesList = emptyList(), ) : MessageContent, TextedInput { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt index 411446772e..e1863bf213 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt @@ -16,7 +16,7 @@ data class AnimationContent( override val media: AnimationFile, val includedDocument: DocumentFile?, override val text: String?, - override val textEntities: List + override val textSources: TextSourcesList = emptyList() ) : MediaContent, CaptionedInput, TextedInput { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt index f72f68b065..83c17f8591 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextPart -import dev.inmo.tgbotapi.CommonAbstracts.textSources +import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendAudio import dev.inmo.tgbotapi.types.ChatIdentifier @@ -16,7 +15,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent data class AudioContent( override val media: AudioFile, override val text: String? = null, - override val textEntities: List = emptyList() + override val textSources: TextSourcesList = emptyList() ) : AudioMediaGroupContent { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt index 9a9be3d0cb..9c4f3a7581 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt @@ -17,7 +17,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent data class DocumentContent( override val media: DocumentFile, override val text: String? = null, - override val textEntities: List = emptyList() + override val textSources: TextSourcesList = emptyList() ) : DocumentMediaGroupContent { override fun createResend( chatId: ChatIdentifier, @@ -46,7 +46,7 @@ inline fun MediaContent.asDocumentContent() = when (this) { is TextedInput -> DocumentContent( media.asDocumentFile(), text, - textEntities + textSources ) else -> DocumentContent( media.asDocumentFile() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt index 95ee54ddd4..707ebcf29c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextPart -import dev.inmo.tgbotapi.CommonAbstracts.textSources +import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendPhoto import dev.inmo.tgbotapi.types.ChatIdentifier @@ -17,7 +16,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent data class PhotoContent( override val mediaCollection: Photo, override val text: String? = null, - override val textEntities: List = emptyList() + override val textSources: TextSourcesList = emptyList() ) : MediaCollectionContent, VisualMediaGroupContent { override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt index 86d794e3b4..717c5c01a1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextPart -import dev.inmo.tgbotapi.CommonAbstracts.textSources +import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendVideo import dev.inmo.tgbotapi.types.ChatIdentifier @@ -16,7 +15,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent data class VideoContent( override val media: VideoFile, override val text: String? = null, - override val textEntities: List = emptyList() + override val textSources: TextSourcesList = emptyList() ) : VisualMediaGroupContent { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt index 0c682a34a2..95e6340edf 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt @@ -14,7 +14,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent data class VoiceContent( override val media: VoiceFile, override val text: String? = null, - override val textEntities: List = emptyList() + override val textSources: TextSourcesList = emptyList() ) : MediaContent, CaptionedInput, TextedInput { override fun createResend( chatId: ChatIdentifier, From 42a8d649cdec936220b97965a08db4690577ee4b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 27 Apr 2021 23:43:04 +0600 Subject: [PATCH 17/63] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ac97f9341..c4735d1aee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,11 @@ * `Core`: * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor - * Fields `SendInvoice#maxTipAmount` and `SendInvoice#suggestedTipAmounts` have been added + * New interface `CommonSendInvoiceData` has been added + * Fields `CommonSendInvoiceData#maxTipAmount` and `CommonSendInvoiceData#suggestedTipAmounts` have been added * New type `InputInvoiceMessageContent` has been added + * Interface `Captioned` and `CaptionedInput` now is deprecated + * Most of captions usages were replaced with texts * `textSources` become main field in `TextedInput` * `textEntities` become are calculable property in `TextedInput` From 167c214e350402021981cb0b99647d82ac1196bf Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 28 Apr 2021 19:54:57 +0600 Subject: [PATCH 18/63] migration to avoid using of TextPart --- CHANGELOG.md | 1 + .../tgbotapi/CommonAbstracts/Explained.kt | 9 +- .../tgbotapi/CommonAbstracts/TextSource.kt | 16 +- .../inmo/tgbotapi/CommonAbstracts/Texted.kt | 3 - .../edit/caption/EditChatMessageCaption.kt | 2 +- .../edit/caption/EditInlineMessageCaption.kt | 2 +- .../requests/edit/text/EditChatMessageText.kt | 2 +- .../edit/text/EditInlineMessageText.kt | 2 +- .../tgbotapi/requests/send/CopyMessage.kt | 2 +- .../tgbotapi/requests/send/SendMessage.kt | 2 +- .../requests/send/media/SendAnimation.kt | 2 +- .../tgbotapi/requests/send/media/SendAudio.kt | 2 +- .../requests/send/media/SendDocument.kt | 2 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 2 +- .../tgbotapi/requests/send/media/SendVideo.kt | 2 +- .../tgbotapi/requests/send/media/SendVoice.kt | 2 +- .../tgbotapi/requests/send/polls/SendPoll.kt | 2 +- .../InlineQueryResultAudioCachedImpl.kt | 2 +- .../InlineQueryResultAudioImpl.kt | 2 +- .../InlineQueryResultDocumentCachedImpl.kt | 2 +- .../InlineQueryResultDocumentImpl.kt | 2 +- .../InlineQueryResultGifCachedImpl.kt | 2 +- .../InlineQueryResultGifImpl.kt | 2 +- .../InlineQueryResultMpeg4GifCachedImpl.kt | 2 +- .../InlineQueryResultMpeg4GifImpl.kt | 2 +- .../InlineQueryResultPhotoCachedImpl.kt | 2 +- .../InlineQueryResultPhotoImpl.kt | 2 +- .../InlineQueryResultVideoCachedImpl.kt | 2 +- .../InlineQueryResultVideoImpl.kt | 2 +- .../InlineQueryResultVoiceCachedImpl.kt | 2 +- .../InlineQueryResultVoiceImpl.kt | 2 +- .../InputTextMessageContent.kt | 2 +- .../types/InputMedia/InputMediaAnimation.kt | 2 +- .../types/InputMedia/InputMediaAudio.kt | 2 +- .../types/InputMedia/InputMediaDocument.kt | 2 +- .../types/InputMedia/InputMediaPhoto.kt | 2 +- .../types/InputMedia/InputMediaVideo.kt | 2 +- .../types/MessageEntity/RawMessageEntity.kt | 216 ++++++++++-------- .../textsources/TextSourceSerializer.kt | 7 - .../dev/inmo/tgbotapi/types/games/RawGame.kt | 5 +- .../inmo/tgbotapi/types/message/RawMessage.kt | 7 +- .../dev/inmo/tgbotapi/types/polls/Poll.kt | 9 +- .../MultilevelTextSourceFormatting.kt | 67 +----- .../types/MessageEntity/EntitiesTestText.kt | 20 +- .../MessageEntity/StringFormattingTests.kt | 2 +- .../MessageEntity/TextPartsCreatingTests.kt | 13 +- .../triggers_handling/CommandHandling.kt | 1 - .../utils/shortcuts/CommandsShortcuts.kt | 1 - 48 files changed, 203 insertions(+), 240 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4735d1aee..f418b93824 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Interface `Captioned` and `CaptionedInput` now is deprecated * Most of captions usages were replaced with texts * `textSources` become main field in `TextedInput` + * **MIGRATION** Remove all `import dev.inmo.tgbotapi.CommonAbstracts.textSources` in your project * `textEntities` become are calculable property in `TextedInput` ## 0.33.4 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt index 05e7cd1c63..71c1fa2633 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt @@ -17,15 +17,10 @@ interface EntitiesExplainedOutput : Explained { interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput interface ExplainedInput : Explained { + val textSources: TextSourcesList /** * Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] */ val explanationEntities: List + get() = textSources.toTextParts() } - -/** - * @see ExplainedInput.explanationEntities - * @see justTextSources - */ -val ExplainedInput.textSources - get() = explanationEntities.justTextSources() 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 05590f49b4..6a51ef9cca 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 @@ -2,7 +2,6 @@ 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.toTextParts import dev.inmo.tgbotapi.types.captionLength import dev.inmo.tgbotapi.types.textLength import kotlinx.serialization.Serializable @@ -44,14 +43,27 @@ interface MultilevelTextSource : TextSource { } } +@Deprecated("This class will be removed soon. Use TextSources instead") data class TextPart( val range: IntRange, val source: TextSource ) +@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 + } + } +} + fun List.makeString() = joinToString("") { it.source } -internal fun MultilevelTextSource.textParts(offset: Int): List = subsources.toTextParts(offset) fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null): List> { if (isEmpty()) { return emptyList() 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 1518631721..b9fedb0403 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,6 +1,5 @@ package dev.inmo.tgbotapi.CommonAbstracts -import dev.inmo.tgbotapi.types.MessageEntity.toTextParts import dev.inmo.tgbotapi.types.ParseMode.ParseMode interface Texted { @@ -20,8 +19,6 @@ interface TextedOutput : ParsableOutput, EntitiesOutput interface TextedInput : Texted { /** * Full list of [TextSource] built from source[TextedInput.textEntities] - * - * @see justTextSources */ val textSources: List /** 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 617970f108..57cbaaa355 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 @@ -59,7 +59,7 @@ data class EditChatMessageCaption internal constructor( override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage { override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + rawEntities ?.asTextSources(text) } override fun method(): String = editMessageCaptionMethod 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 20145b3939..80e024b7ce 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 @@ -48,7 +48,7 @@ data class EditInlineMessageCaption internal constructor( override val replyMarkup: InlineKeyboardMarkup? = null ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage { override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + rawEntities ?.asTextSources(text) } override fun method(): String = editMessageCaptionMethod 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 a0f37f90b3..af7e87a389 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 @@ -65,7 +65,7 @@ data class EditChatMessageText internal constructor( override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + rawEntities ?.asTextSources(text) } override fun method(): String = editMessageTextMethod 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 61c89f500d..c457f01e1e 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 @@ -54,7 +54,7 @@ data class EditInlineMessageText internal constructor( override val replyMarkup: InlineKeyboardMarkup? = null ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + rawEntities ?.asTextSources(text) } override fun method(): String = editMessageTextMethod 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 4ddbf8e68f..4f3c12297d 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 @@ -63,7 +63,7 @@ data class CopyMessage internal constructor( override val chatId: ChatIdentifier get() = fromChatId override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } override fun method(): String = "copyMessage" 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 c36219778c..c36f862686 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 @@ -84,7 +84,7 @@ data class SendTextMessage internal constructor( DisableWebPagePreview { override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + rawEntities ?.asTextSources(text) } init { 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 6a26483056..85a1dede9a 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 @@ -145,7 +145,7 @@ data class SendAnimationData internal constructor( SizedSendMessageRequest> { override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 c95d7e7f7c..e5cc73ba5e 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 @@ -146,7 +146,7 @@ data class SendAudioData internal constructor( Performerable { override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 8c7d0a9cc2..9e5c8e7add 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 @@ -158,7 +158,7 @@ data class SendDocumentData internal constructor( ThumbedSendMessageRequest> { override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 66d388ee91..9b03689e8b 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 @@ -101,7 +101,7 @@ data class SendPhotoData internal constructor( TextableSendMessageRequest> { override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 e50686c5dc..cc850aecc3 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 @@ -151,7 +151,7 @@ data class SendVideoData internal constructor( SizedSendMessageRequest> { override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 79b17c98e4..b6a37c7428 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 @@ -121,7 +121,7 @@ data class SendVoiceData internal constructor( DuratedSendMessageRequest> { override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 2af52017ef..ffe2a64c0c 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 @@ -360,7 +360,7 @@ data class SendQuizPoll internal constructor( override val requestSerializer: SerializationStrategy<*> get() = serializer() override val entities: List? by lazy { - rawEntities ?.asTextParts(explanation ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(explanation ?: return@lazy null) } init { 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 30f23487c8..2f556ff5cb 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 @@ -49,6 +49,6 @@ data class InlineQueryResultAudioCachedImpl internal constructor( ) : InlineQueryResultAudioCached { override val type: String = inlineQueryResultAudioType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 f4221fae20..6bc56236b1 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 @@ -60,6 +60,6 @@ data class InlineQueryResultAudioImpl internal constructor( ) : InlineQueryResultAudio { override val type: String = inlineQueryResultAudioType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 2b7bd33291..a15c0fd0a1 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 @@ -57,6 +57,6 @@ data class InlineQueryResultDocumentCachedImpl internal constructor( ) : InlineQueryResultDocumentCached { override val type: String = inlineQueryResultDocumentType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 bca7294ef3..b9e95a488a 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 @@ -74,6 +74,6 @@ data class InlineQueryResultDocumentImpl internal constructor( ) : InlineQueryResultDocument { override val type: String = inlineQueryResultDocumentType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 a65dd530ac..d12fdb5324 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 @@ -53,6 +53,6 @@ data class InlineQueryResultGifCachedImpl internal constructor( ) : InlineQueryResultGifCached { override val type: String = inlineQueryResultGifType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 d282045d62..b5417b68d0 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 @@ -73,7 +73,7 @@ data class InlineQueryResultGifImpl internal constructor( ) : InlineQueryResultGif { override val type: String = inlineQueryResultGifType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 d7726fa700..b4aa1a0ce9 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 @@ -53,6 +53,6 @@ data class InlineQueryResultMpeg4GifCachedImpl internal constructor( ) : InlineQueryResultMpeg4GifCached { override val type: String = inlineQueryResultMpeg4GifType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 9b07306447..272457cfc3 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 @@ -73,7 +73,7 @@ data class InlineQueryResultMpeg4GifImpl internal constructor( ) : InlineQueryResultMpeg4Gif { override val type: String = inlineQueryResultMpeg4GifType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 942fb9039a..3949c0930a 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 @@ -57,6 +57,6 @@ data class InlineQueryResultPhotoCachedImpl internal constructor( ) : InlineQueryResultPhotoCached { override val type: String = inlineQueryResultPhotoType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 332a2ce09c..6162842ac7 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 @@ -68,6 +68,6 @@ data class InlineQueryResultPhotoImpl internal constructor( ) : InlineQueryResultPhoto { override val type: String = inlineQueryResultPhotoType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 8fe16705c5..410ecbe845 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 @@ -57,6 +57,6 @@ data class InlineQueryResultVideoCachedImpl internal constructor( ) : InlineQueryResultVideoCached { override val type: String = inlineQueryResultVideoType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 e055c7f468..3c46f5a1e4 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 @@ -78,6 +78,6 @@ data class InlineQueryResultVideoImpl internal constructor( ) : InlineQueryResultVideo { override val type: String = inlineQueryResultVideoType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 e5e236120d..af0738d385 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 @@ -53,6 +53,6 @@ data class InlineQueryResultVoiceCachedImpl internal constructor( ) : InlineQueryResultVoiceCached { override val type: String = inlineQueryResultVoiceType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 02c4189ed8..f3a375978b 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 @@ -66,6 +66,6 @@ data class InlineQueryResultVoiceImpl internal constructor( ) : InlineQueryResultVoice { override val type: String = inlineQueryResultVoiceType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } } 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 5871b5a144..898cb84c77 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 @@ -39,6 +39,6 @@ data class InputTextMessageContent internal constructor( override val disableWebPagePreview: Boolean? = null ) : TextedOutput, DisableWebPagePreview, InputMessageContent { override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + rawEntities ?.asTextSources(text) } } \ 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 77eaec8b68..ea11be80bf 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 @@ -45,7 +45,7 @@ data class InputMediaAnimation internal constructor( ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput { override val type: String = "animation" override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } @SerialName(mediaField) 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 598e0ddc4a..0e78d9d244 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 @@ -51,7 +51,7 @@ data class InputMediaAudio internal constructor( ) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, Performerable { override val type: String = audioInputMediaType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) 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 6772614459..51457d81ed 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 @@ -51,7 +51,7 @@ data class InputMediaDocument internal constructor( ) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia { override val type: String = documentInputMediaType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) 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 b3d56b4574..1f0d0ca6f2 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 @@ -35,7 +35,7 @@ data class InputMediaPhoto internal constructor( ) : InputMedia, VisualMediaGroupMemberInputMedia { override val type: String = photoInputMediaType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) 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 f7907dd023..eece259c8f 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 @@ -46,7 +46,7 @@ data class InputMediaVideo internal constructor ( ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia { override val type: String = videoInputMediaType override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + rawEntities ?.asTextSources(text ?: return@lazy null) } override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) 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 d8bff5f11d..b0965a4543 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 @@ -3,8 +3,6 @@ package dev.inmo.tgbotapi.types.MessageEntity import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.User -import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource -import dev.inmo.tgbotapi.utils.internal.shiftSourcesToTheLeft import kotlinx.serialization.Serializable @Serializable @@ -15,70 +13,115 @@ internal data class RawMessageEntity( val url: String? = null, val user: User? = null, val language: String? = null -) - -internal fun RawMessageEntity.asTextParts( - source: String, - subParts: List -): List { - val sourceSubstring: String = source.substring(offset, offset + length) - val range = offset until (offset + length) - val shiftedSubSources = sourceSubstring.fullListOfSubSource(subParts.shiftSourcesToTheLeft(offset)).justTextSources() - return when (type) { - "mention" -> MentionTextSource(sourceSubstring, shiftedSubSources) - "hashtag" -> HashTagTextSource(sourceSubstring, shiftedSubSources) - "cashtag" -> CashTagTextSource(sourceSubstring, shiftedSubSources) - "bot_command" -> BotCommandTextSource(sourceSubstring) - "url" -> URLTextSource(sourceSubstring) - "email" -> EMailTextSource(sourceSubstring, shiftedSubSources) - "phone_number" -> PhoneNumberTextSource(sourceSubstring, shiftedSubSources) - "bold" -> BoldTextSource(sourceSubstring, shiftedSubSources) - "italic" -> ItalicTextSource(sourceSubstring, shiftedSubSources) - "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"), shiftedSubSources) - "underline" -> UnderlineTextSource(sourceSubstring, shiftedSubSources) - "strikethrough" -> StrikethroughTextSource(sourceSubstring, shiftedSubSources) - else -> RegularTextSource(sourceSubstring) - }.let { - val part = TextPart(range, it) - if (it !is MultilevelTextSource && subParts.isNotEmpty()) { - (subParts + part).sortedBy { currentPart -> currentPart.range.first } - } else { - listOf(part) - } +) { + internal val range by lazy { + offset until (offset + length) } } -internal fun createTextPart(originalFullString: String, entities: RawMessageEntities): List { - val mutableEntities = entities.toMutableList() - mutableEntities.sortBy { it.offset } - val resultList = mutableListOf() +internal fun RawMessageEntity.asTextSource( + source: String, + subParts: List +): TextSource { + val sourceSubstring: String = source.substring(range) + val subPartsWithRegulars by lazy { + subParts.fillWithRegulars(sourceSubstring) + } + return when (type) { + "mention" -> MentionTextSource(sourceSubstring, subPartsWithRegulars) + "hashtag" -> HashTagTextSource(sourceSubstring, subPartsWithRegulars) + "cashtag" -> CashTagTextSource(sourceSubstring, subPartsWithRegulars) + "bot_command" -> BotCommandTextSource(sourceSubstring) + "url" -> URLTextSource(sourceSubstring) + "email" -> EMailTextSource(sourceSubstring, subPartsWithRegulars) + "phone_number" -> PhoneNumberTextSource(sourceSubstring, subPartsWithRegulars) + "bold" -> BoldTextSource(sourceSubstring, subPartsWithRegulars) + "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) + "underline" -> UnderlineTextSource(sourceSubstring, subPartsWithRegulars) + "strikethrough" -> StrikethroughTextSource(sourceSubstring, subPartsWithRegulars) + else -> RegularTextSource(sourceSubstring) + } +} + +private inline operator fun > ClosedRange.contains(other: ClosedRange): Boolean { + return start <= other.start && endInclusive >= other.endInclusive +} + +internal fun List.fillWithRegulars(source: String): List { + var index = 0 + val result = mutableListOf() + for (i in 0 until size) { + val textSource = get(i) + val thisSourceInStart = source.startsWith(textSource.source, index) + if (!thisSourceInStart) { + val regularEndIndex = source.indexOf(textSource.source) + result.add(regular(source.substring(index, regularEndIndex))) + index = regularEndIndex + } + result.add(textSource) + index += textSource.source.length + } + + if (index != source.length) { + result.add(regular(source.substring(index, source.length))) + } + + return result +} + +private fun createTextSources(originalFullString: String, entities: RawMessageEntities): List { + val mutableEntities = entities.toMutableList().apply { sortBy { it.offset } } + val resultList = mutableListOf() while (mutableEntities.isNotEmpty()) { - val currentFirst = mutableEntities.removeAt(0) - val subEntities = if (mutableEntities.isNotEmpty()) { - val lastIndex = currentFirst.offset + currentFirst.length - val subEntities = mutableListOf() - while (mutableEntities.isNotEmpty()) { - val currentPossibleSubEntity = mutableEntities.first() - if (currentPossibleSubEntity.offset < lastIndex) { - subEntities.add(currentPossibleSubEntity) - mutableEntities.removeAt(0) - } else { - break + var parent = mutableEntities.removeFirst() + val subentities = mutableListOf() + val toAddCutted = mutableListOf() + while (mutableEntities.isNotEmpty()) { + val potentialParent = mutableEntities.first() + when { + potentialParent.range.first > parent.range.last -> break + potentialParent.range in parent.range -> { + subentities.add(potentialParent) + } + potentialParent.offset == parent.offset && potentialParent.length > parent.length -> { + subentities.add(parent) + parent = potentialParent + } + else -> { // need to cut + toAddCutted.add(potentialParent) } } - subEntities - } else { - emptyList() + mutableEntities.remove(potentialParent) } - - resultList.addAll( - currentFirst.asTextParts( + val subtextSources = if (subentities.isNotEmpty()) { + mutableEntities.removeAll(subentities) + if (toAddCutted.isNotEmpty()) { + val borderIndex = parent.range.last + 1 + mutableEntities.addAll( + 0, + toAddCutted.map { + val firstLength = borderIndex - it.offset + subentities.add(it.copy(length = firstLength)) + it.copy( + offset = borderIndex, + length = it.length - firstLength + ) + } + ) + } + createTextSources(originalFullString, subentities) + } else { + emptyList() + } + resultList.add( + parent.asTextSource( originalFullString, - createTextPart(originalFullString, subEntities) + subtextSources ) ) } @@ -86,46 +129,41 @@ internal fun createTextPart(originalFullString: String, entities: RawMessageEnti return resultList } -internal fun TextPart.asRawMessageEntities(): List { +internal fun TextSource.toRawMessageEntities(offset: Int = 0): List { val source = source - val length = range.last - range.first + 1 - + val length = source.length return listOfNotNull( - when (source) { - is MentionTextSource -> RawMessageEntity("mention", range.first, length) - is HashTagTextSource -> RawMessageEntity("hashtag", range.first, length) - is CashTagTextSource -> RawMessageEntity("cashtag", range.first, length) - is BotCommandTextSource -> RawMessageEntity("bot_command", range.first, length) - is URLTextSource -> RawMessageEntity("url", range.first, length) - is EMailTextSource -> RawMessageEntity("email", range.first, length) - is PhoneNumberTextSource -> RawMessageEntity("phone_number", range.first, length) - is BoldTextSource -> RawMessageEntity("bold", range.first, length) - is ItalicTextSource -> RawMessageEntity("italic", range.first, length) - is CodeTextSource -> RawMessageEntity("code", range.first, length) - is PreTextSource -> RawMessageEntity("pre", range.first, length, language = source.language) - is TextLinkTextSource -> RawMessageEntity("text_link", range.first, length, source.url) - is TextMentionTextSource -> RawMessageEntity("text_mention", range.first, length, user = source.user) - is UnderlineTextSource -> RawMessageEntity("underline", range.first, length) - is StrikethroughTextSource -> RawMessageEntity("strikethrough", range.first, length) + when (this) { + is MentionTextSource -> RawMessageEntity("mention", offset, length) + is HashTagTextSource -> RawMessageEntity("hashtag", offset, length) + is CashTagTextSource -> RawMessageEntity("cashtag", offset, length) + is BotCommandTextSource -> RawMessageEntity("bot_command", offset, length) + is URLTextSource -> RawMessageEntity("url", offset, length) + is EMailTextSource -> RawMessageEntity("email", offset, length) + is PhoneNumberTextSource -> RawMessageEntity("phone_number", offset, length) + is BoldTextSource -> RawMessageEntity("bold", offset, length) + is ItalicTextSource -> RawMessageEntity("italic", offset, length) + is CodeTextSource -> RawMessageEntity("code", offset, length) + is PreTextSource -> RawMessageEntity("pre", offset, length, language = language) + is TextLinkTextSource -> RawMessageEntity("text_link", offset, length, url) + is TextMentionTextSource -> RawMessageEntity("text_mention", offset, length, user = user) + is UnderlineTextSource -> RawMessageEntity("underline", offset, length) + is StrikethroughTextSource -> RawMessageEntity("strikethrough", offset, length) else -> null } - ) + if (source is MultilevelTextSource) { - source.textParts(range.first).asRawMessageEntities() + ) + if (this is MultilevelTextSource) { + subsources.toRawMessageEntities(offset) } else { emptyList() } } -internal fun List.asRawMessageEntities(): List = flatMap { it.asRawMessageEntities() } -internal fun List.toTextParts(preOffset: Int = 0): List { +internal fun List.toRawMessageEntities(preOffset: Int = 0): List { var i = preOffset - return map { - TextPart( - i until (i + it.source.length), - it - ).also { - i = it.range.last + 1 + return flatMap { + it.toRawMessageEntities(i).also { + i += it.maxByOrNull { it.length }!!.length + 1 } } } @@ -136,10 +174,8 @@ fun String.removeLeading(word: String) = if (startsWith(word)){ this } -internal fun List.toRawMessageEntities(): List = toTextParts().asRawMessageEntities() +internal fun List.toRawMessageEntities(): List = toRawMessageEntities(0) -internal fun RawMessageEntities.asTextParts(sourceString: String): List = sourceString.fullListOfSubSource( - createTextPart(sourceString, this) -) +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/TextSourceSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt index a9f76a93ad..8ca19d3419 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 @@ -2,14 +2,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.CommonAbstracts.justTextSources -import dev.inmo.tgbotapi.types.MessageEntity.* -import dev.inmo.tgbotapi.types.MessageEntity.RawMessageEntities -import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.* -import kotlinx.serialization.encoding.* private val baseSerializers: Map> = mapOf( "regular" to RegularTextSource.serializer(), diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt index cf2225cd3a..db398702e3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/RawGame.kt @@ -1,9 +1,8 @@ package dev.inmo.tgbotapi.types.games -import dev.inmo.tgbotapi.CommonAbstracts.justTextSources import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.RawMessageEntities -import dev.inmo.tgbotapi.types.MessageEntity.asTextParts +import dev.inmo.tgbotapi.types.MessageEntity.asTextSources import dev.inmo.tgbotapi.types.files.* import kotlinx.serialization.* @@ -29,7 +28,7 @@ internal data class RawGame( description, photo, text, - text ?.let { _ -> textEntities.asTextParts(text).justTextSources() } ?: emptyList(), + text ?.let { _ -> textEntities.asTextSources(text) } ?: emptyList(), animation ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 4c93700cd7..086b33b792 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -1,9 +1,8 @@ package dev.inmo.tgbotapi.types.message -import dev.inmo.tgbotapi.CommonAbstracts.justTextSources import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.RawMessageEntities -import dev.inmo.tgbotapi.types.MessageEntity.asTextParts +import dev.inmo.tgbotapi.types.MessageEntity.asTextSources import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.* import dev.inmo.tgbotapi.types.dice.Dice @@ -103,11 +102,11 @@ internal data class RawMessage( ) { private val content: MessageContent? by lazy { val adaptedCaptionEntities = caption ?.let { - (caption_entities ?: emptyList()).asTextParts(caption).justTextSources() + (caption_entities ?: emptyList()).asTextSources(caption) } ?: emptyList() when { - text != null -> TextContent(text, (entities ?: emptyList()).asTextParts(text).justTextSources()) + text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text)) audio != null -> AudioContent( audio, caption, 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 8ca845fcd0..a26300419f 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,8 +2,7 @@ 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.TextPart +import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.utils.nonstrictJsonFormat @@ -136,7 +135,7 @@ data class QuizPoll( */ val correctOptionId: Int? = null, override val explanation: String? = null, - override val explanationEntities: List = emptyList(), + override val textSources: List = emptyList(), override val isClosed: Boolean = false, override val isAnonymous: Boolean = false, override val scheduledCloseInfo: ScheduledCloseInfo? = null @@ -159,7 +158,7 @@ internal object PollSerializer : KSerializer { rawPoll.votesCount, rawPoll.correctOptionId, rawPoll.explanation, - rawPoll.explanation?.let { rawPoll.explanationEntities.asTextParts(it) } ?: emptyList(), + rawPoll.explanation?.let { rawPoll.explanationEntities.asTextSources(it) } ?: emptyList(), rawPoll.isClosed, rawPoll.isAnonymous, rawPoll.scheduledCloseInfo @@ -211,7 +210,7 @@ internal object PollSerializer : KSerializer { regularPollType, correctOptionId = value.correctOptionId, explanation = value.explanation, - explanationEntities = value.explanationEntities.asRawMessageEntities(), + explanationEntities = value.textSources.toRawMessageEntities(), openPeriod = (closeInfo as? ApproximateScheduledCloseInfo) ?.openDuration ?.seconds ?.toLong(), closeDate = (closeInfo as? ExactScheduledCloseInfo) ?.closeDateTime ?.unixMillisLong ?.div(1000L) ) 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 bac1e06c41..b36cc15ec2 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,77 +1,12 @@ package dev.inmo.tgbotapi.utils.internal import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.regular 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 -internal fun String.fullListOfSubSource(sourceList: List): List { - val sortedSourceList = sourceList.sortedBy { it.range.first }.toMutableList() - - var previousLastIndex = 0 - - val newSubSources = mutableListOf() - - while (sortedSourceList.isNotEmpty()) { - val topSource = sortedSourceList.removeAt(0) - if (topSource.range.first - previousLastIndex > 0) { - val range = previousLastIndex until topSource.range.first - newSubSources.add( - TextPart( - range, - RegularTextSource( - substring(range) - ) - ) - ) - } - newSubSources.add(topSource) - previousLastIndex = topSource.range.last + 1 - } - - if (length > previousLastIndex) { - val range = previousLastIndex until length - newSubSources.add( - TextPart( - range, - RegularTextSource( - substring(range) - ) - ) - ) - } - - return newSubSources -} - -internal fun List.shiftSourcesToTheLeft(shiftCount: Int = 1): List { - return mapNotNull { - val first = (it.range.first - shiftCount).let { firstCalculated -> - if (firstCalculated < 0) { - 0 - } else { - firstCalculated - } - } - val last = (it.range.last - shiftCount).let { lastCalculated -> - if (lastCalculated < 0) { - 0 - } else { - lastCalculated - } - } - it.copy(range = first .. last).let { newSubSource -> - if (newSubSource.range.isEmpty()) { - null - } else { - newSubSource - } - } - } -} - private fun List.joinSubSourcesMarkdownV2() = joinToString("") { it.markdownV2 } 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 b75814dcf1..08092c0350 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,6 @@ package dev.inmo.tgbotapi.types.MessageEntity -import dev.inmo.tgbotapi.CommonAbstracts.TextPart +import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import kotlin.test.assertTrue @@ -36,19 +36,19 @@ internal val testTextEntities = listOf( RawMessageEntity( "mention", 39, - 6 + 8 ) ) -fun List.testTextParts() { - assertTrue (first().source is RegularTextSource) - assertTrue (get(1).source is BoldTextSource) - assertTrue (get(2).source is RegularTextSource) - assertTrue (get(3).source is HashTagTextSource) - assertTrue (get(4).source is RegularTextSource) - assertTrue (get(5).source is MentionTextSource) +fun List.testTextSources() { + assertTrue (first() is RegularTextSource) + assertTrue (get(1) is BoldTextSource) + assertTrue (get(2) is RegularTextSource) + assertTrue (get(3) is HashTagTextSource) + assertTrue (get(4) is RegularTextSource) + assertTrue (get(5) is MentionTextSource) - val boldSource = get(1).source as BoldTextSource + val boldSource = get(1) as BoldTextSource assertTrue (boldSource.subsources.first() is ItalicTextSource) assertTrue (boldSource.subsources[1] is RegularTextSource) assertTrue (boldSource.subsources[2] is StrikethroughTextSource) 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 1ba73f4c7f..f7b15a854a 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 @@ -48,7 +48,7 @@ class StringFormattingTests { hashtag("tag") + " and " + mention("mention") - sources.toTextParts().testTextParts() + sources.testTextSources() assertEquals(formattedV2Text, sources.toMarkdownV2Texts().first()) assertEquals(formattedHtmlText, sources.toHtmlTexts().first()) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/TextPartsCreatingTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/TextPartsCreatingTests.kt index 14e0a82f2e..a4e3900028 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/TextPartsCreatingTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/TextPartsCreatingTests.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity -import dev.inmo.tgbotapi.CommonAbstracts.justTextSources import dev.inmo.tgbotapi.extensions.utils.formatting.toHtmlTexts import dev.inmo.tgbotapi.extensions.utils.formatting.toMarkdownV2Texts import kotlin.test.Test @@ -9,23 +8,23 @@ import kotlin.test.assertEquals class TextPartsCreatingTests { @Test fun testThatTextWithMultilevelPartsCorrectlyCreating() { - val textParts = testTextEntities.asTextParts(testText) - textParts.testTextParts() + val textSources = testTextEntities.asTextSources(testText) + textSources.testTextSources() assertEquals( formattedV2Text, - textParts.justTextSources().toMarkdownV2Texts().first() + textSources.toMarkdownV2Texts().first() ) } @Test fun testThatTextWithMultilevelPartsCorrectlyCreatingInHtml() { - val textParts = testTextEntities.asTextParts(testText) - textParts.testTextParts() + val textSources = testTextEntities.asTextSources(testText) + textSources.testTextSources() assertEquals( formattedHtmlText, - textParts.justTextSources().toHtmlTexts().first() + textSources.toHtmlTexts().first() ) } } diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt index 0946a99140..4b77abaf69 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling -import dev.inmo.tgbotapi.CommonAbstracts.textSources import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage 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 6df7887dea..749ae68aef 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,7 +1,6 @@ package dev.inmo.tgbotapi.extensions.utils.shortcuts import dev.inmo.tgbotapi.CommonAbstracts.TextSource -import dev.inmo.tgbotapi.CommonAbstracts.textSources import dev.inmo.tgbotapi.extensions.utils.onlyTextContentMessages import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource From 1f7450844f9b90f9d04886c33d1007f6dd129dc5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 28 Apr 2021 19:59:30 +0600 Subject: [PATCH 19/63] optimize imports --- CHANGELOG.md | 3 +++ .../kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt | 2 -- .../inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt | 3 ++- .../tgbotapi/requests/edit/caption/EditChatMessageCaption.kt | 3 ++- .../requests/edit/caption/EditInlineMessageCaption.kt | 3 ++- .../inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt | 3 ++- .../tgbotapi/requests/edit/text/EditInlineMessageText.kt | 3 ++- .../kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt | 3 ++- .../dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt | 3 ++- .../dev/inmo/tgbotapi/requests/send/media/SendDocument.kt | 3 ++- .../dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt | 3 ++- .../dev/inmo/tgbotapi/requests/send/media/SendVideo.kt | 3 ++- .../dev/inmo/tgbotapi/requests/send/media/SendVoice.kt | 3 ++- .../dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt | 2 +- .../InlineQueryResult/InlineQueryResultAudioCachedImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultAudioImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultDocumentCachedImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultDocumentImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultGifCachedImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultGifImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultMpeg4GifCachedImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultMpeg4GifImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultPhotoCachedImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultPhotoImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultVideoCachedImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultVideoImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultVoiceCachedImpl.kt | 3 ++- .../InlineQueryResult/InlineQueryResultVoiceImpl.kt | 3 ++- .../types/InlineQueries/query/LocationInlineQuery.kt | 1 - .../tgbotapi/types/InlineQueries/query/RawInlineQuery.kt | 3 ++- .../dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt | 3 ++- .../inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt | 3 ++- .../types/MessageEntity/textsources/BoldTextSource.kt | 1 - .../types/MessageEntity/textsources/TextSourceSerializer.kt | 2 +- .../types/message/ChatEvents/voice/VoiceChatScheduled.kt | 3 ++- .../dev/inmo/tgbotapi/types/message/content/TextContent.kt | 5 ++--- .../tgbotapi/types/message/content/media/AudioContent.kt | 2 +- .../tgbotapi/types/message/content/media/DocumentContent.kt | 3 ++- .../tgbotapi/types/message/content/media/PhotoContent.kt | 2 +- .../tgbotapi/types/message/content/media/VideoContent.kt | 2 +- .../commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt | 3 ++- .../utils/internal/MultilevelTextSourceFormatting.kt | 4 ++-- .../kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt | 3 --- .../extensions/api/edit/caption/EditChatMessageCaption.kt | 3 ++- .../extensions/api/passport/SetPassportDataErrors.kt | 3 ++- .../inmo/tgbotapi/extensions/behaviour_builder/Variants.kt | 3 ++- .../behaviour_builder/expectations/WaitChatMemberUpdated.kt | 3 --- .../triggers_handling/ChatMemberUpdatedTriggers.kt | 1 - .../behaviour_builder/triggers_handling/CommandHandling.kt | 5 +++-- .../tgbotapi/extensions/utils/ContentMessageConversations.kt | 1 - .../utils/extensions/TextCaptionBotCommandsParser.kt | 1 - .../kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt | 3 +-- 52 files changed, 84 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f418b93824..2f5508e7c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.34.0 +**UPDATE UP TO Telegram Bot API 5.2** +_**ALL OLD DEPRECATIONS WERE REMOVED**_ + * `Core`: * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor * New interface `CommonSendInvoiceData` has been added diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt index 7d5b10c30e..5993bb0d9d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt @@ -1,7 +1,5 @@ package dev.inmo.tgbotapi.CommonAbstracts -import dev.inmo.tgbotapi.types.ParseMode.ParseMode - const val CaptionDeprecation = "Captioned interface and others will be removed soon and not recommended to use" @Deprecated(CaptionDeprecation) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt index 557da34271..4c7e225ff7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.CommonAbstracts -import dev.inmo.tgbotapi.types.payments.abstracts.* +import dev.inmo.tgbotapi.types.payments.abstracts.Currencied +import dev.inmo.tgbotapi.types.payments.abstracts.Priced interface CommonSendInvoiceData : Titled, Currencied, Priced { val description: String 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 57cbaaa355..b750342de9 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,7 @@ package dev.inmo.tgbotapi.requests.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.* 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 80e024b7ce..a943ca29c7 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,7 @@ package dev.inmo.tgbotapi.requests.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* 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 af7e87a389..7899ab4cf6 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,7 @@ package dev.inmo.tgbotapi.requests.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.* 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 c457f01e1e..b0e106c48b 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,7 @@ package dev.inmo.tgbotapi.requests.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* 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 c36f862686..edef06eb39 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,7 @@ package dev.inmo.tgbotapi.requests.send -import dev.inmo.tgbotapi.CommonAbstracts.* +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.* import dev.inmo.tgbotapi.types.* 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 85a1dede9a..a6aa26b6e2 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,7 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* +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.* import dev.inmo.tgbotapi.requests.send.media.base.* 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 9e5c8e7add..99419eb578 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,7 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* +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.* import dev.inmo.tgbotapi.requests.send.media.base.* 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 9b03689e8b..9f6951d130 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,7 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* +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.* import dev.inmo.tgbotapi.requests.send.media.base.* 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 cc850aecc3..5cd1b1af66 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,7 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* +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.* import dev.inmo.tgbotapi.requests.send.media.base.* 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 b6a37c7428..d790671bf8 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,7 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* +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.* import dev.inmo.tgbotapi.requests.send.media.base.* diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt index f804fdf561..387382016b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt @@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializ import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.LabeledPricesSerializer -import dev.inmo.tgbotapi.types.payments.abstracts.* +import dev.inmo.tgbotapi.types.payments.abstracts.Currency import kotlinx.serialization.* private val invoiceMessageSerializer: DeserializationStrategy> 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 2f556ff5cb..b7b1c6edb9 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached 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 6bc56236b1..e494fe0ac3 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType 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 a15c0fd0a1..5ebe52dc37 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached 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 b9e95a488a..84e2741a20 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType 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 d12fdb5324..6112e64d79 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached 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 b5417b68d0..bf0055959f 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType 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 b4aa1a0ce9..7c39bb89a0 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached 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 272457cfc3..ed79e06450 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType 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 3949c0930a..34d2483f39 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached 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 6162842ac7..174d074178 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType 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 410ecbe845..f3680732d6 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached 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 3c46f5a1e4..7f1771248a 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType 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 af0738d385..1e723fd18b 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached 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 f3a375978b..f3f7018b03 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,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType 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 89ce364dbf..78200717bc 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 @@ -5,7 +5,6 @@ import dev.inmo.tgbotapi.types.InlineQueryIdentifier import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.chat.ChatType import dev.inmo.tgbotapi.types.location.Location -import kotlinx.serialization.Serializable data class LocationInlineQuery( override val id: InlineQueryIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/RawInlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/RawInlineQuery.kt index e660c71882..13808bbd40 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/RawInlineQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/RawInlineQuery.kt @@ -4,7 +4,8 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.ChatType import dev.inmo.tgbotapi.types.chat.ChatTypeSerializer import dev.inmo.tgbotapi.types.location.Location -import kotlinx.serialization.* +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable @Serializable internal data class RawInlineQuery( 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 eece259c8f..636807e803 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,7 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.* +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 import dev.inmo.tgbotapi.types.* 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 b0965a4543..67e388ca72 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,6 +1,7 @@ package dev.inmo.tgbotapi.types.MessageEntity -import dev.inmo.tgbotapi.CommonAbstracts.* +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 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 b577bc040f..1129a56e55 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 @@ -3,7 +3,6 @@ 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.SerialName import kotlinx.serialization.Serializable /** 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 8ca19d3419..2c650123dc 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 @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.micro_utils.serialization.typed_serializer.TypedSerializer import dev.inmo.tgbotapi.CommonAbstracts.TextSource -import kotlinx.serialization.* +import kotlinx.serialization.KSerializer private val baseSerializers: Map> = mapOf( "regular" to RegularTextSource.serializer(), diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt index 548eea8e92..8db852aecc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt @@ -1,7 +1,8 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.voice -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent +import dev.inmo.tgbotapi.types.startDateField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index d83ddd701b..67f08598ae 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -1,12 +1,11 @@ package dev.inmo.tgbotapi.types.message.content -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageIdentifier -import dev.inmo.tgbotapi.types.ParseMode.ParseMode -import dev.inmo.tgbotapi.types.ParseMode.defaultParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt index 83c17f8591..cb850e9598 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendAudio import dev.inmo.tgbotapi.types.ChatIdentifier diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt index 9c4f3a7581..aa8f4dba37 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendDocument import dev.inmo.tgbotapi.types.ChatIdentifier diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt index 707ebcf29c..11eea15039 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendPhoto import dev.inmo.tgbotapi.types.ChatIdentifier diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt index 717c5c01a1..e32b9ab412 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendVideo import dev.inmo.tgbotapi.types.ChatIdentifier 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 a26300419f..beea426283 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,7 +2,8 @@ package dev.inmo.tgbotapi.types.polls import com.soywiz.klock.DateTime import com.soywiz.klock.TimeSpan -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.ExplainedInput +import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.utils.nonstrictJsonFormat 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 b36cc15ec2..8ded23db22 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,7 +1,7 @@ package dev.inmo.tgbotapi.utils.internal -import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.regular +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 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 1dd7e893ef..3f1b2a4b16 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 @@ -4,10 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.TestsJsonFormat import dev.inmo.tgbotapi.extensions.utils.formatting.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourceSerializer -import kotlinx.serialization.PolymorphicSerializer import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.encodeToString import kotlin.test.Test import kotlin.test.assertEquals 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 f5b5fd554e..0c20ebb00c 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 @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.caption.EditChatMessageCaption import dev.inmo.tgbotapi.types.ChatIdentifier diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt index 5e19524a04..478f7fc993 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt @@ -2,7 +2,8 @@ package dev.inmo.tgbotapi.extensions.api.passport import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.SetPassportDataErrors -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.User +import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.message.PassportMessage import dev.inmo.tgbotapi.types.passport.PassportData import dev.inmo.tgbotapi.types.passport.PassportElementError diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt index 63ed115bef..457ec155f5 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt @@ -2,7 +2,8 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder import dev.inmo.micro_utils.coroutines.DeferredAction import dev.inmo.micro_utils.coroutines.invokeFirstOf -import kotlinx.coroutines.* +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.async suspend fun BehaviourContext.parallel( action: BehaviourContextReceiver diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt index ccdbd3051b..6157825208 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt @@ -1,10 +1,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate import dev.inmo.tgbotapi.requests.abstracts.Request -import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery -import dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery import dev.inmo.tgbotapi.types.ChatMemberUpdated import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.MyChatMemberUpdatedUpdate diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt index 66676f7c6e..2150b7649b 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt @@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow -import dev.inmo.tgbotapi.extensions.utils.asChatMemberUpdatedUpdate import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat import dev.inmo.tgbotapi.types.ChatMemberUpdated import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt index 4b77abaf69..4ab3479166 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt @@ -1,7 +1,8 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling -import dev.inmo.tgbotapi.extensions.behaviour_builder.* -import dev.inmo.tgbotapi.extensions.utils.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTypeReceiver +import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.TextContent import kotlinx.coroutines.Job diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt index 37841333c7..1866a5137e 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt @@ -7,7 +7,6 @@ import dev.inmo.tgbotapi.types.message.content.media.* import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.mapNotNull -import kotlin.reflect.KClass private inline fun Flow>.withContentType() = mapNotNull { it.withContent() 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 61eed8ef21..e1fac852e7 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 @@ -4,7 +4,6 @@ import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.TextContent -import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent val defaultArgsSeparator = Regex(" ") diff --git a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt b/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt index 2c70dd1c2b..507349899d 100644 --- a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt +++ b/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt @@ -1,9 +1,8 @@ package dev.inmo.tgbotapi.types.files import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper +import java.io.* import java.io.File -import java.io.FileOutputStream -import java.io.InputStream import java.net.URL fun PathedFile.asStream( From 0914710cc7931fa026a5fb300c4af65089d03e40 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 28 Apr 2021 20:08:02 +0600 Subject: [PATCH 20/63] update voice chats --- CHANGELOG.md | 1 + .../ChatEvents/abstracts/VoiceChatEvent.kt | 2 +- .../inmo/tgbotapi/extensions/utils/ClassCasts.kt | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f5508e7c5..4e1dece65c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ _**ALL OLD DEPRECATIONS WERE REMOVED**_ * `textSources` become main field in `TextedInput` * **MIGRATION** Remove all `import dev.inmo.tgbotapi.CommonAbstracts.textSources` in your project * `textEntities` become are calculable property in `TextedInput` + * Interface `VoiceChatEvent` now is `CommonEvent` ## 0.33.4 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt index 54bb629cde..289fc5daac 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt @@ -1,3 +1,3 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts -interface VoiceChatEvent : SupergroupEvent +interface VoiceChatEvent : CommonEvent 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 aa0e254bbe..9811b1ab8b 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 @@ -1,8 +1,8 @@ @file:Suppress("NOTHING_TO_INLINE", "unused", "UNCHECKED_CAST") package dev.inmo.tgbotapi.extensions.utils -import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource -import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.requests.send.payments.SendInvoice import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.CallbackQuery.* import dev.inmo.tgbotapi.types.ChatMember.* @@ -589,6 +589,10 @@ inline fun InputMessageContent.asInputVenueMessageContent(): InputVenueMessageCo @PreviewFeature inline fun InputMessageContent.requireInputVenueMessageContent(): InputVenueMessageContent = this as InputVenueMessageContent @PreviewFeature +inline fun InputMessageContent.asInputInvoiceMessageContent(): InputInvoiceMessageContent? = this as? InputInvoiceMessageContent +@PreviewFeature +inline fun InputMessageContent.requireInputInvoiceMessageContent(): InputInvoiceMessageContent = this as InputInvoiceMessageContent +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultArticle(): InlineQueryResultArticle? = this as? InlineQueryResultArticle @PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultArticle(): InlineQueryResultArticle = this as InlineQueryResultArticle @@ -1304,3 +1308,11 @@ inline fun ChatEvent.requireVoiceChatParticipantsInvited(): VoiceChatParticipant inline fun ChatEvent.asVoiceChatStarted(): VoiceChatStarted? = this as? VoiceChatStarted @PreviewFeature inline fun ChatEvent.requireVoiceChatStarted(): VoiceChatStarted = this as VoiceChatStarted +@PreviewFeature +inline fun CommonSendInvoiceData.asSendInvoice(): SendInvoice? = this as? SendInvoice +@PreviewFeature +inline fun CommonSendInvoiceData.requireVoiceChatParticipantsInvited(): SendInvoice = this as SendInvoice +@PreviewFeature +inline fun CommonSendInvoiceData.asInputInvoiceMessageContent(): InputInvoiceMessageContent? = this as? InputInvoiceMessageContent +@PreviewFeature +inline fun CommonSendInvoiceData.requireInputInvoiceMessageContent(): InputInvoiceMessageContent = this as InputInvoiceMessageContent From eb923a633802273b7317b79ae48702fec88a2135 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 28 Apr 2021 23:22:13 +0600 Subject: [PATCH 21/63] fixes --- .../inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 67e388ca72..4234bdd191 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 @@ -162,9 +162,9 @@ internal fun TextSource.toRawMessageEntities(offset: Int = 0): List.toRawMessageEntities(preOffset: Int = 0): List { var i = preOffset - return flatMap { - it.toRawMessageEntities(i).also { - i += it.maxByOrNull { it.length }!!.length + 1 + return flatMap { textSource -> + textSource.toRawMessageEntities(i).also { + i += it.maxByOrNull { it.length } ?.length ?: textSource.source.length } } } From f447be02dc7846f3ce307a6452072c607b72f10a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 01:18:07 +0600 Subject: [PATCH 22/63] Update InlineKeyboardMarkup.kt --- .../dev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup.kt index cc3e707e47..cd17bb80df 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup.kt @@ -21,7 +21,7 @@ data class InlineKeyboardMarkup( // first button is not PayInlineKeyboardButton val firstIsPaymentButton = keyboard.first().firstOrNull() is PayInlineKeyboardButton if (!firstIsPaymentButton) { - error("In case if PayInlineKeyboardButton included in keyboard - it must ") + error("In case if PayInlineKeyboardButton included in keyboard - it must be the first one") } } } From ab060d02ea597583871afb3c620ea71d8a1fa0e3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 11:52:38 +0600 Subject: [PATCH 23/63] deprecate Explained --- CHANGELOG.md | 15 ++++++++++----- .../inmo/tgbotapi/CommonAbstracts/Explained.kt | 18 +++++++++--------- .../inmo/tgbotapi/CommonAbstracts/Texted.kt | 16 ++++++++++------ .../edit/caption/EditChatMessageCaption.kt | 2 +- .../edit/caption/EditInlineMessageCaption.kt | 2 +- .../requests/edit/text/EditChatMessageText.kt | 2 +- .../edit/text/EditInlineMessageText.kt | 2 +- .../inmo/tgbotapi/requests/send/CopyMessage.kt | 2 +- .../inmo/tgbotapi/requests/send/SendMessage.kt | 2 +- .../requests/send/media/SendAnimation.kt | 2 +- .../tgbotapi/requests/send/media/SendAudio.kt | 2 +- .../requests/send/media/SendDocument.kt | 2 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 2 +- .../tgbotapi/requests/send/media/SendVideo.kt | 2 +- .../tgbotapi/requests/send/media/SendVoice.kt | 2 +- .../tgbotapi/requests/send/polls/SendPoll.kt | 12 ++++++------ .../InlineQueryResultAudioCachedImpl.kt | 2 +- .../InlineQueryResultAudioImpl.kt | 2 +- .../InlineQueryResultDocumentCachedImpl.kt | 2 +- .../InlineQueryResultDocumentImpl.kt | 2 +- .../InlineQueryResultGifCachedImpl.kt | 2 +- .../InlineQueryResultGifImpl.kt | 2 +- .../InlineQueryResultMpeg4GifCachedImpl.kt | 2 +- .../InlineQueryResultMpeg4GifImpl.kt | 2 +- .../InlineQueryResultPhotoCachedImpl.kt | 2 +- .../InlineQueryResultPhotoImpl.kt | 2 +- .../InlineQueryResultVideoCachedImpl.kt | 2 +- .../InlineQueryResultVideoImpl.kt | 2 +- .../InlineQueryResultVoiceCachedImpl.kt | 2 +- .../InlineQueryResultVoiceImpl.kt | 2 +- .../InputTextMessageContent.kt | 2 +- .../types/InputMedia/InputMediaAnimation.kt | 2 +- .../types/InputMedia/InputMediaAudio.kt | 2 +- .../types/InputMedia/InputMediaDocument.kt | 2 +- .../types/InputMedia/InputMediaPhoto.kt | 2 +- .../types/InputMedia/InputMediaVideo.kt | 2 +- .../textsources/TextSourceSerializer.kt | 7 +++++++ .../dev/inmo/tgbotapi/types/polls/Poll.kt | 4 ++-- .../extensions/TextCaptionBotCommandsParser.kt | 2 +- 39 files changed, 77 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e1dece65c..ff89bbdc11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,18 @@ _**ALL OLD DEPRECATIONS WERE REMOVED**_ * `Core`: * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor * New interface `CommonSendInvoiceData` has been added - * Fields `CommonSendInvoiceData#maxTipAmount` and `CommonSendInvoiceData#suggestedTipAmounts` have been added + * Fields `CommonSendInvoiceData#maxTipAmount` and `CommonSendInvoiceData#suggestedTipAmounts` have been added * New type `InputInvoiceMessageContent` has been added - * Interface `Captioned` and `CaptionedInput` now is deprecated + * New interface `TextedWithTextSources` on top of `Texted` interface + * Interface `TextedInput` now extends `TextedWithTextSources` with overriding of `textSources` field as not + nullable + * `textSources` become main field in `TextedInput` + * **MIGRATION** Remove all `import dev.inmo.tgbotapi.CommonAbstracts.textSources` in your project + * `textEntities` become are calculable property in `TextedInput` + * Interface `Captioned` and `CaptionedInput` now is deprecated + * Most of captions usages were replaced with texts + * Interface `Explained` and `ExplainedInput` now is deprecated * Most of captions usages were replaced with texts - * `textSources` become main field in `TextedInput` - * **MIGRATION** Remove all `import dev.inmo.tgbotapi.CommonAbstracts.textSources` in your project - * `textEntities` become are calculable property in `TextedInput` * Interface `VoiceChatEvent` now is `CommonEvent` ## 0.33.4 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt index 71c1fa2633..c5ccd4b90b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt @@ -1,21 +1,21 @@ package dev.inmo.tgbotapi.CommonAbstracts -import dev.inmo.tgbotapi.types.ParseMode.ParseMode - -interface Explained { +@Deprecated("Will be removed soon") +interface Explained : Texted { val explanation: String? + get() = text } -interface ParsableExplainedOutput : Explained { - val parseMode: ParseMode? -} +@Deprecated("Will be removed soon") +interface ParsableExplainedOutput : Explained, TextedOutput -interface EntitiesExplainedOutput : Explained { - val entities: List? -} +@Deprecated("Will be removed soon") +interface EntitiesExplainedOutput : Explained, EntitiesOutput +@Deprecated("Will be removed soon") interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput +@Deprecated("Will be removed soon") interface ExplainedInput : Explained { val textSources: TextSourcesList /** 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 b9fedb0403..0274b688cf 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 @@ -5,22 +5,26 @@ import dev.inmo.tgbotapi.types.ParseMode.ParseMode interface Texted { val text: String? } +interface TextedWithTextSources : Texted { + /** + * Full list of [TextSource] built from source[TextedInput.textEntities] + */ + val textSources: List? +} interface ParsableOutput : Texted { val parseMode: ParseMode? } -interface EntitiesOutput : Texted { +interface EntitiesOutput : TextedWithTextSources { val entities: List? + get() = textSources } interface TextedOutput : ParsableOutput, EntitiesOutput -interface TextedInput : Texted { - /** - * Full list of [TextSource] built from source[TextedInput.textEntities] - */ - val textSources: List +interface TextedInput : TextedWithTextSources { + override val textSources: List /** * Here must be full list of entities. This list must contains [TextPart]s with * [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of 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 b750342de9..5e08caeda3 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 @@ -59,7 +59,7 @@ data class EditChatMessageCaption internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage { - override val entities: 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 a943ca29c7..cf5a2c7d20 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 @@ -48,7 +48,7 @@ data class EditInlineMessageCaption internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage { - override val entities: 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 7899ab4cf6..a65d6de1a0 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 @@ -65,7 +65,7 @@ data class EditChatMessageText internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { - override val entities: 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 b0e106c48b..df537101fb 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 @@ -54,7 +54,7 @@ data class EditInlineMessageText internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { - override val entities: 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 4f3c12297d..877193c498 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 @@ -62,7 +62,7 @@ data class CopyMessage internal constructor( TextedOutput { override val chatId: ChatIdentifier get() = fromChatId - override val entities: 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/SendMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt index edef06eb39..e6b72d7a00 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 @@ -84,7 +84,7 @@ data class SendTextMessage internal constructor( TextableSendMessageRequest>, DisableWebPagePreview { - override val entities: 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 a6aa26b6e2..a464986417 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 @@ -145,7 +145,7 @@ data class SendAnimationData internal constructor( DuratedSendMessageRequest>, SizedSendMessageRequest> { - override val entities: 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 e5cc73ba5e..e18d8562fe 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 @@ -145,7 +145,7 @@ data class SendAudioData internal constructor( DuratedSendMessageRequest>, Performerable { - override val entities: 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/SendDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt index 99419eb578..9bee0c53df 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 @@ -158,7 +158,7 @@ data class SendDocumentData internal constructor( TextableSendMessageRequest>, ThumbedSendMessageRequest> { - override val entities: 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 9f6951d130..b0840dfc95 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 @@ -101,7 +101,7 @@ data class SendPhotoData internal constructor( ReplyingMarkupSendMessageRequest>, TextableSendMessageRequest> { - override val entities: 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 5cd1b1af66..8d4dcfcc71 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 @@ -151,7 +151,7 @@ data class SendVideoData internal constructor( DuratedSendMessageRequest>, SizedSendMessageRequest> { - override val entities: 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 d790671bf8..0e8c0b28ab 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 @@ -121,7 +121,7 @@ data class SendVoiceData internal constructor( TextableSendMessageRequest>, DuratedSendMessageRequest> { - override val entities: 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 ffe2a64c0c..844482379a 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 @@ -338,7 +338,7 @@ data class SendQuizPoll internal constructor( @SerialName(isClosedField) override val isClosed: Boolean = false, @SerialName(explanationField) - override val explanation: String? = null, + override val text: String? = null, @SerialName(explanationParseModeField) override val parseMode: ParseMode? = null, @SerialName(explanationEntitiesField) @@ -355,12 +355,12 @@ data class SendQuizPoll internal constructor( override val allowSendingWithoutReply: Boolean? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null -) : SendPoll(), ExplainedOutput { +) : SendPoll(), ExplainedOutput, TextedOutput { override val type: String = quizPollType override val requestSerializer: SerializationStrategy<*> get() = serializer() - override val entities: List? by lazy { - rawEntities ?.asTextSources(explanation ?: return@lazy null) + override val textSources: List? by lazy { + rawEntities ?.asTextSources(text ?: return@lazy null) } init { @@ -371,9 +371,9 @@ data class SendQuizPoll internal constructor( throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " + "value is $correctOptionId") } - if (explanation != null && explanation.length !in explanationLimit) { + if (text != null && text.length !in explanationLimit) { error("Quiz poll explanation size must be in range $explanationLimit," + - "but actual explanation contains ${explanation.length} symbols") + "but actual explanation contains ${text.length} symbols") } } } 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 b7b1c6edb9..c636fcc9f0 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 @@ -49,7 +49,7 @@ data class InlineQueryResultAudioCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultAudioCached { override val type: String = inlineQueryResultAudioType - override val entities: 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 e494fe0ac3..0139a0ec13 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 @@ -60,7 +60,7 @@ data class InlineQueryResultAudioImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultAudio { override val type: String = inlineQueryResultAudioType - override val entities: 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 5ebe52dc37..de9670b328 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 @@ -57,7 +57,7 @@ data class InlineQueryResultDocumentCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultDocumentCached { override val type: String = inlineQueryResultDocumentType - override val entities: 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 84e2741a20..ca5c132122 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 @@ -74,7 +74,7 @@ data class InlineQueryResultDocumentImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultDocument { override val type: String = inlineQueryResultDocumentType - override val entities: 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 6112e64d79..b177ef247d 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 @@ -53,7 +53,7 @@ data class InlineQueryResultGifCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultGifCached { override val type: String = inlineQueryResultGifType - override val entities: 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 bf0055959f..a09cf7c042 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 @@ -73,7 +73,7 @@ data class InlineQueryResultGifImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultGif { override val type: String = inlineQueryResultGifType - override val entities: 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 7c39bb89a0..ba4722d6fb 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 @@ -53,7 +53,7 @@ data class InlineQueryResultMpeg4GifCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultMpeg4GifCached { override val type: String = inlineQueryResultMpeg4GifType - override val entities: 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 ed79e06450..318a4299ce 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 @@ -73,7 +73,7 @@ data class InlineQueryResultMpeg4GifImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultMpeg4Gif { override val type: String = inlineQueryResultMpeg4GifType - override val entities: 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 34d2483f39..8946df450c 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 @@ -57,7 +57,7 @@ data class InlineQueryResultPhotoCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultPhotoCached { override val type: String = inlineQueryResultPhotoType - override val entities: 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 174d074178..e72a13ed81 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 @@ -68,7 +68,7 @@ data class InlineQueryResultPhotoImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultPhoto { override val type: String = inlineQueryResultPhotoType - override val entities: 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 f3680732d6..5211514940 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 @@ -57,7 +57,7 @@ data class InlineQueryResultVideoCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVideoCached { override val type: String = inlineQueryResultVideoType - override val entities: 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 7f1771248a..85c68034b8 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 @@ -78,7 +78,7 @@ data class InlineQueryResultVideoImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVideo { override val type: String = inlineQueryResultVideoType - override val entities: 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 1e723fd18b..1acbf64656 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 @@ -53,7 +53,7 @@ data class InlineQueryResultVoiceCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVoiceCached { override val type: String = inlineQueryResultVoiceType - override val entities: 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 f3f7018b03..dd6781faff 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 @@ -66,7 +66,7 @@ data class InlineQueryResultVoiceImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVoice { override val type: String = inlineQueryResultVoiceType - override val entities: 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/InputTextMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt index 898cb84c77..17b88fb49c 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 @@ -38,7 +38,7 @@ data class InputTextMessageContent internal constructor( @SerialName(disableWebPagePreviewField) override val disableWebPagePreview: Boolean? = null ) : TextedOutput, DisableWebPagePreview, InputMessageContent { - override val entities: List? by lazy { + 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/InputMedia/InputMediaAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt index ea11be80bf..bb65c3c173 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 @@ -44,7 +44,7 @@ data class InputMediaAnimation internal constructor( override val thumb: InputFile? = null ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput { override val type: String = "animation" - override val entities: 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/InputMediaAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt index 0e78d9d244..5b2ed4a6cb 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 @@ -50,7 +50,7 @@ data class InputMediaAudio internal constructor( override val thumb: InputFile? = null ) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, Performerable { override val type: String = audioInputMediaType - override val entities: 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/InputMediaDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt index 51457d81ed..c695ed1363 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 @@ -50,7 +50,7 @@ data class InputMediaDocument internal constructor( val disableContentTypeDetection: Boolean? = null ) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia { override val type: String = documentInputMediaType - override val entities: 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/InputMediaPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt index 1f0d0ca6f2..3bf3ff4ba7 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 @@ -34,7 +34,7 @@ data class InputMediaPhoto internal constructor( private val rawEntities: List? = null ) : InputMedia, VisualMediaGroupMemberInputMedia { override val type: String = photoInputMediaType - override val entities: 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/InputMediaVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt index 636807e803..f5512043c1 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 @@ -46,7 +46,7 @@ data class InputMediaVideo internal constructor ( override val thumb: InputFile? = null ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia { override val type: String = videoInputMediaType - override val entities: 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/MessageEntity/textsources/TextSourceSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt index 2c650123dc..719b51fe86 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 @@ -2,7 +2,13 @@ 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(), @@ -23,6 +29,7 @@ private val baseSerializers: Map> = mapOf( "cashtag" to CashTagTextSource.serializer(), ) +@Serializer(TextSource::class) object TextSourceSerializer : TypedSerializer(TextSource::class, baseSerializers) { override fun include(type: String, serializer: KSerializer) { require(type !in baseSerializers.keys) 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 beea426283..60dff15177 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 @@ -135,7 +135,7 @@ data class QuizPoll( * Nullable due to documentation (https://core.telegram.org/bots/api#poll) */ val correctOptionId: Int? = null, - override val explanation: String? = null, + override val text: String? = null, override val textSources: List = emptyList(), override val isClosed: Boolean = false, override val isAnonymous: Boolean = false, @@ -210,7 +210,7 @@ internal object PollSerializer : KSerializer { value.isAnonymous, regularPollType, correctOptionId = value.correctOptionId, - explanation = value.explanation, + explanation = value.text, explanationEntities = value.textSources.toRawMessageEntities(), openPeriod = (closeInfo as? ApproximateScheduledCloseInfo) ?.openDuration ?.seconds ?.toLong(), closeDate = (closeInfo as? ExactScheduledCloseInfo) ?.closeDateTime ?.unixMillisLong ?.div(1000L) 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 e1fac852e7..a895207729 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 @@ -47,7 +47,7 @@ fun TextedInput.parseCommandsWithParams( */ fun TextedOutput.parseCommandsWithParams( argsSeparator: Regex = defaultArgsSeparator -) = entities ?.parseCommandsWithParams(argsSeparator) ?: emptyMap() +) = textSources ?.parseCommandsWithParams(argsSeparator) ?: emptyMap() /** * Parse commands and their args. Logic will find command, get all subsequent data as args until new command From 03d4d715c00225ac90c34f21dd4904c43b4dd818 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 11:59:30 +0600 Subject: [PATCH 24/63] hotfix --- .../types/MessageEntity/textsources/TextSourceSerializer.kt | 1 - 1 file changed, 1 deletion(-) 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 719b51fe86..4af8f92fcd 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 @@ -29,7 +29,6 @@ private val baseSerializers: Map> = mapOf( "cashtag" to CashTagTextSource.serializer(), ) -@Serializer(TextSource::class) object TextSourceSerializer : TypedSerializer(TextSource::class, baseSerializers) { override fun include(type: String, serializer: KSerializer) { require(type !in baseSerializers.keys) From 1e41e953333d7eb4f9246d2a94381750cb877298 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 15:07:16 +0600 Subject: [PATCH 25/63] fixes in parseCommandsWithParams --- .../utils/extensions/TextCaptionBotCommandsParser.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 a895207729..1fbc3edeb0 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 @@ -18,10 +18,12 @@ fun List.parseCommandsWithParams( var currentArgs = "" fun includeCurrent() = currentBotCommandSource ?.let { currentArgs = currentArgs.trim() - if (currentArgs.isNotEmpty()) { - result[it.command] = currentArgs.split(argsSeparator).toTypedArray() - currentArgs = "" + result[it.command] = if (currentArgs.isNotEmpty()) { + currentArgs.split(argsSeparator).toTypedArray() + } else { + emptyArray() } + currentArgs = "" } for (textSource in this) { if (textSource is BotCommandTextSource) { From 44e7c80f43588a6a8038b2242cd4a567c16cd0ca Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 15:08:05 +0600 Subject: [PATCH 26/63] remove redundant extensions for parseCommandsWithParams --- .../extensions/TextCaptionBotCommandsParser.kt | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) 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 1fbc3edeb0..1b28ae2f9f 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 @@ -40,24 +40,10 @@ fun List.parseCommandsWithParams( /** * Parse commands and their args. Logic will find command, get all subsequent data as args until new command */ -fun TextedInput.parseCommandsWithParams( - argsSeparator: Regex = defaultArgsSeparator -) = textSources.parseCommandsWithParams(argsSeparator) - -/** - * Parse commands and their args. Logic will find command, get all subsequent data as args until new command - */ -fun TextedOutput.parseCommandsWithParams( +fun TextedWithTextSources.parseCommandsWithParams( argsSeparator: Regex = defaultArgsSeparator ) = textSources ?.parseCommandsWithParams(argsSeparator) ?: emptyMap() -/** - * Parse commands and their args. Logic will find command, get all subsequent data as args until new command - */ -fun CaptionedInput.parseCommandsWithParams( - argsSeparator: Regex = defaultArgsSeparator -) = textSources.parseCommandsWithParams(argsSeparator) - /** * Parse commands and their args. Logic will find command, get all subsequent data as args until new command */ From b6c7ece99552ee377a2ed55b5c9ef42718e0aa60 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 15:09:45 +0600 Subject: [PATCH 27/63] small hotfix --- .../extensions/utils/extensions/TextCaptionBotCommandsParser.kt | 1 + 1 file changed, 1 insertion(+) 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 1b28ae2f9f..8fa69aadad 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 @@ -24,6 +24,7 @@ fun List.parseCommandsWithParams( emptyArray() } currentArgs = "" + currentBotCommandSource = null } for (textSource in this) { if (textSource is BotCommandTextSource) { From c1372b55bcefca59546e2f800b054e9529b635b6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 15:26:08 +0600 Subject: [PATCH 28/63] Note about ChatType in CHANGRLOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff89bbdc11..a5978c635e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ _**ALL OLD DEPRECATIONS WERE REMOVED**_ * `Core`: + * Type `ChatType` has been added * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor * New interface `CommonSendInvoiceData` has been added * Fields `CommonSendInvoiceData#maxTipAmount` and `CommonSendInvoiceData#suggestedTipAmounts` have been added From d3c8b49b10fdc74b648f1a8fc9f2dee3890d4768 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 17:33:27 +0600 Subject: [PATCH 29/63] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5978c635e..35f0608c5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ _**ALL OLD DEPRECATIONS WERE REMOVED**_ * Interface `Explained` and `ExplainedInput` now is deprecated * Most of captions usages were replaced with texts * Interface `VoiceChatEvent` now is `CommonEvent` + * Mechanism of `RawMessageEntity` converting were fully rewritten ## 0.33.4 From 90df436c632edccb7fc2aee6b412e28523507970 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 17:39:10 +0600 Subject: [PATCH 30/63] small refactor of usage TextedInput --- .../extensions/api/edit/caption/EditChatMessageCaption.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 0c20ebb00c..9d28dc4288 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 @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.TextSource -import dev.inmo.tgbotapi.CommonAbstracts.TextedInput +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 @@ -35,7 +34,7 @@ suspend fun TelegramBot.editMessageCaption( text: String, parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null -): ContentMessage where T : TextedInput, T : MediaContent { +): ContentMessage where T : TextedWithTextSources, T : MediaContent { return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) } @@ -59,6 +58,6 @@ suspend fun TelegramBot.editMessageCaption( message: ContentMessage, entities: List, replyMarkup: InlineKeyboardMarkup? = null -): ContentMessage where T : TextedInput, T : MediaContent { +): ContentMessage where T : TextedWithTextSources, T : MediaContent { return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup) } From 63946e860d3a0ac2b18a021ead65c61b25e7fb8f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 17:45:19 +0600 Subject: [PATCH 31/63] note about UnknownExtendedChat --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35f0608c5e..db55b8a298 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ _**ALL OLD DEPRECATIONS WERE REMOVED**_ * `Core`: * Type `ChatType` has been added + * New `ExtendedChat` for unknown messages `UnknownExtendedChat` has been added * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor * New interface `CommonSendInvoiceData` has been added * Fields `CommonSendInvoiceData#maxTipAmount` and `CommonSendInvoiceData#suggestedTipAmounts` have been added From 2584839d66a344ca84b78a409fc6c0b550ecd928 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Apr 2021 19:02:51 +0600 Subject: [PATCH 32/63] update core readme --- tgbotapi.core/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tgbotapi.core/README.md b/tgbotapi.core/README.md index 4728898a5b..edb5912051 100644 --- a/tgbotapi.core/README.md +++ b/tgbotapi.core/README.md @@ -1,6 +1,5 @@ # TelegramBotAPI Core -[![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.core/images/download.svg) ](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) ## What is it? @@ -10,7 +9,7 @@ moments are describing by official [Telegram Bot API](https://core.telegram.org/ ## Compatibility -This version compatible with [9th of March 2021 update of TelegramBotAPI (version 5.1)](https://core.telegram.org/bots/api-changelog#march-9-2021). +This version compatible with [26th of April 2021 update of TelegramBotAPI (version 5.2)](https://core.telegram.org/bots/api-changelog#april-26-2021). ## How to implement library? From ed067db20fd28395c69788abc5f91cd3d2ac844d Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 29 Apr 2021 13:36:31 +0000 Subject: [PATCH 33/63] Update dependency org.jetbrains.dokka:gfm-plugin to v1.4.32 --- docs/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gradle.properties b/docs/gradle.properties index 21241f2d08..681b8537a1 100644 --- a/docs/gradle.properties +++ b/docs/gradle.properties @@ -1,3 +1,3 @@ -dokka_version=1.4.30 +dokka_version=1.4.32 org.gradle.jvmargs=-Xmx1024m From cabfd7c76b387094ab21733b768efbb2e04b0215 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 5 May 2021 18:53:26 +0600 Subject: [PATCH 34/63] start 0.34.1 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db55b8a298..04557fef4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.34.1 + ## 0.34.0 **UPDATE UP TO Telegram Bot API 5.2** diff --git a/gradle.properties b/gradle.properties index 5e93b2b6b2..f1c76092df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.35 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.34.0 +library_version=0.34.1 github_release_plugin_version=2.2.12 From 59d7a7c78126b4ea0015d6b4d7dc0e27c16dcfa3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 5 May 2021 19:02:22 +0600 Subject: [PATCH 35/63] fix in text sources list creating --- CHANGELOG.md | 3 +++ .../dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04557fef4e..0215dfaec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.34.1 +* `Core` + * Fix in creating of text sources list + ## 0.34.0 **UPDATE UP TO Telegram Bot API 5.2** 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 4234bdd191..c294fcbafb 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 @@ -59,7 +59,7 @@ internal fun List.fillWithRegulars(source: String): List val textSource = get(i) val thisSourceInStart = source.startsWith(textSource.source, index) if (!thisSourceInStart) { - val regularEndIndex = source.indexOf(textSource.source) + val regularEndIndex = source.indexOf(textSource.source, index) result.add(regular(source.substring(index, regularEndIndex))) index = regularEndIndex } From 12a64ec1d1553f7e8f120c614e64728b44826137 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 5 May 2021 19:12:59 +0600 Subject: [PATCH 36/63] update ktor --- CHANGELOG.md | 3 +++ gradle.properties | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0215dfaec7..057f4c8fdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.34.1 +* `Common`: + * `Version`: + * `ktor`: `1.5.3` -> `1.5.4` * `Core` * Fix in creating of text sources list diff --git a/gradle.properties b/gradle.properties index f1c76092df..b6bed663aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ kotlin_coroutines_version=1.4.3 kotlin_serialisation_runtime_version=1.1.0 klock_version=2.0.7 uuid_version=0.2.4 -ktor_version=1.5.3 +ktor_version=1.5.4 micro_utils_version=0.4.35 From ec1c0ba8bb1e2b7edd232d41fc20bb02ff0cf8f7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 5 May 2021 19:20:51 +0600 Subject: [PATCH 37/63] update microutils --- CHANGELOG.md | 1 + gradle.properties | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 057f4c8fdf..1473b49eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * `Common`: * `Version`: * `ktor`: `1.5.3` -> `1.5.4` + * `MicroUtils`: `0.4.35` -> `0.4.36` * `Core` * Fix in creating of text sources list diff --git a/gradle.properties b/gradle.properties index b6bed663aa..b666444203 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.0.7 uuid_version=0.2.4 ktor_version=1.5.4 -micro_utils_version=0.4.35 +micro_utils_version=0.4.36 javax_activation_version=1.1.1 From 0306c40fb20b3b8b710cd9d2b2bf4f583bda2721 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 6 May 2021 13:24:11 +0600 Subject: [PATCH 38/63] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1473b49eae..994542fe9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ## 0.34.0 +_**It is recommended to use [0.34.1](https://github.com/InsanusMokrassar/TelegramBotAPI/releases/tag/0.34.1) version due to the bug in 0.34.0 related to rewriting of `TextSource`s creating mechanism.**_ + **UPDATE UP TO Telegram Bot API 5.2** _**ALL OLD DEPRECATIONS WERE REMOVED**_ From 5c694e86259a33a9904f4f0c7cbf0cf608030177 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 6 May 2021 13:24:23 +0600 Subject: [PATCH 39/63] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 994542fe9e..87f80bef6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ _**It is recommended to use [0.34.1](https://github.com/InsanusMokrassar/TelegramBotAPI/releases/tag/0.34.1) version due to the bug in 0.34.0 related to rewriting of `TextSource`s creating mechanism.**_ **UPDATE UP TO Telegram Bot API 5.2** + _**ALL OLD DEPRECATIONS WERE REMOVED**_ * `Core`: From eaee334ff6928555707a25cc1ea7c83eeaeb1883 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 8 May 2021 16:44:14 +0600 Subject: [PATCH 40/63] Update gradle-wrapper.properties --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 68ca99ac45..8bf36eef6a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip From dcfcea65cb644f83aff7f3af8c8f3ba1d53831d6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 26 May 2021 21:51:29 +0600 Subject: [PATCH 41/63] start 0.35.0 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87f80bef6e..0e65bd3f24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.35.0 + ## 0.34.1 * `Common`: diff --git a/gradle.properties b/gradle.properties index b666444203..2971762128 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.36 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.34.1 +library_version=0.35.0 github_release_plugin_version=2.2.12 From 169fc0401a1238ba3a686114780eef701ac4b098 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 26 May 2021 21:55:09 +0600 Subject: [PATCH 42/63] update dependencies --- CHANGELOG.md | 9 +++++++++ gradle.properties | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e65bd3f24..55931ef633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## 0.35.0 +* `Common`: + * `Version`: + * `Kotlin`: `1.4.72` -> `1.5.0` + * `MicroUtils`: `0.4.36` -> `0.5.3` + * `Coroutines`: `1.4.3` -> `1.5.0` + * `Serialization`: `1.1.0` -> `1.2.1` + * `Klock`: `2.0.7` -> `2.1.0` + * `UUID`: `0.2.3` -> `0.3.0` + ## 0.34.1 * `Common`: diff --git a/gradle.properties b/gradle.properties index 2971762128..0afdb5ae15 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,14 +5,14 @@ kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true -kotlin_version=1.4.32 -kotlin_coroutines_version=1.4.3 -kotlin_serialisation_runtime_version=1.1.0 -klock_version=2.0.7 -uuid_version=0.2.4 +kotlin_version=1.5.10 +kotlin_coroutines_version=1.5.0 +kotlin_serialisation_runtime_version=1.2.1 +klock_version=2.1.0 +uuid_version=0.3.0 ktor_version=1.5.4 -micro_utils_version=0.4.36 +micro_utils_version=0.5.3 javax_activation_version=1.1.1 From 6acc9ef2b011d3d05e7c5603ebe5dd91c70265e0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 26 May 2021 22:00:57 +0600 Subject: [PATCH 43/63] update klock --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55931ef633..68a7722731 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ * `MicroUtils`: `0.4.36` -> `0.5.3` * `Coroutines`: `1.4.3` -> `1.5.0` * `Serialization`: `1.1.0` -> `1.2.1` - * `Klock`: `2.0.7` -> `2.1.0` + * `Klock`: `2.0.7` -> `2.1.2` * `UUID`: `0.2.3` -> `0.3.0` ## 0.34.1 diff --git a/gradle.properties b/gradle.properties index 0afdb5ae15..257a33b725 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ kotlin.incremental.js=true kotlin_version=1.5.10 kotlin_coroutines_version=1.5.0 kotlin_serialisation_runtime_version=1.2.1 -klock_version=2.1.0 +klock_version=2.1.2 uuid_version=0.3.0 ktor_version=1.5.4 From e5584cd8b4542b9432a3061def2c56d09b4de468 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 May 2021 00:04:11 +0600 Subject: [PATCH 44/63] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 257a33b725..01cb925144 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.1.2 uuid_version=0.3.0 ktor_version=1.5.4 -micro_utils_version=0.5.3 +micro_utils_version=0.5.4 javax_activation_version=1.1.1 From 07faba7d3856adb0d499cc61f645440629f38eb5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 May 2021 00:04:42 +0600 Subject: [PATCH 45/63] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68a7722731..bab3571a00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ * `Common`: * `Version`: * `Kotlin`: `1.4.72` -> `1.5.0` - * `MicroUtils`: `0.4.36` -> `0.5.3` + * `MicroUtils`: `0.4.36` -> `0.5.4` * `Coroutines`: `1.4.3` -> `1.5.0` * `Serialization`: `1.1.0` -> `1.2.1` * `Klock`: `2.0.7` -> `2.1.2` From 004ff0b49082dac504e145e008dcd70920bfc6be Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 13:29:01 +0600 Subject: [PATCH 46/63] update dependencies and changelog --- CHANGELOG.md | 5 +++-- gradle.properties | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bab3571a00..1159bd916f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,13 @@ * `Common`: * `Version`: - * `Kotlin`: `1.4.72` -> `1.5.0` - * `MicroUtils`: `0.4.36` -> `0.5.4` + * `Kotlin`: `1.4.72` -> `1.5.10` + * `MicroUtils`: `0.4.36` -> `0.5.5` * `Coroutines`: `1.4.3` -> `1.5.0` * `Serialization`: `1.1.0` -> `1.2.1` * `Klock`: `2.0.7` -> `2.1.2` * `UUID`: `0.2.3` -> `0.3.0` + * `Ktor`: `1.5.4` -> `1.6.0` ## 0.34.1 diff --git a/gradle.properties b/gradle.properties index 01cb925144..4264d5b0b6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,9 +10,9 @@ kotlin_coroutines_version=1.5.0 kotlin_serialisation_runtime_version=1.2.1 klock_version=2.1.2 uuid_version=0.3.0 -ktor_version=1.5.4 +ktor_version=1.6.0 -micro_utils_version=0.5.4 +micro_utils_version=0.5.5 javax_activation_version=1.1.1 From e90e25ab01e0901fe2c3eadd39576187149b10b2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 13:39:43 +0600 Subject: [PATCH 47/63] BotAction now is an interface --- .../inmo/tgbotapi/types/actions/BotAction.kt | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt index ea15453612..b8556f5d75 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt @@ -1,6 +1,8 @@ package dev.inmo.tgbotapi.types.actions import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer +import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -8,12 +10,14 @@ import kotlinx.serialization.encoding.Encoder * Use BotAction objects realisations to notify user about bot actions */ @Serializable(BotActionSerializer::class) -sealed class BotAction { - abstract val actionName: String +sealed interface BotAction { + val actionName: String } @Serializer(BotAction::class) internal object BotActionSerializer: KSerializer { + override val descriptor: SerialDescriptor = String.serializer().descriptor + override fun serialize(encoder: Encoder, value: BotAction) { encoder.encodeString(value.actionName) } @@ -41,7 +45,7 @@ internal object BotActionSerializer: KSerializer { * Will notify user that bot is "typing" something */ @Serializable(BotActionSerializer::class) -object TypingAction : BotAction() { +object TypingAction : BotAction { override val actionName: String = "typing" } inline val typing @@ -52,7 +56,7 @@ inline fun BotAction.asTyping() = this as? TypingAction * Will notify user that bot is uploading some photo */ @Serializable(BotActionSerializer::class) -object UploadPhotoAction : BotAction() { +object UploadPhotoAction : BotAction { override val actionName: String = "upload_photo" } inline val uploadPhoto @@ -63,7 +67,7 @@ inline fun BotAction.asUploadPhoto() = this as? UploadPhotoAction * Will notify user that bot is recording some video */ @Serializable(BotActionSerializer::class) -object RecordVideoAction : BotAction() { +object RecordVideoAction : BotAction { override val actionName: String = "record_video" } inline val recordVideo @@ -74,7 +78,7 @@ inline fun BotAction.asRecordVideo() = this as? RecordVideoAction * Will notify user that bot is uploading some photo */ @Serializable(BotActionSerializer::class) -object UploadVideoAction : BotAction() { +object UploadVideoAction : BotAction { override val actionName: String = "upload_video" } inline val uploadVideo @@ -89,7 +93,7 @@ inline fun BotAction.asUploadVideo() = this as? UploadVideoAction "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", ReplaceWith("RecordVoiceAction", "dev.inmo.tgbotapi.types.actions.RecordVoiceAction") ) -object RecordAudioAction : BotAction() { +object RecordAudioAction : BotAction { override val actionName: String = "record_audio" } @Deprecated( @@ -112,7 +116,7 @@ inline fun BotAction.asRecordAudio() = this as? RecordAudioAction "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", ReplaceWith("UploadVoiceAction", "dev.inmo.tgbotapi.types.actions.UploadVoiceAction") ) -object UploadAudioAction : BotAction() { +object UploadAudioAction : BotAction { override val actionName: String = "upload_audio" } @Deprecated( @@ -131,7 +135,7 @@ inline fun BotAction.asUploadAudio() = this as? UploadAudioAction * Will notify user that bot is recording some audio */ @Serializable(BotActionSerializer::class) -object RecordVoiceAction : BotAction() { +object RecordVoiceAction : BotAction { override val actionName: String = "record_voice" } inline val recordVoice @@ -142,7 +146,7 @@ inline fun BotAction.asRecordVoice() = this as? RecordVoiceAction * Will notify user that bot is uploading some audio */ @Serializable(BotActionSerializer::class) -object UploadVoiceAction : BotAction() { +object UploadVoiceAction : BotAction { override val actionName: String = "upload_voice" } inline val uploadVoice @@ -153,7 +157,7 @@ inline fun BotAction.asUploadVoice() = this as? UploadVoiceAction * Will notify user that bot is uploading some document */ @Serializable(BotActionSerializer::class) -object UploadDocumentAction : BotAction() { +object UploadDocumentAction : BotAction { override val actionName: String = "upload_document" } inline val uploadDocument @@ -164,7 +168,7 @@ inline fun BotAction.asUploadDocument() = this as? UploadDocumentAction * Will notify user that bot is trying to find location */ @Serializable(BotActionSerializer::class) -object FindLocationAction : BotAction() { +object FindLocationAction : BotAction { override val actionName: String = "find_location" } inline val findLocation @@ -175,7 +179,7 @@ inline fun BotAction.asFindLocation() = this as? FindLocationAction * Will notify user that bot is recording video note */ @Serializable(BotActionSerializer::class) -object RecordVideoNoteAction : BotAction() { +object RecordVideoNoteAction : BotAction { override val actionName: String = "record_video_note" } inline val recordVideoNote @@ -186,7 +190,7 @@ inline fun BotAction.asRecordVideoNote() = this as? RecordVideoNoteAction * Will notify user that bot is uploading video note */ @Serializable(BotActionSerializer::class) -object UploadVideoNoteAction : BotAction() { +object UploadVideoNoteAction : BotAction { override val actionName: String = "upload_video_note" } inline val uploadVideoNote From 12184cd2be8f5aabea1e4ac3d03aa05986b880f2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 13:40:48 +0600 Subject: [PATCH 48/63] InlineKeyboardButton now is an interface --- .../InlineKeyboardButton.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt index 4940bba946..19f79faf4d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt @@ -7,22 +7,22 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonElement @Serializable(InlineKeyboardButtonSerializer::class) -sealed class InlineKeyboardButton { - abstract val text: String +sealed interface InlineKeyboardButton { + val text: String } @Serializable data class UnknownInlineKeyboardButton internal constructor( override val text: String, val rawData: JsonElement -) : InlineKeyboardButton() +) : InlineKeyboardButton @Serializable data class PayInlineKeyboardButton( override val text: String, @SerialName(payField) val pay: Boolean -) : InlineKeyboardButton() +) : InlineKeyboardButton @Serializable data class CallbackDataInlineKeyboardButton( @@ -30,13 +30,13 @@ data class CallbackDataInlineKeyboardButton( override val text: String, @SerialName(callbackDataField) val callbackData: String -) : InlineKeyboardButton() +) : InlineKeyboardButton @Serializable data class CallbackGameInlineKeyboardButton( @SerialName(textField) override val text: String -) : InlineKeyboardButton() { +) : InlineKeyboardButton { @SerialName(callbackGameField) private val callbackGame = CallbackGame } @@ -46,25 +46,25 @@ data class LoginURLInlineKeyboardButton( override val text: String, @SerialName(loginUrlField) val loginUrl: LoginURL -) : InlineKeyboardButton() +) : InlineKeyboardButton @Serializable data class SwitchInlineQueryCurrentChatInlineKeyboardButton( override val text: String, @SerialName(switchInlineQueryCurrentChatField) val switchInlineQueryCurrentChat: String -) : InlineKeyboardButton() +) : InlineKeyboardButton @Serializable data class SwitchInlineQueryInlineKeyboardButton( override val text: String, @SerialName(switchInlineQueryField) val switchInlineQuery: String -) : InlineKeyboardButton() +) : InlineKeyboardButton @Serializable data class URLInlineKeyboardButton( override val text: String, @SerialName(urlField) val url: String -) : InlineKeyboardButton() +) : InlineKeyboardButton From 7825ec30101f74fcabed8e7565440367ef84d5ec Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 14:23:25 +0600 Subject: [PATCH 49/63] a lot of types has been converted to sealed --- CHANGELOG.md | 2 + .../tgbotapi/CommonAbstracts/TextSource.kt | 141 +++++++----------- .../inmo/tgbotapi/CommonAbstracts/Texted.kt | 5 +- .../edit/caption/EditChatMessageCaption.kt | 5 +- .../edit/caption/EditInlineMessageCaption.kt | 5 +- .../requests/edit/text/EditChatMessageText.kt | 5 +- .../edit/text/EditInlineMessageText.kt | 5 +- .../tgbotapi/requests/send/CopyMessage.kt | 3 +- .../tgbotapi/requests/send/SendMessage.kt | 5 +- .../requests/send/media/SendAnimation.kt | 5 +- .../tgbotapi/requests/send/media/SendAudio.kt | 3 +- .../requests/send/media/SendDocument.kt | 5 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 5 +- .../tgbotapi/requests/send/media/SendVideo.kt | 5 +- .../tgbotapi/requests/send/media/SendVoice.kt | 5 +- .../tgbotapi/requests/send/polls/SendPoll.kt | 3 +- .../types/CallbackQuery/CallbackQuery.kt | 2 +- .../types/CallbackQuery/DataCallbackQuery.kt | 2 +- .../GameShortNameCallbackQuery.kt | 2 +- .../InlineMessageIdCallbackQuery.kt | 4 +- .../CallbackQuery/MessageCallbackQuery.kt | 4 +- .../types/ChatMember/LeftChatMember.kt | 12 -- .../types/ChatMember/LeftChatMemberImpl.kt | 16 ++ .../types/ChatMember/MemberChatMember.kt | 12 -- .../types/ChatMember/MemberChatMemberImpl.kt | 16 ++ .../types/ChatMember/abstracts/ChatMember.kt | 2 +- .../ChatMember/abstracts/LeftChatMember.kt | 3 + .../ChatMember/abstracts/MemberChatMember.kt | 3 + .../InlineQueryResultAudioCachedImpl.kt | 5 +- .../InlineQueryResultAudioImpl.kt | 5 +- .../InlineQueryResultDocumentCachedImpl.kt | 5 +- .../InlineQueryResultDocumentImpl.kt | 5 +- .../InlineQueryResultGifCachedImpl.kt | 5 +- .../InlineQueryResultGifImpl.kt | 5 +- .../InlineQueryResultMpeg4GifCachedImpl.kt | 5 +- .../InlineQueryResultMpeg4GifImpl.kt | 5 +- .../InlineQueryResultPhotoCachedImpl.kt | 7 +- .../InlineQueryResultPhotoImpl.kt | 5 +- .../InlineQueryResultVideoCachedImpl.kt | 5 +- .../InlineQueryResultVideoImpl.kt | 5 +- .../InlineQueryResultVoiceCachedImpl.kt | 5 +- .../InlineQueryResultVoiceImpl.kt | 5 +- .../InputContactMessageContent.kt | 3 +- .../InputInvoiceMessageContent.kt | 1 - .../InputLocationMessageContent.kt | 3 +- .../InputMessageContent.kt | 7 + .../InputTextMessageContent.kt | 6 +- .../InputVenueMessageContent.kt | 1 - .../InlineQueries/abstracts/InlineQuery.kt | 10 +- .../abstracts/InputMessageContent.kt | 5 +- .../InlineQueries/query/BaseInlineQuery.kt | 1 - .../types/InlineQueries/query/InlineQuery.kt | 13 ++ .../query/LocationInlineQuery.kt | 1 - .../types/InputMedia/DuratedInputMedia.kt | 4 +- .../tgbotapi/types/InputMedia/InputMedia.kt | 4 +- .../types/InputMedia/InputMediaAnimation.kt | 3 +- .../types/InputMedia/InputMediaAudio.kt | 3 +- .../types/InputMedia/InputMediaDocument.kt | 3 +- .../types/InputMedia/InputMediaPhoto.kt | 3 +- .../types/InputMedia/InputMediaVideo.kt | 5 +- .../InputMedia/MediaGroupMemberInputMedia.kt | 8 +- .../types/InputMedia/SizedInputMedia.kt | 4 +- .../types/InputMedia/ThumbedInputMedia.kt | 2 +- .../types/InputMedia/TitledInputMedia.kt | 2 +- .../types/MessageEntity/RawMessageEntity.kt | 40 +++-- .../textsources/BoldTextSource.kt | 1 - .../textsources/BotCommandTextSource.kt | 1 - .../textsources/CashTagTextSource.kt | 1 - .../textsources/CodeTextSource.kt | 1 - .../textsources/EMailTextSource.kt | 1 - .../textsources/HashTagTextSource.kt | 1 - .../textsources/ItalicTextSource.kt | 1 - .../textsources/MentionTextSource.kt | 1 - .../textsources/PhoneNumberTextSource.kt | 1 - .../textsources/PreTextSource.kt | 1 - .../textsources/RegularTextSource.kt | 1 - .../textsources/StrikethroughTextSource.kt | 3 +- .../textsources/TextLinkTextSource.kt | 1 - .../textsources/TextMentionTextSource.kt | 1 - .../MessageEntity/textsources/TextSource.kt | 88 +++++++++++ .../textsources/TextSourceSerializer.kt | 7 - .../textsources/URLTextSource.kt | 1 - .../textsources/UnderlineTextSource.kt | 3 +- .../tgbotapi/types/ParseMode/ParseMode.kt | 13 +- .../inmo/tgbotapi/types/buttons/ForceReply.kt | 12 -- .../tgbotapi/types/buttons/KeyboardButton.kt | 22 +-- .../types/buttons/KeyboardButtonPollType.kt | 20 +-- .../tgbotapi/types/buttons/KeyboardMarkup.kt | 2 +- .../types/buttons/KeyboardMarkupSerializer.kt | 2 +- .../inmo/tgbotapi/types/buttons/ReplyForce.kt | 21 +++ .../types/buttons/ReplyKeyboardRemove.kt | 4 +- .../tgbotapi/types/dice/DiceAnimationType.kt | 20 +-- .../inmo/tgbotapi/types/location/Location.kt | 11 +- .../dev/inmo/tgbotapi/types/polls/Poll.kt | 36 ++--- .../MultilevelTextSourceFormatting.kt | 5 +- .../types/MessageEntity/EntitiesTestText.kt | 3 +- .../MessageEntity/StringFormattingTests.kt | 3 +- .../inmo/tgbotapi/types/TextSourcesTests.kt | 3 +- .../edit/caption/EditChatMessageCaption.kt | 5 +- .../edit/caption/EditInlineMessageCaption.kt | 3 +- .../api/edit/text/EditChatMessageText.kt | 9 +- .../api/edit/text/EditInlineMessageText.kt | 3 +- .../extensions/api/send/CopyMessage.kt | 13 +- .../extensions/api/send/SendMessage.kt | 11 +- .../api/send/media/SendAnimation.kt | 15 +- .../extensions/api/send/media/SendAudio.kt | 15 +- .../extensions/api/send/media/SendDocument.kt | 15 +- .../extensions/api/send/media/SendPhoto.kt | 15 +- .../extensions/api/send/media/SendVideo.kt | 15 +- .../extensions/api/send/media/SendVoice.kt | 15 +- .../extensions/api/send/polls/SendPoll.kt | 13 +- .../tgbotapi/extensions/utils/ClassCasts.kt | 4 +- .../TextCaptionBotCommandsParser.kt | 1 + .../utils/formatting/EntitiesBuilder.kt | 62 ++++---- .../utils/shortcuts/CommandsShortcuts.kt | 1 - .../utils/updates/CommandsFilters.kt | 3 +- 116 files changed, 531 insertions(+), 468 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMember.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMember.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/LeftChatMember.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/MemberChatMember.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputMessageContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ForceReply.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt 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) From fe1831fc1967ddd1553849524f1653f25fe510c9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 14:31:44 +0600 Subject: [PATCH 50/63] deprecations removed --- CHANGELOG.md | 2 + .../tgbotapi/CommonAbstracts/Captioned.kt | 20 -------- .../tgbotapi/CommonAbstracts/Explained.kt | 26 ---------- .../tgbotapi/CommonAbstracts/TextSource.kt | 2 +- .../tgbotapi/requests/send/polls/SendPoll.kt | 2 +- .../types/ChatMember/LeftChatMemberImpl.kt | 1 - .../InlineQueries/abstracts/InlineQuery.kt | 3 -- .../abstracts/InputMessageContent.kt | 2 - .../inmo/tgbotapi/types/actions/BotAction.kt | 48 ------------------- .../inmo/tgbotapi/types/files/VideoFile.kt | 1 - .../dev/inmo/tgbotapi/types/games/Game.kt | 3 +- .../types/message/content/TextContent.kt | 1 - .../content/abstracts/MediaGroupContent.kt | 2 +- .../message/content/media/AnimationContent.kt | 3 +- .../message/content/media/AudioContent.kt | 1 - .../message/content/media/DocumentContent.kt | 2 +- .../message/content/media/PhotoContent.kt | 2 +- .../message/content/media/VideoContent.kt | 2 +- .../message/content/media/VoiceContent.kt | 3 +- .../dev/inmo/tgbotapi/types/BotActionTests.kt | 4 -- .../extensions/api/send/SendAction.kt | 32 ------------- .../extensions/api/send/SendActionDSL.kt | 20 -------- .../tgbotapi/extensions/utils/ClassCasts.kt | 11 ++--- .../formatting/ResendingTextFormatting.kt | 9 ++++ 24 files changed, 26 insertions(+), 176 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index e9d7db5c17..5f23548960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.35.0 +**ALL PREVIOUS DEPRECATIONS HAVE BEEN REMOVED** + * `Common`: * `Version`: * `Kotlin`: `1.4.72` -> `1.5.10` diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt deleted file mode 100644 index 5993bb0d9d..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt +++ /dev/null @@ -1,20 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -const val CaptionDeprecation = "Captioned interface and others will be removed soon and not recommended to use" - -@Deprecated(CaptionDeprecation) -interface Captioned : Texted { - @Deprecated(CaptionDeprecation) - val caption: String? - get() = text -} - -@Deprecated(CaptionDeprecation) -interface CaptionedInput : Captioned, TextedInput { - /** - * Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - */ - @Deprecated(CaptionDeprecation) - val captionEntities: List - get() = textEntities -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt deleted file mode 100644 index c5ccd4b90b..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt +++ /dev/null @@ -1,26 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Will be removed soon") -interface Explained : Texted { - val explanation: String? - get() = text -} - -@Deprecated("Will be removed soon") -interface ParsableExplainedOutput : Explained, TextedOutput - -@Deprecated("Will be removed soon") -interface EntitiesExplainedOutput : Explained, EntitiesOutput - -@Deprecated("Will be removed soon") -interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput - -@Deprecated("Will be removed soon") -interface ExplainedInput : Explained { - val textSources: TextSourcesList - /** - * Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - */ - val explanationEntities: List - get() = textSources.toTextParts() -} 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 d22fbb4942..e91b6ff18c 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 @@ -66,7 +66,7 @@ fun List.separateF "Replaced", ReplaceWith("separateForCaption", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForCaption") ) -fun List.separateForCaption() = separateForCaption() +fun List.separateForCaption() = separateForCaption() /** * This method will prepare [TextSource]s list for messages with [textLength] 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 47f74c9f36..ea65c9eda9 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 @@ -356,7 +356,7 @@ data class SendQuizPoll internal constructor( override val allowSendingWithoutReply: Boolean? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null -) : SendPoll(), ExplainedOutput, TextedOutput { +) : SendPoll(), TextedOutput { override val type: String = quizPollType override val requestSerializer: SerializationStrategy<*> get() = serializer() 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 index 471d7347c0..50990b860c 100644 --- 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 @@ -1,7 +1,6 @@ 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.* 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 3b1bcdb3d3..8d73477fa8 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,9 +1,6 @@ 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 @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 fc790070f4..e3fb5789b0 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,8 +1,6 @@ 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 @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/actions/BotAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt index b8556f5d75..9df136fb8f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt @@ -28,8 +28,6 @@ internal object BotActionSerializer: KSerializer { UploadPhotoAction.actionName -> UploadPhotoAction RecordVideoAction.actionName -> RecordVideoAction UploadVideoAction.actionName -> UploadVideoAction - RecordAudioAction.actionName -> RecordAudioAction - UploadAudioAction.actionName -> UploadAudioAction RecordVoiceAction.actionName -> RecordVoiceAction UploadVoiceAction.actionName -> UploadVoiceAction UploadDocumentAction.actionName -> UploadDocumentAction @@ -85,52 +83,6 @@ inline val uploadVideo get() = UploadVideoAction inline fun BotAction.asUploadVideo() = this as? UploadVideoAction -/** - * Will notify user that bot is recording some audio - */ -@Serializable(BotActionSerializer::class) -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("RecordVoiceAction", "dev.inmo.tgbotapi.types.actions.RecordVoiceAction") -) -object RecordAudioAction : BotAction { - override val actionName: String = "record_audio" -} -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("recordVoice", "dev.inmo.tgbotapi.types.actions.recordVoice") -) -inline val recordAudio - get() = RecordAudioAction -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("asRecordVoice", "dev.inmo.tgbotapi.types.actions.asRecordVoice") -) -inline fun BotAction.asRecordAudio() = this as? RecordAudioAction - -/** - * Will notify user that bot is uploading some audio - */ -@Serializable(BotActionSerializer::class) -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("UploadVoiceAction", "dev.inmo.tgbotapi.types.actions.UploadVoiceAction") -) -object UploadAudioAction : BotAction { - override val actionName: String = "upload_audio" -} -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("uploadVoice", "dev.inmo.tgbotapi.types.actions.uploadVoice") -) -inline val uploadAudio - get() = UploadAudioAction -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("asUploadVoice", "dev.inmo.tgbotapi.types.actions.asUploadVoice") -) -inline fun BotAction.asUploadAudio() = this as? UploadAudioAction - /** * Will notify user that bot is recording some audio */ diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index c3f761259b..23534ec718 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.files -import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt index 63c3c00241..c5f0092c64 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.games import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.Photo @@ -11,4 +12,4 @@ data class Game( override val text: String? = null, override val textSources: TextSourcesList = emptyList(), val animation: AnimationFile? = null -) : Titled, CaptionedInput, TextedInput +) : Titled, TextedInput diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index 67f08598ae..86bf6e23a6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.message.content -import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.SendTextMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt index 354fb20903..6d97a72dda 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt @@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.types.InputMedia.* -interface MediaGroupContent : MediaContent, CaptionedInput, TextedInput { +interface MediaGroupContent : MediaContent, TextedInput { fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt index e1863bf213..1d2c5f1e87 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendAnimation import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.InputMediaAnimation +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AnimationFile @@ -17,7 +18,7 @@ data class AnimationContent( val includedDocument: DocumentFile?, override val text: String?, override val textSources: TextSourcesList = emptyList() -) : MediaContent, CaptionedInput, TextedInput { +) : MediaContent, TextedInput { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt index cb850e9598..394fddcd16 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendAudio import dev.inmo.tgbotapi.types.ChatIdentifier diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt index aa8f4dba37..140db64a47 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/DocumentContent.kt @@ -1,12 +1,12 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendDocument import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument import dev.inmo.tgbotapi.types.InputMedia.toInputMediaDocument +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.DocumentFile diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt index 11eea15039..921282e298 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/PhotoContent.kt @@ -1,11 +1,11 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendPhoto import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.InputMediaPhoto import dev.inmo.tgbotapi.types.InputMedia.toInputMediaPhoto +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.* diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt index e32b9ab412..41e8e360c5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VideoContent.kt @@ -1,10 +1,10 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendVideo import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VideoFile diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt index 95e6340edf..c656c2583f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendVoice import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VoiceFile @@ -15,7 +16,7 @@ data class VoiceContent( override val media: VoiceFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList() -) : MediaContent, CaptionedInput, TextedInput { +) : MediaContent, TextedInput { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt index 8dd4d8f159..2b308fbf7d 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt @@ -20,8 +20,6 @@ class BotActionTests { UploadPhotoAction -> example.botAction.actionName RecordVideoAction -> example.botAction.actionName UploadVideoAction -> example.botAction.actionName - RecordAudioAction -> example.botAction.actionName - UploadAudioAction -> example.botAction.actionName RecordVoiceAction -> example.botAction.actionName UploadVoiceAction -> example.botAction.actionName UploadDocumentAction -> example.botAction.actionName @@ -51,8 +49,6 @@ class BotActionTests { UploadPhotoAction.example(), RecordVideoAction.example(), UploadVideoAction.example(), - RecordAudioAction.example(), - UploadAudioAction.example(), RecordVoiceAction.example(), UploadVoiceAction.example(), UploadDocumentAction.example(), diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt index 71e11aef1c..bf6af8adf9 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt @@ -35,22 +35,6 @@ suspend fun TelegramBot.sendActionUploadVideo( chatId: ChatIdentifier ) = sendBotAction(chatId, UploadVideoAction) -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("sendActionRecordVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionRecordVoice") -) -suspend fun TelegramBot.sendActionRecordAudio( - chatId: ChatIdentifier -) = sendBotAction(chatId, RecordAudioAction) - -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("sendActionUploadVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionUploadVoice") -) -suspend fun TelegramBot.sendActionUploadAudio( - chatId: ChatIdentifier -) = sendBotAction(chatId, UploadAudioAction) - suspend fun TelegramBot.sendActionRecordVoice( chatId: ChatIdentifier ) = sendBotAction(chatId, RecordVoiceAction) @@ -92,22 +76,6 @@ suspend fun TelegramBot.sendActionUploadVideo( chat: Chat ) = sendBotAction(chat, UploadVideoAction) -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("sendActionRecordVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionRecordVoice") -) -suspend fun TelegramBot.sendActionRecordAudio( - chat: Chat -) = sendBotAction(chat, RecordAudioAction) - -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("sendActionUploadVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionUploadVoice") -) -suspend fun TelegramBot.sendActionUploadAudio( - chat: Chat -) = sendBotAction(chat, UploadAudioAction) - suspend fun TelegramBot.sendActionRecordVoice( chat: Chat ) = sendBotAction(chat, RecordVoiceAction) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt index 0e9f1fb94e..652eaf6ba4 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt @@ -56,16 +56,6 @@ suspend fun TelegramBot.withTypingAction(chatId: ChatId, block: TelegramBotA suspend fun TelegramBot.withUploadPhotoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadPhotoAction, block) suspend fun TelegramBot.withRecordVideoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordVideoAction, block) suspend fun TelegramBot.withUploadVideoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadVideoAction, block) -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("withRecordVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withRecordVoiceAction") -) -suspend fun TelegramBot.withRecordAudioAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordAudioAction, block) -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("withUploadVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withUploadVoiceAction") -) -suspend fun TelegramBot.withUploadAudioAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadAudioAction, block) suspend fun TelegramBot.withRecordVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordVoiceAction, block) suspend fun TelegramBot.withUploadVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadVoiceAction, block) suspend fun TelegramBot.withUploadDocumentAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadDocumentAction, block) @@ -78,16 +68,6 @@ suspend fun TelegramBot.withTypingAction(chat: Chat, block: TelegramBotActio suspend fun TelegramBot.withUploadPhotoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadPhotoAction, block) suspend fun TelegramBot.withRecordVideoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordVideoAction, block) suspend fun TelegramBot.withUploadVideoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadVideoAction, block) -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("withRecordVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withRecordVoiceAction") -) -suspend fun TelegramBot.withRecordAudioAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordAudioAction, block) -@Deprecated( - "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", - ReplaceWith("withUploadVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withUploadVoiceAction") -) -suspend fun TelegramBot.withUploadAudioAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadAudioAction, block) suspend fun TelegramBot.withRecordVoiceAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordVoiceAction, block) suspend fun TelegramBot.withUploadVoiceAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadVoiceAction, block) suspend fun TelegramBot.withUploadDocumentAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadDocumentAction, block) 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 79aa77dccc..73a2ee2f23 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 @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.CallbackQuery.* import dev.inmo.tgbotapi.types.ChatMember.* import dev.inmo.tgbotapi.types.ChatMember.abstracts.* +import dev.inmo.tgbotapi.types.ChatMember.abstracts.MemberChatMember import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.* @@ -23,6 +24,8 @@ import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery import dev.inmo.tgbotapi.types.InputMedia.* 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.actions.* import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* @@ -521,10 +524,6 @@ inline fun BotAction.asFindLocationAction(): FindLocationAction? = this as? Find @PreviewFeature inline fun BotAction.requireFindLocationAction(): FindLocationAction = this as FindLocationAction @PreviewFeature -inline fun BotAction.asRecordAudioAction(): RecordAudioAction? = this as? RecordAudioAction -@PreviewFeature -inline fun BotAction.requireRecordAudioAction(): RecordAudioAction = this as RecordAudioAction -@PreviewFeature inline fun BotAction.asRecordVoiceAction(): RecordVoiceAction? = this as? RecordVoiceAction @PreviewFeature inline fun BotAction.requireRecordVoiceAction(): RecordVoiceAction = this as RecordVoiceAction @@ -541,10 +540,6 @@ inline fun BotAction.asTypingAction(): TypingAction? = this as? TypingAction @PreviewFeature inline fun BotAction.requireTypingAction(): TypingAction = this as TypingAction @PreviewFeature -inline fun BotAction.asUploadAudioAction(): UploadAudioAction? = this as? UploadAudioAction -@PreviewFeature -inline fun BotAction.requireUploadAudioAction(): UploadAudioAction = this as UploadAudioAction -@PreviewFeature inline fun BotAction.asUploadVoiceAction(): UploadVoiceAction? = this as? UploadVoiceAction @PreviewFeature inline fun BotAction.requireUploadVoiceAction(): UploadVoiceAction = this as UploadVoiceAction diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt index a8e0535d8d..b36599ec67 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt @@ -55,18 +55,21 @@ fun TextSourcesList.toMarkdownCaptions(): List = createMarkdownText( this, captionLength.last ) + fun CaptionedInput.toMarkdownCaptions(): List = textSources.toMarkdownCaptions() fun TextSourcesList.toMarkdownTexts(): List = createMarkdownText( this, textLength.last ) + fun TextContent.toMarkdownTexts(): List = textSources.toMarkdownTexts() fun TextSourcesList.toMarkdownExplanations(): List = createMarkdownText( this, explanationLimit.last ) + fun ExplainedInput.toMarkdownExplanations(): List = textSources.toMarkdownTexts() @@ -79,18 +82,21 @@ fun TextSourcesList.toMarkdownV2Captions(): List = createMarkdownV2Text( this, captionLength.last ) + fun CaptionedInput.toMarkdownV2Captions(): List = textSources.toMarkdownV2Captions() fun TextSourcesList.toMarkdownV2Texts(): List = createMarkdownV2Text( this, textLength.last ) + fun TextContent.toMarkdownV2Texts(): List = textSources.toMarkdownV2Texts() fun TextSourcesList.toMarkdownV2Explanations(): List = createMarkdownV2Text( this, explanationLimit.last ) + fun ExplainedInput.toMarkdownV2Explanations(): List = textSources.toMarkdownV2Texts() @@ -103,18 +109,21 @@ fun TextSourcesList.toHtmlCaptions(): List = createHtmlText( this, captionLength.last ) + fun CaptionedInput.toHtmlCaptions(): List = textSources.toHtmlCaptions() fun TextSourcesList.toHtmlTexts(): List = createHtmlText( this, textLength.last ) + fun TextContent.toHtmlTexts(): List = textSources.toHtmlTexts() fun TextSourcesList.toHtmlExplanations(): List = createHtmlText( this, explanationLimit.last ) + fun ExplainedInput.toHtmlExplanations(): List = textSources.toHtmlTexts() From 72c3623d30e5beb5189f2be30a7b37878c8c8ad7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 14:32:45 +0600 Subject: [PATCH 51/63] small fillup of changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f23548960..d1f23dbf58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ * `Ktor`: `1.5.4` -> `1.6.0` * `Core`: * `ForceReply` has been renamed to `ReplyForce` + * `Captioned` and `Explained` interfaces have been removed + * `RecordAudioAction` and `UploadAudioAction` (and all related to these actions functionality) have been removed ## 0.34.1 From 5c0e58caec2615f4d98611f9a251db3d489487e7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 15:34:14 +0600 Subject: [PATCH 52/63] buildable except of jvm tests --- .github/write-good.yml | 1 - docs/build.gradle | 2 +- tgbotapi.core/build.gradle | 6 +- .../tgbotapi/CommonAbstracts/TextSource.kt | 14 +- .../inmo/tgbotapi/CommonAbstracts/Texted.kt | 13 +- .../dev/inmo/tgbotapi/requests/StopPoll.kt | 3 +- .../tgbotapi/requests/abstracts/InputFile.kt | 5 +- .../requests/answers/AnswerInlineQuery.kt | 9 +- .../answers/payments/AnswerShippingQuery.kt | 4 +- .../edit/caption/EditChatMessageCaption.kt | 5 +- .../edit/caption/EditInlineMessageCaption.kt | 5 +- .../requests/edit/text/EditChatMessageText.kt | 5 +- .../edit/text/EditInlineMessageText.kt | 5 +- .../games/abstracts/GetGameHighScores.kt | 4 +- .../tgbotapi/requests/send/CopyMessage.kt | 5 +- .../tgbotapi/requests/send/SendMessage.kt | 5 +- .../requests/send/media/SendAnimation.kt | 5 +- .../tgbotapi/requests/send/media/SendAudio.kt | 5 +- .../requests/send/media/SendDocument.kt | 5 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 5 +- .../tgbotapi/requests/send/media/SendVideo.kt | 5 +- .../tgbotapi/requests/send/media/SendVoice.kt | 5 +- .../tgbotapi/requests/send/polls/SendPoll.kt | 5 +- .../dev/inmo/tgbotapi/types/ChatIdentifier.kt | 12 +- .../dev/inmo/tgbotapi/types/ChatInviteLink.kt | 1 - .../types/ChatMember/MemberChatMemberImpl.kt | 1 - .../abstracts/AdministratorChatMember.kt | 1 - .../types/ChatMember/abstracts/ChatMember.kt | 9 +- .../InlineQueryResultArticle.kt | 4 +- .../InlineQueryResultAudioCachedImpl.kt | 7 +- .../InlineQueryResultAudioImpl.kt | 7 +- .../InlineQueryResultContact.kt | 2 +- .../InlineQueryResultDocumentCachedImpl.kt | 8 +- .../InlineQueryResultDocumentImpl.kt | 7 +- .../InlineQueryResultGifCachedImpl.kt | 7 +- .../InlineQueryResultGifImpl.kt | 7 +- .../InlineQueryResultLocation.kt | 2 +- .../InlineQueryResultMpeg4GifCachedImpl.kt | 7 +- .../InlineQueryResultMpeg4GifImpl.kt | 7 +- .../InlineQueryResultPhotoCachedImpl.kt | 7 +- .../InlineQueryResultPhotoImpl.kt | 7 +- .../InlineQueryResultStickerCached.kt | 2 +- .../InlineQueryResultVenue.kt | 2 +- .../InlineQueryResultVideoCachedImpl.kt | 7 +- .../InlineQueryResultVideoImpl.kt | 7 +- .../InlineQueryResultVoiceCachedImpl.kt | 8 +- .../InlineQueryResultVoiceImpl.kt | 8 +- ...ithInputMessageContentInlineQueryResult.kt | 2 +- .../InlineQueryResultSerializer.kt | 7 +- .../InputTextMessageContent.kt | 9 +- .../InputMessageContentSerializer.kt | 6 +- .../types/InputMedia/InputMediaAnimation.kt | 8 +- .../types/InputMedia/InputMediaAudio.kt | 4 +- .../types/InputMedia/InputMediaDocument.kt | 7 +- .../types/InputMedia/InputMediaPhoto.kt | 7 +- .../types/InputMedia/InputMediaSerializer.kt | 5 +- .../types/InputMedia/InputMediaVideo.kt | 6 +- .../MediaGroupMemberInputMediaSerializer.kt | 7 +- .../types/MessageEntity/RawMessageEntity.kt | 21 +- .../textsources/BoldTextSource.kt | 4 +- .../textsources/CashTagTextSource.kt | 4 +- .../textsources/EMailTextSource.kt | 4 +- .../textsources/HashTagTextSource.kt | 4 +- .../textsources/ItalicTextSource.kt | 4 +- .../textsources/MentionTextSource.kt | 4 +- .../textsources/PhoneNumberTextSource.kt | 4 +- .../textsources/StrikethroughTextSource.kt | 4 +- .../textsources/TextMentionTextSource.kt | 14 +- .../MessageEntity/textsources/TextSource.kt | 1 + .../textsources/UnderlineTextSource.kt | 4 +- .../tgbotapi/types/ParseMode/ParseMode.kt | 5 +- .../dev/inmo/tgbotapi/types/TelegramDate.kt | 10 +- .../kotlin/dev/inmo/tgbotapi/types/User.kt | 11 +- .../inmo/tgbotapi/types/UserProfilePhotos.kt | 4 +- .../inmo/tgbotapi/types/actions/BotAction.kt | 3 +- .../InlineKeyboardButtonSerializer.kt | 4 +- .../tgbotapi/types/buttons/KeyboardButton.kt | 5 +- .../types/buttons/KeyboardButtonPollType.kt | 5 +- .../types/buttons/KeyboardMarkupSerializer.kt | 5 +- .../tgbotapi/types/chat/ChatSerializers.kt | 8 +- .../tgbotapi/types/dice/DiceAnimationType.kt | 5 +- .../inmo/tgbotapi/types/files/PhotoSize.kt | 4 +- .../inmo/tgbotapi/types/files/VideoFile.kt | 1 + .../dev/inmo/tgbotapi/types/games/Game.kt | 3 +- .../inmo/tgbotapi/types/location/Location.kt | 1 - .../types/message/abstracts/Message.kt | 2 - .../types/message/content/TextContent.kt | 1 + .../content/abstracts/MediaGroupContent.kt | 1 - .../message/content/media/AnimationContent.kt | 2 +- .../message/content/media/AudioContent.kt | 1 + .../message/content/media/VoiceContent.kt | 2 +- .../encrypted/EncryptedElementSerializer.kt | 1 - .../tgbotapi/types/payments/ShippingOption.kt | 4 +- .../dev/inmo/tgbotapi/types/polls/Poll.kt | 7 +- .../inmo/tgbotapi/types/polls/PollOption.kt | 4 +- .../types/update/InlineQueryUpdate.kt | 2 +- .../tgbotapi/types/update/abstracts/Update.kt | 4 +- .../dev/inmo/tgbotapi/utils/MimeType.kt | 4 +- .../MultilevelTextSourceFormatting.kt | 6 +- .../dev/inmo/tgbotapi/types/BotActionTests.kt | 1 + .../types/MessageEntity/EntitiesTestText.kt | 2 +- .../MessageEntity/StringFormattingTests.kt | 2 +- .../inmo/tgbotapi/types/TextSourcesTests.kt | 1 + tgbotapi.extensions.api/build.gradle | 6 +- .../api/answers/AnswerInlineQuery.kt | 3 +- .../edit/caption/EditChatMessageCaption.kt | 7 +- .../edit/caption/EditInlineMessageCaption.kt | 3 +- .../api/edit/text/EditChatMessageText.kt | 7 +- .../api/edit/text/EditInlineMessageText.kt | 3 +- .../extensions/api/send/CopyMessage.kt | 13 +- .../extensions/api/send/SendMessage.kt | 11 +- .../api/send/media/SendAnimation.kt | 15 +- .../extensions/api/send/media/SendAudio.kt | 15 +- .../extensions/api/send/media/SendDocument.kt | 15 +- .../extensions/api/send/media/SendPhoto.kt | 15 +- .../extensions/api/send/media/SendVideo.kt | 15 +- .../extensions/api/send/media/SendVoice.kt | 15 +- .../extensions/api/send/polls/SendPoll.kt | 13 +- .../build.gradle | 6 +- .../expectations/WaitInlineQuery.kt | 7 +- .../triggers_handling/InlineQueryTriggers.kt | 7 +- tgbotapi.extensions.utils/build.gradle | 6 +- .../tgbotapi/extensions/utils/ClassCasts.kt | 1295 ++++++++++++++--- .../TextCaptionBotCommandsParser.kt | 2 +- .../utils/formatting/EntitiesBuilder.kt | 32 +- .../formatting/ResendingTextFormatting.kt | 14 +- .../utils/updates/CommandsFilters.kt | 5 +- tgbotapi/build.gradle | 6 +- 128 files changed, 1481 insertions(+), 579 deletions(-) delete mode 100644 .github/write-good.yml diff --git a/.github/write-good.yml b/.github/write-good.yml deleted file mode 100644 index 3edb5151f9..0000000000 --- a/.github/write-good.yml +++ /dev/null @@ -1 +0,0 @@ -spellchecker: true diff --git a/docs/build.gradle b/docs/build.gradle index d543950490..babb90dfde 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -26,7 +26,7 @@ repositories { kotlin { jvm() - js(BOTH) { + js(IR) { browser() nodejs() } diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index 5c01929c53..1948d03bc0 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -29,10 +29,8 @@ repositories { } kotlin { - jvm { - compilations.main.kotlinOptions.useIR = true - } - js(BOTH) { + jvm() + js(IR) { browser() nodejs() } 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 e91b6ff18c..2f5e3a38e9 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 @@ -4,12 +4,12 @@ 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 dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString 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 +import dev.inmo.tgbotapi.types.captionLength +import dev.inmo.tgbotapi.types.textLength const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods" @@ -30,7 +30,7 @@ inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource @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) = +inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.plus(other: List) = listOf(this) + other @Suppress("NOTHING_TO_INLINE") @@ -40,7 +40,7 @@ inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource @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) +inline operator fun List.plus(text: String) = this + regular(text) @Deprecated( "Replaced", @@ -49,13 +49,13 @@ inline operator fun List.makeString() = makeString() +fun List.makeString() = makeString() @Deprecated( "Replaced", ReplaceWith("separateForMessage", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage") ) -fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null) = +fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null) = separateForMessage(limit, numberOfParts) /** 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 f1f7dec69b..d2348af1ac 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 @@ -8,9 +8,9 @@ interface Texted { } interface TextedWithTextSources : Texted { /** - * Full list of [TextSource] built from source[TextedInput.textEntities] + * Full list of [TextSource]s */ - val textSources: List? + val textSources: List? } interface ParsableOutput : Texted { @@ -18,7 +18,7 @@ interface ParsableOutput : Texted { } interface EntitiesOutput : TextedWithTextSources { - val entities: List? + val entities: List? get() = textSources } @@ -26,11 +26,4 @@ interface TextedOutput : ParsableOutput, EntitiesOutput interface TextedInput : TextedWithTextSources { override val textSources: List - /** - * Here must be full list of entities. This list must contains [TextPart]s with - * [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of - * regular text - */ - val textEntities: List - get() = textSources.toTextParts() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/StopPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/StopPoll.kt index 307fe0dda2..1d5bfefd72 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/StopPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/StopPoll.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.polls.Poll +import dev.inmo.tgbotapi.types.polls.PollSerializer import kotlinx.serialization.* @Serializable @@ -19,7 +20,7 @@ data class StopPoll( ) : MessageAction, SimpleRequest, ReplyMarkup { override fun method(): String = "stopPoll" override val resultDeserializer: DeserializationStrategy - get() = Poll.serializer() + get() = PollSerializer override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt index 29ba40120d..1a02259ba6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.requests.abstracts +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.StorageFile import kotlinx.serialization.* import kotlinx.serialization.descriptors.* @@ -30,8 +31,8 @@ data class FileId( fun String.toInputFile() = FileId(this) -@Serializer(InputFile::class) -internal object InputFileSerializer : KSerializer { +@RiskFeature +object InputFileSerializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING) override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId) override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString()) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/AnswerInlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/AnswerInlineQuery.kt index c295a99dcc..0971c24ed5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/AnswerInlineQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/AnswerInlineQuery.kt @@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.serializer @@ -26,7 +26,7 @@ data class AnswerInlineQuery( val switchPmText: String? = null, @SerialName(switchPmParameterField) val switchPmParameter: String? = null -): SimpleRequest { +) : SimpleRequest { override fun method(): String = "answerInlineQuery" override val resultDeserializer: DeserializationStrategy get() = Boolean.serializer() @@ -34,7 +34,7 @@ data class AnswerInlineQuery( get() = serializer() } -fun InlineQuery.createAnswer( +fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.createAnswer( results: List = emptyList(), cachedTime: Int? = null, isPersonal: Boolean? = null, @@ -51,6 +51,7 @@ fun InlineQuery.createAnswer( switchPmParameter ) -internal object InlineQueryAnswersResultsSerializer: KSerializer> by ListSerializer( +@RiskFeature +object InlineQueryAnswersResultsSerializer : KSerializer> by ListSerializer( InlineQueryResultSerializer ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/payments/AnswerShippingQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/payments/AnswerShippingQuery.kt index 468e81a323..9eeae332f3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/payments/AnswerShippingQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/payments/AnswerShippingQuery.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.answers.payments.abstracts.AnswerShippingQuery import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.payments.ShippingOption import dev.inmo.tgbotapi.types.payments.ShippingQuery +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer @@ -21,7 +22,8 @@ data class AnswerShippingQueryOk( get() = serializer() } -internal object ShippingOptionsSerializer : KSerializer> by ListSerializer( +@RiskFeature +object ShippingOptionsSerializer : KSerializer> by ListSerializer( ShippingOption.serializer() ) 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 9a74b6823a..fdc8cc8e55 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 @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -32,7 +33,7 @@ fun EditChatMessageCaption( fun EditChatMessageCaption( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageCaption( chatId, @@ -58,7 +59,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: TextSourcesList? 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 1b93d918bc..21a96caf51 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -24,7 +25,7 @@ fun EditInlineMessageCaption( fun EditInlineMessageCaption( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageCaption( inlineMessageId, @@ -47,7 +48,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: TextSourcesList? 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 6f825dc46e..82644f8e4e 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 @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -34,7 +35,7 @@ fun EditChatMessageText( fun EditChatMessageText( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageText( @@ -64,7 +65,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: TextSourcesList? 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 89c8f1f4f5..2d92305b31 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -26,7 +27,7 @@ fun EditInlineMessageText( fun EditInlineMessageText( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageText( @@ -53,7 +54,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: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/abstracts/GetGameHighScores.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/abstracts/GetGameHighScores.kt index fe7ea58aca..1c68b30ab8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/abstracts/GetGameHighScores.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/abstracts/GetGameHighScores.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.requests.games.abstracts import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.games.GameHighScore +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.ListSerializer @@ -15,4 +16,5 @@ interface GetGameHighScores : SimpleRequest> { get() = GameHighScoresSerializer } -internal object GameHighScoresSerializer : KSerializer> by ListSerializer(GameHighScore.serializer()) +@RiskFeature +object GameHighScoresSerializer : KSerializer> by ListSerializer(GameHighScore.serializer()) 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 7c2484eaa4..61f88c08e3 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 @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.CommonAbstracts.types.MessageAction import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest @@ -28,7 +29,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 6e5b019b13..3449b0bc01 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 @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -40,7 +41,7 @@ fun SendTextMessage( fun SendTextMessage( chatId: ChatIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -83,7 +84,7 @@ data class SendTextMessage internal constructor( TextableSendMessageRequest>, DisableWebPagePreview { - override val textSources: List? by lazy { + override val textSources: TextSourcesList? 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 f2d2f7c6a4..cd05c978d3 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 @@ -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.TextSourcesList 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 SendAnimation( chatId: ChatIdentifier, animation: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -144,7 +145,7 @@ data class SendAnimationData internal constructor( DuratedSendMessageRequest>, SizedSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: TextSourcesList? 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 44640436ac..ca2040d1f2 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 @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.Performerable +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.media.base.* @@ -66,7 +67,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 d6de45940d..0e17106f28 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 @@ -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.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -79,7 +80,7 @@ fun SendDocument( chatId: ChatIdentifier, document: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -157,7 +158,7 @@ data class SendDocumentData internal constructor( TextableSendMessageRequest>, ThumbedSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: TextSourcesList? 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 79dd2aa5c7..a6ad86c385 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 @@ -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.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -47,7 +48,7 @@ fun SendPhoto( fun SendPhoto( chatId: ChatIdentifier, photo: InputFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -100,7 +101,7 @@ data class SendPhotoData internal constructor( ReplyingMarkupSendMessageRequest>, TextableSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: TextSourcesList? 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 327bc141a0..ce0366c437 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 @@ -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.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -67,7 +68,7 @@ fun SendVideo( chatId: ChatIdentifier, video: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -150,7 +151,7 @@ data class SendVideoData internal constructor( DuratedSendMessageRequest>, SizedSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: TextSourcesList? 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 f154ac84ae..0a951a97e5 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 @@ -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.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -56,7 +57,7 @@ fun SendVoice( fun SendVoice( chatId: ChatIdentifier, voice: InputFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -120,7 +121,7 @@ data class SendVoiceData internal constructor( TextableSendMessageRequest>, DuratedSendMessageRequest> { - override val textSources: List? by lazy { + override val textSources: TextSourcesList? 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 ea65c9eda9..72bc2cb98a 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 @@ -1,7 +1,8 @@ package dev.inmo.tgbotapi.requests.send.polls import com.soywiz.klock.DateTime -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput +import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.types.* @@ -268,7 +269,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/ChatIdentifier.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt index 3633593f94..4cbee6bedd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt @@ -1,7 +1,9 @@ package dev.inmo.tgbotapi.types import dev.inmo.micro_utils.common.Warning +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* +import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.JsonPrimitive @@ -52,10 +54,12 @@ data class Username( fun String.toUsername(): Username = Username(this) -@Serializer(ChatIdentifier::class) -internal object ChatIdentifierSerializer : KSerializer { +@RiskFeature +object ChatIdentifierSerializer : KSerializer { + private val internalSerializer = JsonPrimitive.serializer() + override val descriptor: SerialDescriptor = internalSerializer.descriptor override fun deserialize(decoder: Decoder): ChatIdentifier { - val id = JsonPrimitive.serializer().deserialize(decoder) + val id = internalSerializer.deserialize(decoder) return id.longOrNull ?.let { ChatId(it) } ?: id.content.let { @@ -73,4 +77,4 @@ internal object ChatIdentifierSerializer : KSerializer { is Username -> encoder.encodeString(value.username) } } -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt index fe4bc031e7..945e2b9616 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt @@ -79,7 +79,6 @@ data class CommonInviteLink( get() = expireDate ?.asDate } -@Serializer(ChatInviteLink::class) object ChatInviteLinkSerializer : KSerializer { override val descriptor: SerialDescriptor get() = RawChatInviteLink.serializer().descriptor 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 index 35cafb6bd3..3adbac1b3c 100644 --- 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 @@ -1,7 +1,6 @@ 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.* diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt index cd05b4e9c9..5751852819 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt @@ -20,7 +20,6 @@ interface AdministratorChatMember : SpecialRightsChatMember { val customTitle: String? } -@Serializer(AdministratorChatMember::class) @RiskFeature object AdministratorChatMemberSerializer : KSerializer { override val descriptor: SerialDescriptor = ChatMemberSerializer.descriptor 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 e325c7999b..d5c5acfde0 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 @@ -17,7 +17,6 @@ sealed interface ChatMember { val user: User } -@Serializer(ChatMember::class) @RiskFeature object ChatMemberSerializer : KSerializer { override val descriptor: SerialDescriptor = JsonObject.serializer().descriptor @@ -27,9 +26,9 @@ object ChatMemberSerializer : KSerializer { return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) { "creator" -> nonstrictJsonFormat.decodeFromJsonElement(CreatorChatMember.serializer(), json) "administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json) - "member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMember.serializer(), json) + "member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMemberImpl.serializer(), json) "restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json) - "left" -> nonstrictJsonFormat.decodeFromJsonElement(LeftChatMember.serializer(), json) + "left" -> nonstrictJsonFormat.decodeFromJsonElement(LeftChatMemberImpl.serializer(), json) "kicked" -> nonstrictJsonFormat.decodeFromJsonElement(KickedChatMember.serializer(), json) else -> error("Unknown type of chat member in json: $json") } @@ -39,9 +38,9 @@ object ChatMemberSerializer : KSerializer { when (value) { is CreatorChatMember -> CreatorChatMember.serializer() is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer() - is MemberChatMember -> MemberChatMember.serializer() + is MemberChatMember -> MemberChatMemberImpl.serializer() is RestrictedChatMember -> RestrictedChatMember.serializer() - is LeftChatMember -> LeftChatMember.serializer() + is LeftChatMember -> LeftChatMemberImpl.serializer() is KickedChatMember -> KickedChatMember.serializer() } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt index 85d68f304f..870e3e7fc8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -36,4 +36,4 @@ class InlineQueryResultArticle( WithInputMessageContentInlineQueryResult, UrlInlineQueryResult { override val type: String = "article" -} \ No newline at end of file +} 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 19a1abf34e..2d0c578208 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 @@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -25,7 +26,7 @@ fun InlineQueryResultAudioCachedImpl( fun InlineQueryResultAudioCachedImpl( id: InlineQueryIdentifier, fileId: FileId, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultAudioCachedImpl(id, fileId, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -48,7 +49,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: TextSourcesList? 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 b9536aa9ea..3ba051f937 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 @@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -30,7 +31,7 @@ fun InlineQueryResultAudioImpl( title: String, performer: String? = null, duration: Int? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultAudioImpl(id, url, title, performer, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -59,7 +60,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: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt index bd929a4862..6403a79c8e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultContact.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult import dev.inmo.tgbotapi.CommonAbstracts.CommonContactData import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable 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 65cd621ac6..49fe37fcf9 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 @@ -5,8 +5,10 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -29,7 +31,7 @@ fun InlineQueryResultDocumentCachedImpl( fileId: FileId, title: String, description: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultDocumentCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -56,7 +58,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: TextSourcesList? 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 c17285846a..62a37d5ffd 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 @@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -38,7 +39,7 @@ fun InlineQueryResultDocumentImpl( thumbWidth: Int? = null, thumbHeight: Int? = null, description: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultDocumentImpl(id, url, title, mimeType, thumbUrl, thumbWidth, thumbHeight, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -73,7 +74,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: TextSourcesList? 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 b08013b5d8..07a5139df1 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 @@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -27,7 +28,7 @@ fun InlineQueryResultGifCachedImpl( id: InlineQueryIdentifier, fileId: FileId, title: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultGifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -52,7 +53,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: TextSourcesList? 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 c9fbfd01bf..69e491a43a 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 @@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -37,7 +38,7 @@ fun InlineQueryResultGifImpl( height: Int? = null, duration: Int? = null, title: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultGifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -72,7 +73,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: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt index 5b6d19776f..7a7f383371 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultLocation.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable 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 9d4b3eaf71..76f9dc7c5e 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 @@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -27,7 +28,7 @@ fun InlineQueryResultMpeg4GifCachedImpl( id: InlineQueryIdentifier, fileId: FileId, title: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultMpeg4GifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -52,7 +53,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: TextSourcesList? 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 7abd6fb13c..b789a849e1 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 @@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -37,7 +38,7 @@ fun InlineQueryResultMpeg4GifImpl( height: Int? = null, duration: Int? = null, title: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultMpeg4GifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -72,7 +73,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: TextSourcesList? 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 8a55e29fde..b39a025b5c 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 @@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -29,7 +30,7 @@ fun InlineQueryResultPhotoCachedImpl( fileId: FileId, title: String? = null, description: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultPhotoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -56,7 +57,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: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } 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 fb1443a03e..d3e9c722d2 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 @@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -34,7 +35,7 @@ fun InlineQueryResultPhotoImpl( height: Int? = null, title: String? = null, description: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultPhotoImpl(id, url, thumbUrl, width, height, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -67,7 +68,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: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultStickerCached.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultStickerCached.kt index a1defa2d23..936574e4ca 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultStickerCached.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultStickerCached.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt index e514afb1dd..a3dc134bfd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/InlineQueryResultVenue.kt @@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.CommonVenueData import dev.inmo.tgbotapi.CommonAbstracts.Locationed import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable 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 bc50c0dc02..6b61eee0d3 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 @@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -29,7 +30,7 @@ fun InlineQueryResultVideoCachedImpl( fileId: FileId, title: String, description: String? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVideoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -56,7 +57,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: TextSourcesList? 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 9677902fb2..478e8590b9 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 @@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.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 dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -40,7 +41,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) @@ -77,7 +78,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 1d948491cd..52969b6696 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 @@ -5,8 +5,10 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -27,7 +29,7 @@ fun InlineQueryResultVoiceCachedImpl( id: InlineQueryIdentifier, fileId: FileId, title: String, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVoiceCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -52,7 +54,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: TextSourcesList? 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 8374fe7996..4239a43126 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 @@ -4,8 +4,10 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -38,7 +40,7 @@ fun InlineQueryResultVoiceImpl( url: String, title: String, duration: Int? = null, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null ) = InlineQueryResultVoiceImpl(id, url, title, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) @@ -65,7 +67,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: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/WithInputMessageContentInlineQueryResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/WithInputMessageContentInlineQueryResult.kt index 3205267932..b3cf50e24f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/WithInputMessageContentInlineQueryResult.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/WithInputMessageContentInlineQueryResult.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent interface WithInputMessageContentInlineQueryResult : InlineQueryResult { val inputMessageContent: InputMessageContent? diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/serializers/InlineQueryResultSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/serializers/InlineQueryResultSerializer.kt index 29a852e5fa..cc8d150dba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/serializers/InlineQueryResultSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/serializers/InlineQueryResultSerializer.kt @@ -2,13 +2,14 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -@Serializer(InlineQueryResult::class) -internal object InlineQueryResultSerializer : KSerializer { +@RiskFeature +object InlineQueryResultSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor(InlineQueryResult::class.toString(), PolymorphicKind.OPEN) override fun serialize(encoder: Encoder, value: InlineQueryResult) { @@ -39,4 +40,4 @@ internal object InlineQueryResultSerializer : KSerializer { override fun deserialize(decoder: Decoder): InlineQueryResult { throw TODO() } -} \ No newline at end of file +} 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 6e959bec6b..ef056d4857 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 @@ -1,10 +1,11 @@ package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.SerialName @@ -23,7 +24,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: TextSourcesList, disableWebPagePreview: Boolean? = null ) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview) @@ -38,7 +39,7 @@ data class InputTextMessageContent internal constructor( @SerialName(disableWebPagePreviewField) override val disableWebPagePreview: Boolean? = null ) : TextedOutput, DisableWebPagePreview, InputMessageContent { - override val textSources: List? by lazy { + override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt index 39052ffbc4..815272fb5a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt @@ -1,14 +1,14 @@ package dev.inmo.tgbotapi.types.InlineQueries import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -@Serializer(InputMessageContent::class) -internal object InputMessageContentSerializer : KSerializer { +@RiskFeature +object InputMessageContentSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor(InputMessageContent::class.toString(), PolymorphicKind.OPEN) override fun serialize(encoder: Encoder, value: InputMessageContent) { 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 093545046d..4f64b24563 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 @@ -1,11 +1,13 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput +import dev.inmo.tgbotapi.CommonAbstracts.makeString 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.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.SerialName @@ -23,7 +25,7 @@ fun InputMediaAnimation( fun InputMediaAnimation( file: InputFile, - entities: List, + entities: TextSourcesList, width: Int? = null, height: Int? = null, duration: Long? = null, @@ -45,7 +47,7 @@ data class InputMediaAnimation internal constructor( override val thumb: InputFile? = null ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput { override val type: String = "animation" - override val textSources: List? by lazy { + override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy 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 52a432005e..fcd164a2b1 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 @@ -15,7 +15,7 @@ internal const val audioInputMediaType = "audio" fun InputMediaAudio( file: InputFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, performer: String? = null, title: String? = null, @@ -51,7 +51,7 @@ data class InputMediaAudio internal constructor( override val thumb: InputFile? = null ) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, Performerable { override val type: String = audioInputMediaType - override val textSources: List? by lazy { + override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy 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 ea8410de98..3da2e9bb7c 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 @@ -1,10 +1,11 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.makeString 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.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.DocumentFile @@ -22,7 +23,7 @@ fun InputMediaDocument( fun InputMediaDocument( file: InputFile, - entities: List, + entities: TextSourcesList, thumb: InputFile? = null, disableContentTypeDetection: Boolean? = null ) = InputMediaDocument(file, entities.makeString(), null, entities.toRawMessageEntities(), thumb, disableContentTypeDetection) @@ -51,7 +52,7 @@ data class InputMediaDocument internal constructor( val disableContentTypeDetection: Boolean? = null ) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia { override val type: String = documentInputMediaType - override val textSources: List? by lazy { + override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } 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 1f80d4260c..c6c6f671ac 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 @@ -1,11 +1,12 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.makeString 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.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.PhotoSize @@ -21,7 +22,7 @@ fun InputMediaPhoto( fun InputMediaPhoto( file: InputFile, - entities: List + entities: TextSourcesList ) = InputMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities()) @Serializable @@ -35,7 +36,7 @@ data class InputMediaPhoto internal constructor( private val rawEntities: List? = null ) : InputMedia, VisualMediaGroupMemberInputMedia { override val type: String = photoInputMediaType - override val textSources: List? by lazy { + override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaSerializer.kt index 1d29dbb037..a5358762e1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaSerializer.kt @@ -1,12 +1,13 @@ package dev.inmo.tgbotapi.types.InputMedia +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -@Serializer(InputMedia::class) -internal object InputMediaSerializer : KSerializer { +@RiskFeature +object InputMediaSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor(InputMedia::class.toString(), PolymorphicKind.OPEN) override fun serialize(encoder: Encoder, value: InputMedia) { 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 3a8355a486..fbe67ad528 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 @@ -5,6 +5,8 @@ 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.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.* @@ -23,7 +25,7 @@ fun InputMediaVideo( fun InputMediaVideo( file: InputFile, - entities: List, + entities: TextSourcesList, width: Int? = null, height: Int? = null, duration: Long? = null, @@ -45,7 +47,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: TextSourcesList? by lazy { rawEntities ?.asTextSources(text ?: return@lazy null) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMediaSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMediaSerializer.kt index 2933aa558b..2777e576f0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMediaSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMediaSerializer.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.InputMedia import dev.inmo.tgbotapi.types.typeField +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* import kotlinx.serialization.descriptors.* @@ -8,8 +9,8 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.* -@Serializer(MediaGroupMemberInputMedia::class) -internal object MediaGroupMemberInputMediaSerializer : KSerializer { +@RiskFeature +object MediaGroupMemberInputMediaSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor(MediaGroupMemberInputMedia::class.toString(), PolymorphicKind.OPEN) override fun serialize(encoder: Encoder, value: MediaGroupMemberInputMedia) { @@ -32,4 +33,4 @@ internal object MediaGroupMemberInputMediaSerializer : KSerializer error("Illegal type of incoming MediaGroupMemberInputMedia") } } -} \ No newline at end of file +} 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 f4572c11c7..577e378c72 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,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity -import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.User import kotlinx.serialization.Serializable @@ -21,8 +20,8 @@ internal data class RawMessageEntity( internal fun RawMessageEntity.asTextSource( source: String, - subParts: List -): dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource { + subParts: TextSourcesList +): TextSource { val sourceSubstring: String = source.substring(range) val subPartsWithRegulars by lazy { subParts.fillWithRegulars(sourceSubstring) @@ -58,9 +57,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 TextSourcesList.fillWithRegulars(source: String): TextSourcesList { 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) @@ -83,9 +82,9 @@ internal fun List. private fun createTextSources( originalFullString: String, entities: RawMessageEntities -): List { +): TextSourcesList { val mutableEntities = entities.toMutableList().apply { sortBy { it.offset } } - val resultList = mutableListOf() + val resultList = mutableListOf() while (mutableEntities.isNotEmpty()) { var parent = mutableEntities.removeFirst() @@ -139,7 +138,7 @@ private fun createTextSources( return resultList } -internal fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.toRawMessageEntities(offset: Int = 0): List { +internal fun TextSource.toRawMessageEntities(offset: Int = 0): List { val source = source val length = source.length return listOfNotNull( @@ -169,7 +168,7 @@ internal fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.toRawM } -internal fun List.toRawMessageEntities(preOffset: Int = 0): List { +internal fun TextSourcesList.toRawMessageEntities(preOffset: Int = 0): List { var i = preOffset return flatMap { textSource -> textSource.toRawMessageEntities(i).also { @@ -184,9 +183,9 @@ fun String.removeLeading(word: String) = if (startsWith(word)) { this } -internal fun List.toRawMessageEntities(): List = toRawMessageEntities(0) +internal fun TextSourcesList.toRawMessageEntities(): List = toRawMessageEntities(0) -internal fun RawMessageEntities.asTextSources(sourceString: String): List = +internal fun RawMessageEntities.asTextSources(sourceString: String): TextSourcesList = 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 2b1ea32e05..40c5a53b3b 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.boldMarkdown() } override val markdownV2: String by lazy { boldMarkdownV2() } @@ -18,7 +18,7 @@ data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) } @Suppress("NOTHING_TO_INLINE") -inline fun bold(parts: List) = BoldTextSource(parts.makeString(), parts) +inline fun bold(parts: TextSourcesList) = BoldTextSource(parts.makeString(), parts) @Suppress("NOTHING_TO_INLINE") inline fun bold(vararg parts: TextSource) = bold(parts.toList()) @Suppress("NOTHING_TO_INLINE") 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 de6f10874f..9e07f371d9 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.cashTagMarkdown() } override val markdownV2: String by lazy { cashTagMarkdownV2() } @@ -18,7 +18,7 @@ data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo } @Suppress("NOTHING_TO_INLINE") -inline fun cashTag(parts: List) = CashTagTextSource(parts.makeString(), parts) +inline fun cashTag(parts: TextSourcesList) = CashTagTextSource(parts.makeString(), parts) @Suppress("NOTHING_TO_INLINE") inline fun cashTag(vararg parts: TextSource) = cashTag(parts.toList()) @Suppress("NOTHING_TO_INLINE") 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 dd45431454..0e99978665 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.emailMarkdown() } override val markdownV2: String by lazy { emailMarkdownV2(source) } @@ -18,7 +18,7 @@ data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) } @Suppress("NOTHING_TO_INLINE") -inline fun email(parts: List) = EMailTextSource(parts.makeString(), parts) +inline fun email(parts: TextSourcesList) = EMailTextSource(parts.makeString(), parts) @Suppress("NOTHING_TO_INLINE") inline fun email(vararg parts: TextSource) = email(parts.toList()) @Suppress("NOTHING_TO_INLINE") 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 ffcc885cb1..2138cd9485 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.hashTagMarkdown() } override val markdownV2: String by lazy { hashTagMarkdownV2() } @@ -24,7 +24,7 @@ data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo } @Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_API_USAGE") -inline fun hashtag(parts: List) = (regular("#") + parts).let { HashTagTextSource(it.makeString(), it) } +inline fun hashtag(parts: TextSourcesList) = (regular("#") + parts).let { HashTagTextSource(it.makeString(), it) } @Suppress("NOTHING_TO_INLINE") inline fun hashtag(vararg parts: TextSource) = hashtag(parts.toList()) /** 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 ab5846fb2f..18c3125996 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.italicMarkdown() } override val markdownV2: String by lazy { italicMarkdownV2() } @@ -18,7 +18,7 @@ data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor } @Suppress("NOTHING_TO_INLINE") -inline fun italic(parts: List) = ItalicTextSource(parts.makeString(), parts) +inline fun italic(parts: TextSourcesList) = ItalicTextSource(parts.makeString(), parts) @Suppress("NOTHING_TO_INLINE") inline fun italic(vararg parts: TextSource) = italic(parts.toList()) @Suppress("NOTHING_TO_INLINE") 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 169f9aa784..6c84646821 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 @@ -17,7 +17,7 @@ private val String.withoutCommercialAt @Serializable data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.mentionMarkdown() } override val markdownV2: String by lazy { mentionMarkdownV2() } @@ -31,7 +31,7 @@ data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo } @Suppress("NOTHING_TO_INLINE") -inline fun mention(parts: List) = (regular("@") + parts).let { MentionTextSource(it.makeString(), it) } +inline fun mention(parts: TextSourcesList) = (regular("@") + parts).let { MentionTextSource(it.makeString(), it) } @Suppress("NOTHING_TO_INLINE") inline fun mention(vararg parts: TextSource) = mention(parts.toList()) 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 fe329bfac0..67350033eb 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.phoneMarkdown() } override val markdownV2: String by lazy { phoneMarkdownV2() } @@ -18,7 +18,7 @@ data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstr } @Suppress("NOTHING_TO_INLINE") -inline fun phone(parts: List) = PhoneNumberTextSource(parts.makeString(), parts) +inline fun phone(parts: TextSourcesList) = PhoneNumberTextSource(parts.makeString(), parts) @Suppress("NOTHING_TO_INLINE") inline fun phone(vararg parts: TextSource) = phone(parts.toList()) @Suppress("NOTHING_TO_INLINE") 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 2efea3020b..7965ae799f 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val html: String by lazy { strikethroughHTML() } override val markdownV2: String by lazy { strikethroughMarkdownV2() } @@ -18,7 +18,7 @@ data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceCons } @Suppress("NOTHING_TO_INLINE") -inline fun strikethrough(parts: List) = StrikethroughTextSource(parts.makeString(), parts) +inline fun strikethrough(parts: TextSourcesList) = StrikethroughTextSource(parts.makeString(), parts) @Suppress("NOTHING_TO_INLINE") inline fun strikethrough(vararg parts: TextSource) = strikethrough(parts.toList()) @Suppress("NOTHING_TO_INLINE") 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 791ec21d88..7a9e6ad792 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 @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, val user: User, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.textMentionMarkdown(user.id) } override val markdownV2: String by lazy { textMentionMarkdownV2(user.id) } @@ -20,17 +20,17 @@ data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstr } @Suppress("NOTHING_TO_INLINE") -inline fun mention(parts: List, user: User) = TextMentionTextSource(parts.makeString(), user, parts) +inline fun mention(parts: TextSourcesList, user: User) = TextMentionTextSource(parts.makeString(), user, parts) @Suppress("NOTHING_TO_INLINE") -inline fun User.mention(parts: List) = mention(parts, this) +inline fun User.mention(parts: TextSourcesList) = mention(parts, this) @Suppress("NOTHING_TO_INLINE") -inline fun mention(parts: List, userId: UserId) = mention(parts, CommonUser(userId, "")) +inline fun mention(parts: TextSourcesList, userId: UserId) = mention(parts, CommonUser(userId, "")) @Suppress("NOTHING_TO_INLINE") -inline fun UserId.mention(parts: List) = mention(parts, this) +inline fun UserId.mention(parts: TextSourcesList) = mention(parts, this) @Suppress("NOTHING_TO_INLINE") -inline fun mention(parts: List, id: Identifier) = mention(parts, UserId(id)) +inline fun mention(parts: TextSourcesList, id: Identifier) = mention(parts, UserId(id)) @Suppress("NOTHING_TO_INLINE") -inline fun Identifier.mention(parts: List) = mention(parts, this) +inline fun Identifier.mention(parts: TextSourcesList) = mention(parts, this) @Suppress("NOTHING_TO_INLINE") inline fun mention(user: User, vararg parts: TextSource) = mention(parts.toList(), user) @Suppress("NOTHING_TO_INLINE") 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 index e909b2aed3..3ac89386a4 100644 --- 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 @@ -7,6 +7,7 @@ import kotlinx.serialization.Serializable const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods" typealias TextSourcesList = List +typealias MutableTextSourcesList = MutableList @Serializable(TextSourceSerializer::class) sealed interface TextSource { 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 969cda18ad..0a61ab2905 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val subsources: List + override val subsources: TextSourcesList ) : MultilevelTextSource { override val markdown: String by lazy { source.underlineMarkdown() } override val markdownV2: String by lazy { underlineMarkdownV2() } @@ -18,7 +18,7 @@ data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstruc } @Suppress("NOTHING_TO_INLINE") -inline fun underline(parts: List) = UnderlineTextSource(parts.makeString(), parts) +inline fun underline(parts: TextSourcesList) = UnderlineTextSource(parts.makeString(), parts) @Suppress("NOTHING_TO_INLINE") inline fun underline(vararg parts: TextSource) = underline(parts.toList()) @Suppress("NOTHING_TO_INLINE") 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 a889a1f1bb..cf2222ddd2 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,5 +1,6 @@ package dev.inmo.tgbotapi.types.ParseMode +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer import kotlinx.serialization.descriptors.SerialDescriptor @@ -45,8 +46,8 @@ typealias HTML = HTMLParseMode */ var defaultParseMode: ParseMode = HTML -@Serializer(ParseMode::class) -internal object ParseModeSerializerObject : KSerializer { +@RiskFeature +object ParseModeSerializerObject : KSerializer { override val descriptor: SerialDescriptor = String.serializer().descriptor override fun deserialize(decoder: Decoder): ParseMode { return when (decoder.decodeString()) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TelegramDate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TelegramDate.kt index 0be809987d..8ac8a5c12e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TelegramDate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TelegramDate.kt @@ -1,9 +1,13 @@ package dev.inmo.tgbotapi.types import com.soywiz.klock.DateTime +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer +import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder +import kotlinx.serialization.json.JsonPrimitive @Serializable(TelegramDateSerializer::class) data class TelegramDate( @@ -24,8 +28,10 @@ data class TelegramDate( fun DateTime.toTelegramDate(): TelegramDate = TelegramDate(this) -@Serializer(TelegramDate::class) -internal object TelegramDateSerializer : KSerializer { +@RiskFeature +object TelegramDateSerializer : KSerializer { + override val descriptor: SerialDescriptor = Long.serializer().descriptor + override fun serialize(encoder: Encoder, value: TelegramDate) { encoder.encodeLong( value.date diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/User.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/User.kt index bb9707428a..5c7fd10e41 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/User.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/User.kt @@ -2,9 +2,10 @@ package dev.inmo.tgbotapi.types import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat import dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl -import dev.inmo.tgbotapi.utils.PreviewFeature +import dev.inmo.tgbotapi.utils.* 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.* @@ -68,10 +69,12 @@ data class ExtendedBot( } -@Serializer(User::class) -internal object UserSerializer : KSerializer { +@RiskFeature +object UserSerializer : KSerializer { + private val internalSerializer = JsonObject.serializer() + override val descriptor: SerialDescriptor = internalSerializer.descriptor override fun deserialize(decoder: Decoder): User { - val asJson = JsonObject.serializer().deserialize(decoder) + val asJson = internalSerializer.deserialize(decoder) return when { asJson[isBotField] ?.jsonPrimitive ?.booleanOrNull != true -> nonstrictJsonFormat.decodeFromJsonElement( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UserProfilePhotos.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UserProfilePhotos.kt index 2ccb208d9b..2b677b27e7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UserProfilePhotos.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UserProfilePhotos.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.PhotoSerializer +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer @@ -13,6 +14,7 @@ data class UserProfilePhotos ( val photos: List ) -internal object UserProfilePhotosPhotosSerializer : KSerializer> by ListSerializer( +@RiskFeature +object UserProfilePhotosPhotosSerializer : KSerializer> by ListSerializer( PhotoSerializer ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt index 9df136fb8f..a79b14781d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt @@ -14,8 +14,7 @@ sealed interface BotAction { val actionName: String } -@Serializer(BotAction::class) -internal object BotActionSerializer: KSerializer { +object BotActionSerializer: KSerializer { override val descriptor: SerialDescriptor = String.serializer().descriptor override fun serialize(encoder: Encoder, value: BotAction) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt index c8a3be6343..20772f4eae 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.InternalSerializationApi import kotlinx.serialization.KSerializer @@ -10,7 +11,8 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonObject -internal object InlineKeyboardButtonSerializer : KSerializer { +@RiskFeature +object InlineKeyboardButtonSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor( "dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton", 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 c7e3016b09..8993a1ab30 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 @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.buttons import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor @@ -47,8 +48,8 @@ data class RequestPollKeyboardButton( val requestPoll: KeyboardButtonPollType ) : KeyboardButton -@Serializer(KeyboardButton::class) -internal object KeyboardButtonSerializer : KSerializer { +@RiskFeature +object KeyboardButtonSerializer : KSerializer { private val internalSerializer = JsonElement.serializer() override val descriptor: SerialDescriptor = internalSerializer.descriptor 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 c3b68fb990..681c44f03f 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 @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.buttons import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder @@ -25,8 +26,8 @@ object QuizKeyboardButtonPollType : KeyboardButtonPollType { override val type: String = quizPollType } -@Serializer(KeyboardButtonPollType::class) -internal object KeyboardButtonPollTypeSerializer : KSerializer { +@RiskFeature +object KeyboardButtonPollTypeSerializer : KSerializer { private val internalSerializer = JsonElement.serializer() override val descriptor: SerialDescriptor = internalSerializer.descriptor diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardMarkupSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardMarkupSerializer.kt index f30a9a16c1..328d9f61fa 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardMarkupSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardMarkupSerializer.kt @@ -1,12 +1,13 @@ package dev.inmo.tgbotapi.types.buttons +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -@Serializer(KeyboardMarkup::class) -internal object KeyboardMarkupSerializer : KSerializer { +@RiskFeature +object KeyboardMarkupSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor( KeyboardMarkup::class.toString(), diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt index 56a0c78fb1..e02220a3ad 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.UnknownChatType import dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat import dev.inmo.tgbotapi.types.chat.abstracts.extended.UnknownExtendedChat import dev.inmo.tgbotapi.types.chat.extended.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer @@ -39,7 +40,6 @@ val String.asChatType ChatType.ChannelChatType.stringified -> ChatType.ChannelChatType else -> ChatType.UnknownChatType(this) } -@Serializer(ChatType::class) object ChatTypeSerializer : KSerializer { override val descriptor: SerialDescriptor = String.serializer().descriptor override fun deserialize(decoder: Decoder): ChatType { @@ -51,7 +51,8 @@ object ChatTypeSerializer : KSerializer { } } -internal object PreviewChatSerializer : KSerializer { +@RiskFeature +object PreviewChatSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) @@ -83,7 +84,8 @@ internal object PreviewChatSerializer : KSerializer { } } -internal object ExtendedChatSerializer : KSerializer { +@RiskFeature +object ExtendedChatSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) 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 2d59847d95..8feb10b0f0 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 @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.dice import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder @@ -55,8 +56,8 @@ data class CustomDiceAnimationType( get() = error("Custom dice animation type have unknown value limits") } -@Serializer(DiceAnimationType::class) -internal object DiceAnimationTypeSerializer : KSerializer { +@RiskFeature +object DiceAnimationTypeSerializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("DiceAnimationType", PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): DiceAnimationType { return when (val type = decoder.decodeString()) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt index 07a76c1d4c..78910be5b7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.FileUniqueId import dev.inmo.tgbotapi.types.fileUniqueIdField import dev.inmo.tgbotapi.types.files.abstracts.* +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer @@ -13,7 +14,8 @@ fun Photo.biggest(): PhotoSize? = maxByOrNull { it.resolution } -internal object PhotoSerializer : KSerializer by ListSerializer( +@RiskFeature +object PhotoSerializer : KSerializer by ListSerializer( PhotoSize.serializer() ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index 23534ec718..bce88fc7b9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.files import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.files.abstracts.* import dev.inmo.tgbotapi.utils.MimeType diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt index c5f0092c64..6cf7fc17b7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.games -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput +import dev.inmo.tgbotapi.CommonAbstracts.Titled import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.Photo 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 7707da1616..b0fcab5fd2 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 @@ -39,7 +39,6 @@ data class LiveLocation( override val proximityAlertRadius: Meters? = null ) : Location, Livable, ProximityAlertable, Headed -@Serializer(Location::class) object LocationSerializer : KSerializer { private val internalSerializer = JsonObject.serializer() override val descriptor: SerialDescriptor = internalSerializer.descriptor diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt index 3bf616a482..b2c85f828b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt @@ -31,8 +31,6 @@ internal class TelegramBotAPIMessageDeserializationStrategyClass : Deserializ return RawMessage.serializer().deserialize(decoder).asMessage as T } } -internal object TelegramBotAPIMessageDeserializationStrategy - : DeserializationStrategy by TelegramBotAPIMessageDeserializationStrategyClass() internal class TelegramBotAPIMessageDeserializeOnlySerializerClass : KSerializer { private val deserializer = TelegramBotAPIMessageDeserializationStrategyClass() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index 86bf6e23a6..ad5a3d089c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt index 6d97a72dda..be20aa5ca8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.message.content.abstracts -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.types.InputMedia.* diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt index 1d2c5f1e87..96c11864e2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AnimationContent.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendAnimation import dev.inmo.tgbotapi.types.ChatIdentifier diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt index 394fddcd16..c7d94ddce2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/AudioContent.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendAudio import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio import dev.inmo.tgbotapi.types.InputMedia.toInputMediaAudio +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AudioFile diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt index c656c2583f..5cae1a9cb5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/VoiceContent.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendVoice import dev.inmo.tgbotapi.types.ChatIdentifier diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/EncryptedElementSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/EncryptedElementSerializer.kt index 52cb81f1af..1c83f349c9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/EncryptedElementSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/EncryptedElementSerializer.kt @@ -35,7 +35,6 @@ val encryptedElementsClassesByTypes = mapOf( val EncryptedPassportElement.type: String get() = encryptedElementsClassesByTypes.keys.firstOrNull { encryptedElementsClassesByTypes.getValue(it).klass.isInstance(this) } ?: "unknown" -@Serializer(EncryptedPassportElement::class) object EncryptedElementSerializer : KSerializer { private val jsonSerializer = JsonObject.serializer() override val descriptor: SerialDescriptor = jsonSerializer.descriptor diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/ShippingOption.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/ShippingOption.kt index bc62f67c2f..5bb102aeca 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/ShippingOption.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/ShippingOption.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.payments import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.payments.abstracts.Priced +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer @@ -16,6 +17,7 @@ data class ShippingOption( override val prices: List ) : Priced -internal object LabeledPricesSerializer : KSerializer> by ListSerializer( +@RiskFeature +object LabeledPricesSerializer : KSerializer> by ListSerializer( LabeledPrice.serializer() ) 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 80b283109e..48535529b6 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,11 @@ package dev.inmo.tgbotapi.types.polls import com.soywiz.klock.DateTime import com.soywiz.klock.TimeSpan -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor @@ -142,8 +143,8 @@ data class QuizPoll( override val scheduledCloseInfo: ScheduledCloseInfo? = null ) : Poll, TextedInput -@Serializer(Poll::class) -internal object PollSerializer : KSerializer { +@RiskFeature +object PollSerializer : KSerializer { override val descriptor: SerialDescriptor get() = RawPoll.serializer().descriptor diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/PollOption.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/PollOption.kt index 2333b63613..0e7ab5d758 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/PollOption.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/PollOption.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.polls import dev.inmo.tgbotapi.types.textField import dev.inmo.tgbotapi.types.votesCountField +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder @@ -21,7 +22,8 @@ data class SimplePollOption ( override val votes: Int ) : PollOption() -internal object PollOptionSerializer : KSerializer { +@RiskFeature +object PollOptionSerializer : KSerializer { override val descriptor: SerialDescriptor = SimplePollOption.serializer().descriptor override fun deserialize(decoder: Decoder): PollOption = SimplePollOption.serializer().deserialize( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/InlineQueryUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/InlineQueryUpdate.kt index 10b4e61230..7d46a186f7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/InlineQueryUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/InlineQueryUpdate.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.update -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.update.abstracts.Update diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/Update.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/Update.kt index 0ea6f4c49f..a06e2be315 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/Update.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/Update.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.update.abstracts import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.update.RawUpdate +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor @@ -20,7 +21,8 @@ data class UnknownUpdate( val rawJson: JsonElement ) : Update -internal object UpdateSerializerWithoutSerialization : KSerializer { +@RiskFeature +object UpdateSerializerWithoutSerialization : KSerializer { override val descriptor: SerialDescriptor = JsonElement.serializer().descriptor override fun deserialize(decoder: Decoder): Update = UpdateDeserializationStrategy.deserialize(decoder) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/MimeType.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/MimeType.kt index 04ec695668..6864b0fa05 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/MimeType.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/MimeType.kt @@ -19,8 +19,8 @@ fun buildMimeType(raw: String): MimeType = mimesCache.getOrPut(raw) { createMimeType(raw) } -@Serializer(MimeType::class) -internal object MimeTypeSerializer : KSerializer { +@RiskFeature +object MimeTypeSerializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("mimeType", PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): MimeType { 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 a74b53a5e9..6160f91965 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,16 +1,16 @@ package dev.inmo.tgbotapi.utils.internal -import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* 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 TextSourcesList.joinSubSourcesMarkdownV2() = joinToString("") { it.markdownV2 } -private fun List.joinSubSourcesHtml() = joinToString("") { +private fun TextSourcesList.joinSubSourcesHtml() = joinToString("") { it.html } diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt index 2b308fbf7d..e10fef23e7 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/BotActionTests.kt @@ -9,6 +9,7 @@ import kotlin.test.assertEquals class BotActionTests { @Serializable data class Example( + @Serializable(BotActionSerializer::class) val botAction: BotAction ) 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 7092b31e0f..e0e1e32550 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 @@ -39,7 +39,7 @@ internal val testTextEntities = listOf( ) ) -fun List.testTextSources() { +fun TextSourcesList.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 d817adc266..98f36e7b28 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 @@ -39,7 +39,7 @@ class StringFormattingTests { @Test fun testThatCreatingOfStringWithSimpleDSLWorksCorrectly() { - val sources: List = regular("It ") + + val sources: TextSourcesList = 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 b3f0158702..d544f21c70 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 @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.TestsJsonFormat import dev.inmo.tgbotapi.extensions.utils.formatting.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import kotlinx.serialization.builtins.ListSerializer import kotlin.test.Test import kotlin.test.assertEquals diff --git a/tgbotapi.extensions.api/build.gradle b/tgbotapi.extensions.api/build.gradle index 1d557205fe..f47a5e111c 100644 --- a/tgbotapi.extensions.api/build.gradle +++ b/tgbotapi.extensions.api/build.gradle @@ -29,10 +29,8 @@ repositories { } kotlin { - jvm { - compilations.main.kotlinOptions.useIR = true - } - js(BOTH) { + jvm() + js(IR) { browser() nodejs() } diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt index bee5f5c67b..e549143781 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt @@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.extensions.api.answers import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery import dev.inmo.tgbotapi.types.InlineQueryIdentifier suspend fun TelegramBot.answerInlineQuery( @@ -19,7 +18,7 @@ suspend fun TelegramBot.answerInlineQuery( ) suspend fun TelegramBot.answerInlineQuery( - inlineQuery: InlineQuery, + inlineQuery: dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery, results: List = emptyList(), cachedTime: Int? = null, isPersonal: Boolean? = null, 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 81d730056a..4ed6b395f0 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 @@ -1,10 +1,11 @@ package dev.inmo.tgbotapi.extensions.api.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedWithTextSources 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.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -42,7 +43,7 @@ suspend fun TelegramBot.editMessageCaption( suspend fun TelegramBot.editMessageCaption( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null ) = execute( EditChatMessageCaption(chatId, messageId, entities, replyMarkup) @@ -51,7 +52,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 d30a399696..1ee2224a42 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 @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.caption import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.caption.EditInlineMessageCaption import dev.inmo.tgbotapi.types.InlineMessageIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -15,6 +16,6 @@ suspend fun TelegramBot.editMessageCaption( suspend fun TelegramBot.editMessageCaption( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: TextSourcesList, 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 0fe253ff0b..fa94728a9e 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 @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.text import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList 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.editMessageText( suspend fun TelegramBot.editMessageText( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute( @@ -51,14 +52,14 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( chat: Chat, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup) suspend fun TelegramBot.editMessageText( message: ContentMessage, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = 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 3d734cf303..1293e4a3fa 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 @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.text import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText import dev.inmo.tgbotapi.types.InlineMessageIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -16,7 +17,7 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: TextSourcesList, 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 82e04f308e..c7f2281461 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 @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.CopyMessage import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -86,7 +87,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, toChatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -99,7 +100,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, toChatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -110,7 +111,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, toChat: Chat, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -121,7 +122,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, toChat: Chat, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -131,7 +132,7 @@ suspend inline fun TelegramBot.copyMessage( suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, message: Message, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -141,7 +142,7 @@ suspend inline fun TelegramBot.copyMessage( suspend inline fun TelegramBot.copyMessage( toChat: Chat, message: Message, - entities: List, + entities: TextSourcesList, 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 6c30653a50..30447010b2 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 @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -60,7 +61,7 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -72,7 +73,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -84,7 +85,7 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendMessage( chat: Chat, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -95,7 +96,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendTextMessage( chat: Chat, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -123,7 +124,7 @@ suspend inline fun TelegramBot.reply( ) suspend inline fun TelegramBot.reply( to: Message, - entities: List, + entities: TextSourcesList, 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 058b2a57b1..df6646a8b0 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendAnimation import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -144,7 +145,7 @@ suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -171,7 +172,7 @@ suspend fun TelegramBot.sendAnimation( suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: AnimationFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -187,7 +188,7 @@ suspend fun TelegramBot.sendAnimation( chat: Chat, animation: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -200,7 +201,7 @@ suspend fun TelegramBot.sendAnimation( suspend fun TelegramBot.sendAnimation( chat: Chat, animation: AnimationFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -214,7 +215,7 @@ suspend inline fun TelegramBot.replyWithAnimation( to: Message, animation: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -238,7 +239,7 @@ suspend inline fun TelegramBot.replyWithAnimation( suspend inline fun TelegramBot.replyWithAnimation( to: Message, animation: AnimationFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -250,7 +251,7 @@ suspend inline fun TelegramBot.replyWithAnimation( suspend inline fun TelegramBot.reply( to: Message, animation: AnimationFile, - entities: List, + entities: TextSourcesList, 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 019e8ec048..f19f3ea605 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendAudio import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -121,7 +122,7 @@ suspend inline fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, performer: String? = null, title: String? = null, @@ -149,7 +150,7 @@ suspend inline fun TelegramBot.sendAudio( chat: Chat, audio: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, performer: String? = null, title: String? = null, @@ -162,7 +163,7 @@ suspend inline fun TelegramBot.sendAudio( suspend inline fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: AudioFile, - entities: List, + entities: TextSourcesList, title: String? = audio.title, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -173,7 +174,7 @@ suspend inline fun TelegramBot.sendAudio( suspend inline fun TelegramBot.sendAudio( chat: Chat, audio: AudioFile, - entities: List, + entities: TextSourcesList, title: String? = audio.title, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -185,7 +186,7 @@ suspend inline fun TelegramBot.replyWithAudio( to: Message, audio: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, performer: String? = null, title: String? = null, @@ -197,7 +198,7 @@ suspend inline fun TelegramBot.replyWithAudio( suspend inline fun TelegramBot.replyWithAudio( to: Message, audio: AudioFile, - entities: List, + entities: TextSourcesList, title: String? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -207,7 +208,7 @@ suspend inline fun TelegramBot.replyWithAudio( suspend inline fun TelegramBot.reply( to: Message, audio: AudioFile, - entities: List, + entities: TextSourcesList, 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 88be4feb78..a06dbc9ab9 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendDocument import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -115,7 +116,7 @@ suspend inline fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -139,7 +140,7 @@ suspend inline fun TelegramBot.sendDocument( chat: Chat, document: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -150,7 +151,7 @@ suspend inline fun TelegramBot.sendDocument( suspend inline fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: DocumentFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -163,7 +164,7 @@ suspend inline fun TelegramBot.sendDocument( suspend inline fun TelegramBot.sendDocument( chat: Chat, document: DocumentFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -175,7 +176,7 @@ suspend inline fun TelegramBot.replyWithDocument( to: Message, document: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, @@ -185,7 +186,7 @@ suspend inline fun TelegramBot.replyWithDocument( suspend inline fun TelegramBot.replyWithDocument( to: Message, document: DocumentFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, @@ -195,7 +196,7 @@ suspend inline fun TelegramBot.replyWithDocument( suspend inline fun TelegramBot.reply( to: Message, document: DocumentFile, - entities: List, + entities: TextSourcesList, 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 565098825e..872ef23507 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendPhoto import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -101,7 +102,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -121,7 +122,7 @@ suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -131,7 +132,7 @@ suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -141,7 +142,7 @@ suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -151,7 +152,7 @@ suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.replyWithPhoto( to: Message, fileId: InputFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null @@ -160,7 +161,7 @@ suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.replyWithPhoto( to: Message, photo: Photo, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null @@ -169,7 +170,7 @@ suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.reply( to: Message, photo: Photo, - entities: List, + entities: TextSourcesList, 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 a11bb412a8..5bcc1085c9 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVideo import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -119,7 +120,7 @@ suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -147,7 +148,7 @@ suspend inline fun TelegramBot.sendVideo( suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: VideoFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -158,7 +159,7 @@ suspend inline fun TelegramBot.sendVideo( chat: Chat, video: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -172,7 +173,7 @@ suspend inline fun TelegramBot.sendVideo( suspend inline fun TelegramBot.sendVideo( chat: Chat, video: VideoFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -183,7 +184,7 @@ suspend inline fun TelegramBot.replyWithVideo( to: Message, video: InputFile, thumb: InputFile? = null, - entities: List, + entities: TextSourcesList, duration: Long? = null, width: Int? = null, height: Int? = null, @@ -195,7 +196,7 @@ suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.replyWithVideo( to: Message, video: VideoFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null @@ -204,7 +205,7 @@ suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.reply( to: Message, video: VideoFile, - entities: List, + entities: TextSourcesList, 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 4f8566aa4f..6024220d4b 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVoice import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -106,7 +107,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: InputFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -128,7 +129,7 @@ suspend inline fun TelegramBot.sendVoice( suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: InputFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -139,7 +140,7 @@ suspend inline fun TelegramBot.sendVoice( suspend inline fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: VoiceFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -151,7 +152,7 @@ suspend inline fun TelegramBot.sendVoice( suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: VoiceFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -161,7 +162,7 @@ suspend inline fun TelegramBot.sendVoice( suspend inline fun TelegramBot.replyWithVoice( to: Message, voice: InputFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -171,7 +172,7 @@ suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.replyWithVoice( to: Message, voice: VoiceFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null @@ -180,7 +181,7 @@ suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.reply( to: Message, voice: VoiceFile, - entities: List, + entities: TextSourcesList, 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 a69923e6ad..2662d17013 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -161,7 +162,7 @@ suspend inline fun TelegramBot.sendQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, - entities: List, + entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -180,7 +181,7 @@ suspend inline fun TelegramBot.sendQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, - entities: List, + entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -198,7 +199,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: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -216,7 +217,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: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -291,7 +292,7 @@ suspend inline fun TelegramBot.replyWithQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, - entities: List, + entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -306,7 +307,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: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.extensions.behaviour_builder/build.gradle b/tgbotapi.extensions.behaviour_builder/build.gradle index ffa6a93381..c733bd1258 100644 --- a/tgbotapi.extensions.behaviour_builder/build.gradle +++ b/tgbotapi.extensions.behaviour_builder/build.gradle @@ -29,10 +29,8 @@ repositories { } kotlin { - jvm { - compilations.main.kotlinOptions.useIR = true - } - js(BOTH) { + jvm() + js(IR) { browser() nodejs() } diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt index c3de533c8e..c5afff5667 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt @@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate import dev.inmo.tgbotapi.requests.abstracts.Request -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery import kotlinx.coroutines.flow.toList @@ -14,7 +13,7 @@ private suspend fun BehaviourContext.waitInlineQueries( count: Int = 1, initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - mapper: suspend InlineQuery.() -> O? + mapper: suspend dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.() -> O? ): List = expectFlow( initRequest, count, @@ -24,7 +23,7 @@ private suspend fun BehaviourContext.waitInlineQueries( }.toList().toList() -private suspend inline fun BehaviourContext.waitInlines( +private suspend inline fun BehaviourContext.waitInlines( count: Int = 1, initRequest: Request<*>? = null, noinline errorFactory: NullableRequestBuilder<*> = { null }, @@ -49,7 +48,7 @@ suspend fun BehaviourContext.waitAnyInlineQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: InlineQueryMapper? = null + filter: InlineQueryMapper? = null ) = waitInlines(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitBaseInlineQuery( diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt index bc55ed4afd..621d1fd8bb 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt @@ -5,11 +5,10 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery -internal suspend inline fun BehaviourContext.onInlineQuery( +internal suspend inline fun BehaviourContext.onInlineQuery( includeFilterByChatInBehaviourSubContext: Boolean = true, noinline additionalFilter: (suspend (T) -> Boolean)? = null, noinline scenarioReceiver: BehaviourContextAndTypeReceiver @@ -37,8 +36,8 @@ internal suspend inline fun BehaviourContext.onInlineQ suspend fun BehaviourContext.onAnyInlineQuery( includeFilterByChatInBehaviourSubContext: Boolean = true, - additionalFilter: (suspend (InlineQuery) -> Boolean)? = null, - scenarioReceiver: BehaviourContextAndTypeReceiver + additionalFilter: (suspend (dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery) -> Boolean)? = null, + scenarioReceiver: BehaviourContextAndTypeReceiver ) = onInlineQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) diff --git a/tgbotapi.extensions.utils/build.gradle b/tgbotapi.extensions.utils/build.gradle index dca79235e1..810af2519b 100644 --- a/tgbotapi.extensions.utils/build.gradle +++ b/tgbotapi.extensions.utils/build.gradle @@ -29,10 +29,8 @@ repositories { } kotlin { - jvm { - compilations.main.kotlinOptions.useIR = true - } - js(BOTH) { + jvm() + js(IR) { browser() nodejs() } 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 73a2ee2f23..ac235c56df 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 @@ -1,7 +1,8 @@ @file:Suppress("NOTHING_TO_INLINE", "unused", "UNCHECKED_CAST") package dev.inmo.tgbotapi.extensions.utils -import dev.inmo.tgbotapi.CommonAbstracts.* + +import dev.inmo.tgbotapi.CommonAbstracts.CommonSendInvoiceData import dev.inmo.tgbotapi.requests.send.payments.SendInvoice import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.CallbackQuery.* @@ -18,14 +19,11 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.* import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery import dev.inmo.tgbotapi.types.InputMedia.* 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.actions.* import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* @@ -57,1257 +55,2104 @@ import dev.inmo.tgbotapi.utils.PreviewFeature @PreviewFeature inline fun Chat.asBot(): Bot? = this as? Bot + @PreviewFeature inline fun Chat.requireBot(): Bot = this as Bot + @PreviewFeature inline fun Chat.asCommonBot(): CommonBot? = this as? CommonBot + @PreviewFeature inline fun Chat.requireCommonBot(): CommonBot = this as CommonBot + @PreviewFeature inline fun Chat.asCommonUser(): CommonUser? = this as? CommonUser + @PreviewFeature inline fun Chat.requireCommonUser(): CommonUser = this as CommonUser + @PreviewFeature inline fun Chat.asExtendedBot(): ExtendedBot? = this as? ExtendedBot + @PreviewFeature inline fun Chat.requireExtendedBot(): ExtendedBot = this as ExtendedBot + @PreviewFeature inline fun Chat.asUser(): User? = this as? User + @PreviewFeature inline fun Chat.requireUser(): User = this as User + @PreviewFeature inline fun Chat.asChannelChat(): ChannelChat? = this as? ChannelChat + @PreviewFeature inline fun Chat.requireChannelChat(): ChannelChat = this as ChannelChat + @PreviewFeature inline fun Chat.asGroupChat(): GroupChat? = this as? GroupChat + @PreviewFeature inline fun Chat.requireGroupChat(): GroupChat = this as GroupChat + @PreviewFeature inline fun Chat.asPrivateChat(): PrivateChat? = this as? PrivateChat + @PreviewFeature inline fun Chat.requirePrivateChat(): PrivateChat = this as PrivateChat + @PreviewFeature inline fun Chat.asPublicChat(): PublicChat? = this as? PublicChat + @PreviewFeature inline fun Chat.requirePublicChat(): PublicChat = this as PublicChat + @PreviewFeature inline fun Chat.asSuperPublicChat(): SuperPublicChat? = this as? SuperPublicChat + @PreviewFeature inline fun Chat.requireSuperPublicChat(): SuperPublicChat = this as SuperPublicChat + @PreviewFeature inline fun Chat.asSupergroupChat(): SupergroupChat? = this as? SupergroupChat + @PreviewFeature inline fun Chat.requireSupergroupChat(): SupergroupChat = this as SupergroupChat + @PreviewFeature inline fun Chat.asUnknownChatType(): UnknownChatType? = this as? UnknownChatType + @PreviewFeature inline fun Chat.requireUnknownChatType(): UnknownChatType = this as UnknownChatType + @PreviewFeature inline fun Chat.asUsernameChat(): UsernameChat? = this as? UsernameChat + @PreviewFeature inline fun Chat.requireUsernameChat(): UsernameChat = this as UsernameChat + @PreviewFeature inline fun Chat.asExtendedChannelChat(): ExtendedChannelChat? = this as? ExtendedChannelChat + @PreviewFeature inline fun Chat.requireExtendedChannelChat(): ExtendedChannelChat = this as ExtendedChannelChat + @PreviewFeature inline fun Chat.asExtendedChat(): ExtendedChat? = this as? ExtendedChat + @PreviewFeature inline fun Chat.requireExtendedChat(): ExtendedChat = this as ExtendedChat + @PreviewFeature inline fun Chat.asExtendedGroupChat(): ExtendedGroupChat? = this as? ExtendedGroupChat + @PreviewFeature inline fun Chat.requireExtendedGroupChat(): ExtendedGroupChat = this as ExtendedGroupChat + @PreviewFeature inline fun Chat.asExtendedPrivateChat(): ExtendedPrivateChat? = this as? ExtendedPrivateChat + @PreviewFeature inline fun Chat.requireExtendedPrivateChat(): ExtendedPrivateChat = this as ExtendedPrivateChat + @PreviewFeature inline fun Chat.asExtendedPublicChat(): ExtendedPublicChat? = this as? ExtendedPublicChat + @PreviewFeature inline fun Chat.requireExtendedPublicChat(): ExtendedPublicChat = this as ExtendedPublicChat + @PreviewFeature inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? ExtendedSupergroupChat + @PreviewFeature inline fun Chat.requireExtendedSupergroupChat(): ExtendedSupergroupChat = this as ExtendedSupergroupChat + @PreviewFeature inline fun CallbackQuery.asDataCallbackQuery(): DataCallbackQuery? = this as? DataCallbackQuery + @PreviewFeature inline fun CallbackQuery.requireDataCallbackQuery(): DataCallbackQuery = this as DataCallbackQuery + @PreviewFeature -inline fun CallbackQuery.asGameShortNameCallbackQuery(): GameShortNameCallbackQuery? = this as? GameShortNameCallbackQuery +inline fun CallbackQuery.asGameShortNameCallbackQuery(): GameShortNameCallbackQuery? = + this as? GameShortNameCallbackQuery + @PreviewFeature -inline fun CallbackQuery.requireGameShortNameCallbackQuery(): GameShortNameCallbackQuery = this as GameShortNameCallbackQuery +inline fun CallbackQuery.requireGameShortNameCallbackQuery(): GameShortNameCallbackQuery = + this as GameShortNameCallbackQuery + @PreviewFeature -inline fun CallbackQuery.asInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery? = this as? InlineMessageIdCallbackQuery +inline fun CallbackQuery.asInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery? = + this as? InlineMessageIdCallbackQuery + @PreviewFeature -inline fun CallbackQuery.requireInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery = this as InlineMessageIdCallbackQuery +inline fun CallbackQuery.requireInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery = + this as InlineMessageIdCallbackQuery + @PreviewFeature -inline fun CallbackQuery.asInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery? = this as? InlineMessageIdDataCallbackQuery +inline fun CallbackQuery.asInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery? = + this as? InlineMessageIdDataCallbackQuery + @PreviewFeature -inline fun CallbackQuery.requireInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery = this as InlineMessageIdDataCallbackQuery +inline fun CallbackQuery.requireInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery = + this as InlineMessageIdDataCallbackQuery + @PreviewFeature -inline fun CallbackQuery.asInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery? = this as? InlineMessageIdGameShortNameCallbackQuery +inline fun CallbackQuery.asInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery? = + this as? InlineMessageIdGameShortNameCallbackQuery + @PreviewFeature -inline fun CallbackQuery.requireInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery = this as InlineMessageIdGameShortNameCallbackQuery +inline fun CallbackQuery.requireInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery = + this as InlineMessageIdGameShortNameCallbackQuery + @PreviewFeature inline fun CallbackQuery.asMessageCallbackQuery(): MessageCallbackQuery? = this as? MessageCallbackQuery + @PreviewFeature inline fun CallbackQuery.requireMessageCallbackQuery(): MessageCallbackQuery = this as MessageCallbackQuery + @PreviewFeature inline fun CallbackQuery.asMessageDataCallbackQuery(): MessageDataCallbackQuery? = this as? MessageDataCallbackQuery + @PreviewFeature inline fun CallbackQuery.requireMessageDataCallbackQuery(): MessageDataCallbackQuery = this as MessageDataCallbackQuery + @PreviewFeature -inline fun CallbackQuery.asMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery? = this as? MessageGameShortNameCallbackQuery +inline fun CallbackQuery.asMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery? = + this as? MessageGameShortNameCallbackQuery + @PreviewFeature -inline fun CallbackQuery.requireMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery = this as MessageGameShortNameCallbackQuery +inline fun CallbackQuery.requireMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery = + this as MessageGameShortNameCallbackQuery + @PreviewFeature inline fun CallbackQuery.asUnknownCallbackQueryType(): UnknownCallbackQueryType? = this as? UnknownCallbackQueryType + @PreviewFeature inline fun CallbackQuery.requireUnknownCallbackQueryType(): UnknownCallbackQueryType = this as UnknownCallbackQueryType + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorDataField(): PassportElementErrorDataField? = this as? PassportElementErrorDataField +inline fun PassportElementError.asPassportElementErrorDataField(): PassportElementErrorDataField? = + this as? PassportElementErrorDataField + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorDataField(): PassportElementErrorDataField = this as PassportElementErrorDataField +inline fun PassportElementError.requirePassportElementErrorDataField(): PassportElementErrorDataField = + this as PassportElementErrorDataField + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorFile(): PassportElementErrorFile? = this as? PassportElementErrorFile +inline fun PassportElementError.asPassportElementErrorFile(): PassportElementErrorFile? = + this as? PassportElementErrorFile + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorFile(): PassportElementErrorFile = this as PassportElementErrorFile +inline fun PassportElementError.requirePassportElementErrorFile(): PassportElementErrorFile = + this as PassportElementErrorFile + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorFiles(): PassportElementErrorFiles? = this as? PassportElementErrorFiles +inline fun PassportElementError.asPassportElementErrorFiles(): PassportElementErrorFiles? = + this as? PassportElementErrorFiles + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorFiles(): PassportElementErrorFiles = this as PassportElementErrorFiles +inline fun PassportElementError.requirePassportElementErrorFiles(): PassportElementErrorFiles = + this as PassportElementErrorFiles + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorFrontSide(): PassportElementErrorFrontSide? = this as? PassportElementErrorFrontSide +inline fun PassportElementError.asPassportElementErrorFrontSide(): PassportElementErrorFrontSide? = + this as? PassportElementErrorFrontSide + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorFrontSide(): PassportElementErrorFrontSide = this as PassportElementErrorFrontSide +inline fun PassportElementError.requirePassportElementErrorFrontSide(): PassportElementErrorFrontSide = + this as PassportElementErrorFrontSide + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorReverseSide(): PassportElementErrorReverseSide? = this as? PassportElementErrorReverseSide +inline fun PassportElementError.asPassportElementErrorReverseSide(): PassportElementErrorReverseSide? = + this as? PassportElementErrorReverseSide + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorReverseSide(): PassportElementErrorReverseSide = this as PassportElementErrorReverseSide +inline fun PassportElementError.requirePassportElementErrorReverseSide(): PassportElementErrorReverseSide = + this as PassportElementErrorReverseSide + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorSelfie(): PassportElementErrorSelfie? = this as? PassportElementErrorSelfie +inline fun PassportElementError.asPassportElementErrorSelfie(): PassportElementErrorSelfie? = + this as? PassportElementErrorSelfie + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorSelfie(): PassportElementErrorSelfie = this as PassportElementErrorSelfie +inline fun PassportElementError.requirePassportElementErrorSelfie(): PassportElementErrorSelfie = + this as PassportElementErrorSelfie + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorTranslationFile(): PassportElementErrorTranslationFile? = this as? PassportElementErrorTranslationFile +inline fun PassportElementError.asPassportElementErrorTranslationFile(): PassportElementErrorTranslationFile? = + this as? PassportElementErrorTranslationFile + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorTranslationFile(): PassportElementErrorTranslationFile = this as PassportElementErrorTranslationFile +inline fun PassportElementError.requirePassportElementErrorTranslationFile(): PassportElementErrorTranslationFile = + this as PassportElementErrorTranslationFile + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorTranslationFiles(): PassportElementErrorTranslationFiles? = this as? PassportElementErrorTranslationFiles +inline fun PassportElementError.asPassportElementErrorTranslationFiles(): PassportElementErrorTranslationFiles? = + this as? PassportElementErrorTranslationFiles + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorTranslationFiles(): PassportElementErrorTranslationFiles = this as PassportElementErrorTranslationFiles +inline fun PassportElementError.requirePassportElementErrorTranslationFiles(): PassportElementErrorTranslationFiles = + this as PassportElementErrorTranslationFiles + @PreviewFeature -inline fun PassportElementError.asPassportElementErrorUnspecified(): PassportElementErrorUnspecified? = this as? PassportElementErrorUnspecified +inline fun PassportElementError.asPassportElementErrorUnspecified(): PassportElementErrorUnspecified? = + this as? PassportElementErrorUnspecified + @PreviewFeature -inline fun PassportElementError.requirePassportElementErrorUnspecified(): PassportElementErrorUnspecified = this as PassportElementErrorUnspecified +inline fun PassportElementError.requirePassportElementErrorUnspecified(): PassportElementErrorUnspecified = + this as PassportElementErrorUnspecified + @PreviewFeature -inline fun PassportElementError.asPassportElementFileError(): PassportElementFileError? = this as? PassportElementFileError +inline fun PassportElementError.asPassportElementFileError(): PassportElementFileError? = + this as? PassportElementFileError + @PreviewFeature -inline fun PassportElementError.requirePassportElementFileError(): PassportElementFileError = this as PassportElementFileError +inline fun PassportElementError.requirePassportElementFileError(): PassportElementFileError = + this as PassportElementFileError + @PreviewFeature -inline fun PassportElementError.asPassportElementFilesError(): PassportElementFilesError? = this as? PassportElementFilesError +inline fun PassportElementError.asPassportElementFilesError(): PassportElementFilesError? = + this as? PassportElementFilesError + @PreviewFeature -inline fun PassportElementError.requirePassportElementFilesError(): PassportElementFilesError = this as PassportElementFilesError +inline fun PassportElementError.requirePassportElementFilesError(): PassportElementFilesError = + this as PassportElementFilesError + @PreviewFeature -inline fun PassportElementError.asPassportMultipleElementsError(): PassportMultipleElementsError? = this as? PassportMultipleElementsError +inline fun PassportElementError.asPassportMultipleElementsError(): PassportMultipleElementsError? = + this as? PassportMultipleElementsError + @PreviewFeature -inline fun PassportElementError.requirePassportMultipleElementsError(): PassportMultipleElementsError = this as PassportMultipleElementsError +inline fun PassportElementError.requirePassportMultipleElementsError(): PassportMultipleElementsError = + this as PassportMultipleElementsError + @PreviewFeature -inline fun PassportElementError.asPassportSingleElementError(): PassportSingleElementError? = this as? PassportSingleElementError +inline fun PassportElementError.asPassportSingleElementError(): PassportSingleElementError? = + this as? PassportSingleElementError + @PreviewFeature -inline fun PassportElementError.requirePassportSingleElementError(): PassportSingleElementError = this as PassportSingleElementError +inline fun PassportElementError.requirePassportSingleElementError(): PassportSingleElementError = + this as PassportSingleElementError + @PreviewFeature -inline fun PassportElementError.asUnknownPassportElementError(): UnknownPassportElementError? = this as? UnknownPassportElementError +inline fun PassportElementError.asUnknownPassportElementError(): UnknownPassportElementError? = + this as? UnknownPassportElementError + @PreviewFeature -inline fun PassportElementError.requireUnknownPassportElementError(): UnknownPassportElementError = this as UnknownPassportElementError +inline fun PassportElementError.requireUnknownPassportElementError(): UnknownPassportElementError = + this as UnknownPassportElementError + @PreviewFeature inline fun EncryptedPassportElement.asBankStatement(): BankStatement? = this as? BankStatement + @PreviewFeature inline fun EncryptedPassportElement.requireBankStatement(): BankStatement = this as BankStatement + @PreviewFeature inline fun EncryptedPassportElement.asCommonPassport(): CommonPassport? = this as? CommonPassport + @PreviewFeature inline fun EncryptedPassportElement.requireCommonPassport(): CommonPassport = this as CommonPassport + @PreviewFeature inline fun EncryptedPassportElement.asDriverLicense(): DriverLicense? = this as? DriverLicense + @PreviewFeature inline fun EncryptedPassportElement.requireDriverLicense(): DriverLicense = this as DriverLicense + @PreviewFeature inline fun EncryptedPassportElement.asEmail(): Email? = this as? Email + @PreviewFeature inline fun EncryptedPassportElement.requireEmail(): Email = this as Email + @PreviewFeature inline fun EncryptedPassportElement.asEncryptedAddress(): EncryptedAddress? = this as? EncryptedAddress + @PreviewFeature inline fun EncryptedPassportElement.requireEncryptedAddress(): EncryptedAddress = this as EncryptedAddress + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPersonalDetails(): EncryptedPersonalDetails? = this as? EncryptedPersonalDetails +inline fun EncryptedPassportElement.asEncryptedPersonalDetails(): EncryptedPersonalDetails? = + this as? EncryptedPersonalDetails + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPersonalDetails(): EncryptedPersonalDetails = this as EncryptedPersonalDetails +inline fun EncryptedPassportElement.requireEncryptedPersonalDetails(): EncryptedPersonalDetails = + this as EncryptedPersonalDetails + @PreviewFeature inline fun EncryptedPassportElement.asIdentityCard(): IdentityCard? = this as? IdentityCard + @PreviewFeature inline fun EncryptedPassportElement.requireIdentityCard(): IdentityCard = this as IdentityCard + @PreviewFeature inline fun EncryptedPassportElement.asInternalPassport(): InternalPassport? = this as? InternalPassport + @PreviewFeature inline fun EncryptedPassportElement.requireInternalPassport(): InternalPassport = this as InternalPassport + @PreviewFeature inline fun EncryptedPassportElement.asPassport(): Passport? = this as? Passport + @PreviewFeature inline fun EncryptedPassportElement.requirePassport(): Passport = this as Passport + @PreviewFeature inline fun EncryptedPassportElement.asPassportRegistration(): PassportRegistration? = this as? PassportRegistration + @PreviewFeature inline fun EncryptedPassportElement.requirePassportRegistration(): PassportRegistration = this as PassportRegistration + @PreviewFeature inline fun EncryptedPassportElement.asPhoneNumber(): PhoneNumber? = this as? PhoneNumber + @PreviewFeature inline fun EncryptedPassportElement.requirePhoneNumber(): PhoneNumber = this as PhoneNumber + @PreviewFeature inline fun EncryptedPassportElement.asRentalAgreement(): RentalAgreement? = this as? RentalAgreement + @PreviewFeature inline fun EncryptedPassportElement.requireRentalAgreement(): RentalAgreement = this as RentalAgreement + @PreviewFeature inline fun EncryptedPassportElement.asTemporaryRegistration(): TemporaryRegistration? = this as? TemporaryRegistration + @PreviewFeature -inline fun EncryptedPassportElement.requireTemporaryRegistration(): TemporaryRegistration = this as TemporaryRegistration +inline fun EncryptedPassportElement.requireTemporaryRegistration(): TemporaryRegistration = + this as TemporaryRegistration + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithTranslatableFilesCollection(): EncryptedPassportElementWithTranslatableFilesCollection? = this as? EncryptedPassportElementWithTranslatableFilesCollection +inline fun EncryptedPassportElement.asEncryptedPassportElementWithTranslatableFilesCollection(): EncryptedPassportElementWithTranslatableFilesCollection? = + this as? EncryptedPassportElementWithTranslatableFilesCollection + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithTranslatableFilesCollection(): EncryptedPassportElementWithTranslatableFilesCollection = this as EncryptedPassportElementWithTranslatableFilesCollection +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithTranslatableFilesCollection(): EncryptedPassportElementWithTranslatableFilesCollection = + this as EncryptedPassportElementWithTranslatableFilesCollection + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithTranslatableIDDocument(): EncryptedPassportElementWithTranslatableIDDocument? = this as? EncryptedPassportElementWithTranslatableIDDocument +inline fun EncryptedPassportElement.asEncryptedPassportElementWithTranslatableIDDocument(): EncryptedPassportElementWithTranslatableIDDocument? = + this as? EncryptedPassportElementWithTranslatableIDDocument + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithTranslatableIDDocument(): EncryptedPassportElementWithTranslatableIDDocument = this as EncryptedPassportElementWithTranslatableIDDocument +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithTranslatableIDDocument(): EncryptedPassportElementWithTranslatableIDDocument = + this as EncryptedPassportElementWithTranslatableIDDocument + @PreviewFeature inline fun EncryptedPassportElement.asUtilityBill(): UtilityBill? = this as? UtilityBill + @PreviewFeature inline fun EncryptedPassportElement.requireUtilityBill(): UtilityBill = this as UtilityBill + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithFilesCollection(): EncryptedPassportElementWithFilesCollection? = this as? EncryptedPassportElementWithFilesCollection +inline fun EncryptedPassportElement.asEncryptedPassportElementWithFilesCollection(): EncryptedPassportElementWithFilesCollection? = + this as? EncryptedPassportElementWithFilesCollection + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithFilesCollection(): EncryptedPassportElementWithFilesCollection = this as EncryptedPassportElementWithFilesCollection +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithFilesCollection(): EncryptedPassportElementWithFilesCollection = + this as EncryptedPassportElementWithFilesCollection + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementTranslatable(): EncryptedPassportElementTranslatable? = this as? EncryptedPassportElementTranslatable +inline fun EncryptedPassportElement.asEncryptedPassportElementTranslatable(): EncryptedPassportElementTranslatable? = + this as? EncryptedPassportElementTranslatable + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementTranslatable(): EncryptedPassportElementTranslatable = this as EncryptedPassportElementTranslatable +inline fun EncryptedPassportElement.requireEncryptedPassportElementTranslatable(): EncryptedPassportElementTranslatable = + this as EncryptedPassportElementTranslatable + @PreviewFeature -inline fun EncryptedPassportElement.asUnknownEncryptedPassportElement(): UnknownEncryptedPassportElement? = this as? UnknownEncryptedPassportElement +inline fun EncryptedPassportElement.asUnknownEncryptedPassportElement(): UnknownEncryptedPassportElement? = + this as? UnknownEncryptedPassportElement + @PreviewFeature -inline fun EncryptedPassportElement.requireUnknownEncryptedPassportElement(): UnknownEncryptedPassportElement = this as UnknownEncryptedPassportElement +inline fun EncryptedPassportElement.requireUnknownEncryptedPassportElement(): UnknownEncryptedPassportElement = + this as UnknownEncryptedPassportElement + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithData(): EncryptedPassportElementWithData? = this as? EncryptedPassportElementWithData +inline fun EncryptedPassportElement.asEncryptedPassportElementWithData(): EncryptedPassportElementWithData? = + this as? EncryptedPassportElementWithData + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithData(): EncryptedPassportElementWithData = this as EncryptedPassportElementWithData +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithData(): EncryptedPassportElementWithData = + this as EncryptedPassportElementWithData + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithEmail(): EncryptedPassportElementWithEmail? = this as? EncryptedPassportElementWithEmail +inline fun EncryptedPassportElement.asEncryptedPassportElementWithEmail(): EncryptedPassportElementWithEmail? = + this as? EncryptedPassportElementWithEmail + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithEmail(): EncryptedPassportElementWithEmail = this as EncryptedPassportElementWithEmail +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithEmail(): EncryptedPassportElementWithEmail = + this as EncryptedPassportElementWithEmail + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithFrontSide(): EncryptedPassportElementWithFrontSide? = this as? EncryptedPassportElementWithFrontSide +inline fun EncryptedPassportElement.asEncryptedPassportElementWithFrontSide(): EncryptedPassportElementWithFrontSide? = + this as? EncryptedPassportElementWithFrontSide + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithFrontSide(): EncryptedPassportElementWithFrontSide = this as EncryptedPassportElementWithFrontSide +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithFrontSide(): EncryptedPassportElementWithFrontSide = + this as EncryptedPassportElementWithFrontSide + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithPhoneNumber(): EncryptedPassportElementWithPhoneNumber? = this as? EncryptedPassportElementWithPhoneNumber +inline fun EncryptedPassportElement.asEncryptedPassportElementWithPhoneNumber(): EncryptedPassportElementWithPhoneNumber? = + this as? EncryptedPassportElementWithPhoneNumber + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithPhoneNumber(): EncryptedPassportElementWithPhoneNumber = this as EncryptedPassportElementWithPhoneNumber +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithPhoneNumber(): EncryptedPassportElementWithPhoneNumber = + this as EncryptedPassportElementWithPhoneNumber + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithReverseSide(): EncryptedPassportElementWithReverseSide? = this as? EncryptedPassportElementWithReverseSide +inline fun EncryptedPassportElement.asEncryptedPassportElementWithReverseSide(): EncryptedPassportElementWithReverseSide? = + this as? EncryptedPassportElementWithReverseSide + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithReverseSide(): EncryptedPassportElementWithReverseSide = this as EncryptedPassportElementWithReverseSide +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithReverseSide(): EncryptedPassportElementWithReverseSide = + this as EncryptedPassportElementWithReverseSide + @PreviewFeature -inline fun EncryptedPassportElement.asEncryptedPassportElementWithSelfie(): EncryptedPassportElementWithSelfie? = this as? EncryptedPassportElementWithSelfie +inline fun EncryptedPassportElement.asEncryptedPassportElementWithSelfie(): EncryptedPassportElementWithSelfie? = + this as? EncryptedPassportElementWithSelfie + @PreviewFeature -inline fun EncryptedPassportElement.requireEncryptedPassportElementWithSelfie(): EncryptedPassportElementWithSelfie = this as EncryptedPassportElementWithSelfie +inline fun EncryptedPassportElement.requireEncryptedPassportElementWithSelfie(): EncryptedPassportElementWithSelfie = + this as EncryptedPassportElementWithSelfie + @PreviewFeature inline fun SecureValue.asAddressSecureValue(): AddressSecureValue? = this as? AddressSecureValue + @PreviewFeature inline fun SecureValue.requireAddressSecureValue(): AddressSecureValue = this as AddressSecureValue + @PreviewFeature inline fun SecureValue.asBankStatementSecureValue(): BankStatementSecureValue? = this as? BankStatementSecureValue + @PreviewFeature inline fun SecureValue.requireBankStatementSecureValue(): BankStatementSecureValue = this as BankStatementSecureValue + @PreviewFeature inline fun SecureValue.asCommonPassportSecureValue(): CommonPassportSecureValue? = this as? CommonPassportSecureValue + @PreviewFeature inline fun SecureValue.requireCommonPassportSecureValue(): CommonPassportSecureValue = this as CommonPassportSecureValue + @PreviewFeature inline fun SecureValue.asDriverLicenseSecureValue(): DriverLicenseSecureValue? = this as? DriverLicenseSecureValue + @PreviewFeature inline fun SecureValue.requireDriverLicenseSecureValue(): DriverLicenseSecureValue = this as DriverLicenseSecureValue + @PreviewFeature inline fun SecureValue.asIdentityCardSecureValue(): IdentityCardSecureValue? = this as? IdentityCardSecureValue + @PreviewFeature inline fun SecureValue.requireIdentityCardSecureValue(): IdentityCardSecureValue = this as IdentityCardSecureValue + @PreviewFeature -inline fun SecureValue.asIdentityWithReverseSideSecureValue(): IdentityWithReverseSideSecureValue? = this as? IdentityWithReverseSideSecureValue +inline fun SecureValue.asIdentityWithReverseSideSecureValue(): IdentityWithReverseSideSecureValue? = + this as? IdentityWithReverseSideSecureValue + @PreviewFeature -inline fun SecureValue.requireIdentityWithReverseSideSecureValue(): IdentityWithReverseSideSecureValue = this as IdentityWithReverseSideSecureValue +inline fun SecureValue.requireIdentityWithReverseSideSecureValue(): IdentityWithReverseSideSecureValue = + this as IdentityWithReverseSideSecureValue + @PreviewFeature -inline fun SecureValue.asInternalPassportSecureValue(): InternalPassportSecureValue? = this as? InternalPassportSecureValue +inline fun SecureValue.asInternalPassportSecureValue(): InternalPassportSecureValue? = + this as? InternalPassportSecureValue + @PreviewFeature -inline fun SecureValue.requireInternalPassportSecureValue(): InternalPassportSecureValue = this as InternalPassportSecureValue +inline fun SecureValue.requireInternalPassportSecureValue(): InternalPassportSecureValue = + this as InternalPassportSecureValue + @PreviewFeature inline fun SecureValue.asOtherDocumentsSecureValue(): OtherDocumentsSecureValue? = this as? OtherDocumentsSecureValue + @PreviewFeature inline fun SecureValue.requireOtherDocumentsSecureValue(): OtherDocumentsSecureValue = this as OtherDocumentsSecureValue + @PreviewFeature -inline fun SecureValue.asPassportRegistrationSecureValue(): PassportRegistrationSecureValue? = this as? PassportRegistrationSecureValue +inline fun SecureValue.asPassportRegistrationSecureValue(): PassportRegistrationSecureValue? = + this as? PassportRegistrationSecureValue + @PreviewFeature -inline fun SecureValue.requirePassportRegistrationSecureValue(): PassportRegistrationSecureValue = this as PassportRegistrationSecureValue +inline fun SecureValue.requirePassportRegistrationSecureValue(): PassportRegistrationSecureValue = + this as PassportRegistrationSecureValue + @PreviewFeature inline fun SecureValue.asPassportSecureValue(): PassportSecureValue? = this as? PassportSecureValue + @PreviewFeature inline fun SecureValue.requirePassportSecureValue(): PassportSecureValue = this as PassportSecureValue + @PreviewFeature inline fun SecureValue.asPersonalDetailsSecureValue(): PersonalDetailsSecureValue? = this as? PersonalDetailsSecureValue + @PreviewFeature -inline fun SecureValue.requirePersonalDetailsSecureValue(): PersonalDetailsSecureValue = this as PersonalDetailsSecureValue +inline fun SecureValue.requirePersonalDetailsSecureValue(): PersonalDetailsSecureValue = + this as PersonalDetailsSecureValue + @PreviewFeature inline fun SecureValue.asRentalAgreementSecureValue(): RentalAgreementSecureValue? = this as? RentalAgreementSecureValue + @PreviewFeature -inline fun SecureValue.requireRentalAgreementSecureValue(): RentalAgreementSecureValue = this as RentalAgreementSecureValue +inline fun SecureValue.requireRentalAgreementSecureValue(): RentalAgreementSecureValue = + this as RentalAgreementSecureValue + @PreviewFeature -inline fun SecureValue.asTemporalRegistrationSecureValue(): TemporalRegistrationSecureValue? = this as? TemporalRegistrationSecureValue +inline fun SecureValue.asTemporalRegistrationSecureValue(): TemporalRegistrationSecureValue? = + this as? TemporalRegistrationSecureValue + @PreviewFeature -inline fun SecureValue.requireTemporalRegistrationSecureValue(): TemporalRegistrationSecureValue = this as TemporalRegistrationSecureValue +inline fun SecureValue.requireTemporalRegistrationSecureValue(): TemporalRegistrationSecureValue = + this as TemporalRegistrationSecureValue + @PreviewFeature inline fun SecureValue.asUtilityBillSecureValue(): UtilityBillSecureValue? = this as? UtilityBillSecureValue + @PreviewFeature inline fun SecureValue.requireUtilityBillSecureValue(): UtilityBillSecureValue = this as UtilityBillSecureValue + @PreviewFeature inline fun SecureValue.asSecureValueIdentity(): SecureValueIdentity? = this as? SecureValueIdentity + @PreviewFeature inline fun SecureValue.requireSecureValueIdentity(): SecureValueIdentity = this as SecureValueIdentity + @PreviewFeature inline fun SecureValue.asSecureValueWithData(): SecureValueWithData? = this as? SecureValueWithData + @PreviewFeature inline fun SecureValue.requireSecureValueWithData(): SecureValueWithData = this as SecureValueWithData + @PreviewFeature inline fun SecureValue.asSecureValueWithFiles(): SecureValueWithFiles? = this as? SecureValueWithFiles + @PreviewFeature inline fun SecureValue.requireSecureValueWithFiles(): SecureValueWithFiles = this as SecureValueWithFiles + @PreviewFeature inline fun SecureValue.asSecureValueWithReverseSide(): SecureValueWithReverseSide? = this as? SecureValueWithReverseSide + @PreviewFeature -inline fun SecureValue.requireSecureValueWithReverseSide(): SecureValueWithReverseSide = this as SecureValueWithReverseSide +inline fun SecureValue.requireSecureValueWithReverseSide(): SecureValueWithReverseSide = + this as SecureValueWithReverseSide + @PreviewFeature -inline fun SecureValue.asSecureValueWithTranslations(): SecureValueWithTranslations? = this as? SecureValueWithTranslations +inline fun SecureValue.asSecureValueWithTranslations(): SecureValueWithTranslations? = + this as? SecureValueWithTranslations + @PreviewFeature -inline fun SecureValue.requireSecureValueWithTranslations(): SecureValueWithTranslations = this as SecureValueWithTranslations +inline fun SecureValue.requireSecureValueWithTranslations(): SecureValueWithTranslations = + this as SecureValueWithTranslations + @PreviewFeature -inline fun Message.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl? = this as? AnonymousGroupContentMessageImpl +inline fun Message.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl? = + this as? AnonymousGroupContentMessageImpl + @PreviewFeature -inline fun Message.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl = this as AnonymousGroupContentMessageImpl +inline fun Message.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl = + this as AnonymousGroupContentMessageImpl + @PreviewFeature -inline fun Message.asChannelContentMessageImpl(): ChannelContentMessageImpl? = this as? ChannelContentMessageImpl +inline fun Message.asChannelContentMessageImpl(): ChannelContentMessageImpl? = + this as? ChannelContentMessageImpl + @PreviewFeature -inline fun Message.requireChannelContentMessageImpl(): ChannelContentMessageImpl = this as ChannelContentMessageImpl +inline fun Message.requireChannelContentMessageImpl(): ChannelContentMessageImpl = + this as ChannelContentMessageImpl + @PreviewFeature -inline fun Message.asFromChannelGroupContentMessageImpl(): FromChannelGroupContentMessageImpl? = this as? FromChannelGroupContentMessageImpl +inline fun Message.asFromChannelGroupContentMessageImpl(): FromChannelGroupContentMessageImpl? = + this as? FromChannelGroupContentMessageImpl + @PreviewFeature -inline fun Message.requireFromChannelGroupContentMessageImpl(): FromChannelGroupContentMessageImpl = this as FromChannelGroupContentMessageImpl +inline fun Message.requireFromChannelGroupContentMessageImpl(): FromChannelGroupContentMessageImpl = + this as FromChannelGroupContentMessageImpl + @PreviewFeature inline fun Message.asPassportMessage(): PassportMessage? = this as? PassportMessage + @PreviewFeature inline fun Message.requirePassportMessage(): PassportMessage = this as PassportMessage + @PreviewFeature -inline fun Message.asPrivateContentMessageImpl(): PrivateContentMessageImpl? = this as? PrivateContentMessageImpl +inline fun Message.asPrivateContentMessageImpl(): PrivateContentMessageImpl? = + this as? PrivateContentMessageImpl + @PreviewFeature -inline fun Message.requirePrivateContentMessageImpl(): PrivateContentMessageImpl = this as PrivateContentMessageImpl +inline fun Message.requirePrivateContentMessageImpl(): PrivateContentMessageImpl = + this as PrivateContentMessageImpl + @PreviewFeature -inline fun Message.asChannelEventMessage(): ChannelEventMessage? = this as? ChannelEventMessage +inline fun Message.asChannelEventMessage(): ChannelEventMessage? = + this as? ChannelEventMessage + @PreviewFeature -inline fun Message.requireChannelEventMessage(): ChannelEventMessage = this as ChannelEventMessage +inline fun Message.requireChannelEventMessage(): ChannelEventMessage = + this as ChannelEventMessage + @PreviewFeature -inline fun Message.asChannelMediaGroupMessage(): ChannelMediaGroupMessage? = this as? ChannelMediaGroupMessage +inline fun Message.asChannelMediaGroupMessage(): ChannelMediaGroupMessage? = + this as? ChannelMediaGroupMessage + @PreviewFeature -inline fun Message.requireChannelMediaGroupMessage(): ChannelMediaGroupMessage = this as ChannelMediaGroupMessage +inline fun Message.requireChannelMediaGroupMessage(): ChannelMediaGroupMessage = + this as ChannelMediaGroupMessage + @PreviewFeature -inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = this as? CommonGroupEventMessage +inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = + this as? CommonGroupEventMessage + @PreviewFeature -inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage = this as CommonGroupEventMessage +inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage = + this as CommonGroupEventMessage + @PreviewFeature -inline fun Message.asCommonMediaGroupMessage(): CommonMediaGroupMessage? = this as? CommonMediaGroupMessage +inline fun Message.asCommonMediaGroupMessage(): CommonMediaGroupMessage? = + this as? CommonMediaGroupMessage + @PreviewFeature -inline fun Message.requireCommonMediaGroupMessage(): CommonMediaGroupMessage = this as CommonMediaGroupMessage +inline fun Message.requireCommonMediaGroupMessage(): CommonMediaGroupMessage = + this as CommonMediaGroupMessage + @PreviewFeature -inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = this as? CommonSupergroupEventMessage +inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = + this as? CommonSupergroupEventMessage + @PreviewFeature -inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = this as CommonSupergroupEventMessage +inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = + this as CommonSupergroupEventMessage + @PreviewFeature -inline fun Message.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage? = this as? AnonymousGroupContentMessage +inline fun Message.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage? = + this as? AnonymousGroupContentMessage + @PreviewFeature -inline fun Message.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage = this as AnonymousGroupContentMessage +inline fun Message.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage = + this as AnonymousGroupContentMessage + @PreviewFeature -inline fun Message.asChannelContentMessage(): ChannelContentMessageImpl? = this as? ChannelContentMessageImpl +inline fun Message.asChannelContentMessage(): ChannelContentMessageImpl? = + this as? ChannelContentMessageImpl + @PreviewFeature -inline fun Message.requireChannelContentMessage(): ChannelContentMessageImpl = this as ChannelContentMessageImpl +inline fun Message.requireChannelContentMessage(): ChannelContentMessageImpl = + this as ChannelContentMessageImpl + @PreviewFeature inline fun Message.asChatEventMessage(): ChatEventMessage? = this as? ChatEventMessage + @PreviewFeature inline fun Message.requireChatEventMessage(): ChatEventMessage = this as ChatEventMessage + @PreviewFeature -inline fun Message.asCommonGroupContentMessage(): CommonGroupContentMessage? = this as? CommonGroupContentMessage +inline fun Message.asCommonGroupContentMessage(): CommonGroupContentMessage? = + this as? CommonGroupContentMessage + @PreviewFeature -inline fun Message.requireCommonGroupContentMessage(): CommonGroupContentMessage = this as CommonGroupContentMessage +inline fun Message.requireCommonGroupContentMessage(): CommonGroupContentMessage = + this as CommonGroupContentMessage + @PreviewFeature inline fun Message.asCommonMessage(): CommonMessage? = this as? CommonMessage + @PreviewFeature inline fun Message.requireCommonMessage(): CommonMessage = this as CommonMessage + @PreviewFeature inline fun Message.asContentMessage(): ContentMessage? = this as? ContentMessage + @PreviewFeature inline fun Message.requireContentMessage(): ContentMessage = this as ContentMessage + @PreviewFeature -inline fun Message.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage? = this as? FromChannelGroupContentMessage +inline fun Message.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage? = + this as? FromChannelGroupContentMessage + @PreviewFeature -inline fun Message.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage = this as FromChannelGroupContentMessage +inline fun Message.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage = + this as FromChannelGroupContentMessage + @PreviewFeature inline fun Message.asGroupEventMessage(): GroupEventMessage? = this as? GroupEventMessage + @PreviewFeature inline fun Message.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage + @PreviewFeature -inline fun Message.asGroupContentMessage(): GroupContentMessage? = this as? GroupContentMessage +inline fun Message.asGroupContentMessage(): GroupContentMessage? = + this as? GroupContentMessage + @PreviewFeature -inline fun Message.requireGroupContentMessage(): GroupContentMessage = this as GroupContentMessage +inline fun Message.requireGroupContentMessage(): GroupContentMessage = + this as GroupContentMessage + @PreviewFeature -inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = this as? MediaGroupMessage +inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = + this as? MediaGroupMessage + @PreviewFeature -inline fun Message.requireMediaGroupMessage(): MediaGroupMessage = this as MediaGroupMessage +inline fun Message.requireMediaGroupMessage(): MediaGroupMessage = + this as MediaGroupMessage + @PreviewFeature inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage + @PreviewFeature inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage + @PreviewFeature inline fun Message.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage + @PreviewFeature inline fun Message.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage + @PreviewFeature inline fun Message.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage + @PreviewFeature inline fun Message.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage + @PreviewFeature -inline fun Message.asPrivateContentMessage(): PrivateContentMessage? = this as? PrivateContentMessage +inline fun Message.asPrivateContentMessage(): PrivateContentMessage? = + this as? PrivateContentMessage + @PreviewFeature -inline fun Message.requirePrivateContentMessage(): PrivateContentMessage = this as PrivateContentMessage +inline fun Message.requirePrivateContentMessage(): PrivateContentMessage = + this as PrivateContentMessage + @PreviewFeature -inline fun Message.asPublicContentMessage(): PublicContentMessage? = this as? PublicContentMessage +inline fun Message.asPublicContentMessage(): PublicContentMessage? = + this as? PublicContentMessage + @PreviewFeature -inline fun Message.requirePublicContentMessage(): PublicContentMessage = this as PublicContentMessage +inline fun Message.requirePublicContentMessage(): PublicContentMessage = + this as PublicContentMessage + @PreviewFeature inline fun Message.asSignedMessage(): SignedMessage? = this as? SignedMessage + @PreviewFeature inline fun Message.requireSignedMessage(): SignedMessage = this as SignedMessage + @PreviewFeature -inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? = this as? SupergroupEventMessage +inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? = + this as? SupergroupEventMessage + @PreviewFeature -inline fun Message.requireSupergroupEventMessage(): SupergroupEventMessage = this as SupergroupEventMessage +inline fun Message.requireSupergroupEventMessage(): SupergroupEventMessage = + this as SupergroupEventMessage + @PreviewFeature inline fun Message.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType + @PreviewFeature inline fun Message.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType + @PreviewFeature -inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = this as? PossiblySentViaBotCommonMessage +inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = + this as? PossiblySentViaBotCommonMessage + @PreviewFeature -inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = this as PossiblySentViaBotCommonMessage +inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = + this as PossiblySentViaBotCommonMessage + @PreviewFeature inline fun Message.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage + @PreviewFeature inline fun Message.requireFromUserMessage(): FromUserMessage = this as FromUserMessage + @PreviewFeature inline fun BotAction.asFindLocationAction(): FindLocationAction? = this as? FindLocationAction + @PreviewFeature inline fun BotAction.requireFindLocationAction(): FindLocationAction = this as FindLocationAction + @PreviewFeature inline fun BotAction.asRecordVoiceAction(): RecordVoiceAction? = this as? RecordVoiceAction + @PreviewFeature inline fun BotAction.requireRecordVoiceAction(): RecordVoiceAction = this as RecordVoiceAction + @PreviewFeature inline fun BotAction.asRecordVideoAction(): RecordVideoAction? = this as? RecordVideoAction + @PreviewFeature inline fun BotAction.requireRecordVideoAction(): RecordVideoAction = this as RecordVideoAction + @PreviewFeature inline fun BotAction.asRecordVideoNoteAction(): RecordVideoNoteAction? = this as? RecordVideoNoteAction + @PreviewFeature inline fun BotAction.requireRecordVideoNoteAction(): RecordVideoNoteAction = this as RecordVideoNoteAction + @PreviewFeature inline fun BotAction.asTypingAction(): TypingAction? = this as? TypingAction + @PreviewFeature inline fun BotAction.requireTypingAction(): TypingAction = this as TypingAction + @PreviewFeature inline fun BotAction.asUploadVoiceAction(): UploadVoiceAction? = this as? UploadVoiceAction + @PreviewFeature inline fun BotAction.requireUploadVoiceAction(): UploadVoiceAction = this as UploadVoiceAction + @PreviewFeature inline fun BotAction.asUploadDocumentAction(): UploadDocumentAction? = this as? UploadDocumentAction + @PreviewFeature inline fun BotAction.requireUploadDocumentAction(): UploadDocumentAction = this as UploadDocumentAction + @PreviewFeature inline fun BotAction.asUploadPhotoAction(): UploadPhotoAction? = this as? UploadPhotoAction + @PreviewFeature inline fun BotAction.requireUploadPhotoAction(): UploadPhotoAction = this as UploadPhotoAction + @PreviewFeature inline fun BotAction.asUploadVideoAction(): UploadVideoAction? = this as? UploadVideoAction + @PreviewFeature inline fun BotAction.requireUploadVideoAction(): UploadVideoAction = this as UploadVideoAction + @PreviewFeature inline fun BotAction.asUploadVideoNoteAction(): UploadVideoNoteAction? = this as? UploadVideoNoteAction + @PreviewFeature inline fun BotAction.requireUploadVideoNoteAction(): UploadVideoNoteAction = this as UploadVideoNoteAction + @PreviewFeature -inline fun InlineQuery.asBaseInlineQuery(): BaseInlineQuery? = this as? BaseInlineQuery +inline fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.asBaseInlineQuery(): BaseInlineQuery? = + this as? BaseInlineQuery + @PreviewFeature -inline fun InlineQuery.requireBaseInlineQuery(): BaseInlineQuery = this as BaseInlineQuery +inline fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.requireBaseInlineQuery(): BaseInlineQuery = + this as BaseInlineQuery + @PreviewFeature -inline fun InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = this as? LocationInlineQuery +inline fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = + this as? LocationInlineQuery + @PreviewFeature -inline fun InlineQuery.requireLocationInlineQuery(): LocationInlineQuery = this as LocationInlineQuery +inline fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.requireLocationInlineQuery(): LocationInlineQuery = + this as LocationInlineQuery + @PreviewFeature -inline fun InputMessageContent.asInputContactMessageContent(): InputContactMessageContent? = this as? InputContactMessageContent +inline fun InputMessageContent.asInputContactMessageContent(): InputContactMessageContent? = + this as? InputContactMessageContent + @PreviewFeature -inline fun InputMessageContent.requireInputContactMessageContent(): InputContactMessageContent = this as InputContactMessageContent +inline fun InputMessageContent.requireInputContactMessageContent(): InputContactMessageContent = + this as InputContactMessageContent + @PreviewFeature -inline fun InputMessageContent.asInputLocationMessageContent(): InputLocationMessageContent? = this as? InputLocationMessageContent +inline fun InputMessageContent.asInputLocationMessageContent(): InputLocationMessageContent? = + this as? InputLocationMessageContent + @PreviewFeature -inline fun InputMessageContent.requireInputLocationMessageContent(): InputLocationMessageContent = this as InputLocationMessageContent +inline fun InputMessageContent.requireInputLocationMessageContent(): InputLocationMessageContent = + this as InputLocationMessageContent + @PreviewFeature inline fun InputMessageContent.asInputTextMessageContent(): InputTextMessageContent? = this as? InputTextMessageContent + @PreviewFeature -inline fun InputMessageContent.requireInputTextMessageContent(): InputTextMessageContent = this as InputTextMessageContent +inline fun InputMessageContent.requireInputTextMessageContent(): InputTextMessageContent = + this as InputTextMessageContent + @PreviewFeature -inline fun InputMessageContent.asInputVenueMessageContent(): InputVenueMessageContent? = this as? InputVenueMessageContent +inline fun InputMessageContent.asInputVenueMessageContent(): InputVenueMessageContent? = + this as? InputVenueMessageContent + @PreviewFeature -inline fun InputMessageContent.requireInputVenueMessageContent(): InputVenueMessageContent = this as InputVenueMessageContent +inline fun InputMessageContent.requireInputVenueMessageContent(): InputVenueMessageContent = + this as InputVenueMessageContent + @PreviewFeature -inline fun InputMessageContent.asInputInvoiceMessageContent(): InputInvoiceMessageContent? = this as? InputInvoiceMessageContent +inline fun InputMessageContent.asInputInvoiceMessageContent(): InputInvoiceMessageContent? = + this as? InputInvoiceMessageContent + @PreviewFeature -inline fun InputMessageContent.requireInputInvoiceMessageContent(): InputInvoiceMessageContent = this as InputInvoiceMessageContent +inline fun InputMessageContent.requireInputInvoiceMessageContent(): InputInvoiceMessageContent = + this as InputInvoiceMessageContent + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultArticle(): InlineQueryResultArticle? = this as? InlineQueryResultArticle + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultArticle(): InlineQueryResultArticle = this as InlineQueryResultArticle +inline fun InlineQueryResult.requireInlineQueryResultArticle(): InlineQueryResultArticle = + this as InlineQueryResultArticle + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultContact(): InlineQueryResultContact? = this as? InlineQueryResultContact + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultContact(): InlineQueryResultContact = this as InlineQueryResultContact +inline fun InlineQueryResult.requireInlineQueryResultContact(): InlineQueryResultContact = + this as InlineQueryResultContact + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultGame(): InlineQueryResultGame? = this as? InlineQueryResultGame + @PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultGame(): InlineQueryResultGame = this as InlineQueryResultGame + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultLocation(): InlineQueryResultLocation? = this as? InlineQueryResultLocation +inline fun InlineQueryResult.asInlineQueryResultLocation(): InlineQueryResultLocation? = + this as? InlineQueryResultLocation + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultLocation(): InlineQueryResultLocation = this as InlineQueryResultLocation +inline fun InlineQueryResult.requireInlineQueryResultLocation(): InlineQueryResultLocation = + this as InlineQueryResultLocation + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultStickerCached(): InlineQueryResultStickerCached? = this as? InlineQueryResultStickerCached +inline fun InlineQueryResult.asInlineQueryResultStickerCached(): InlineQueryResultStickerCached? = + this as? InlineQueryResultStickerCached + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultStickerCached(): InlineQueryResultStickerCached = this as InlineQueryResultStickerCached +inline fun InlineQueryResult.requireInlineQueryResultStickerCached(): InlineQueryResultStickerCached = + this as InlineQueryResultStickerCached + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVenue(): InlineQueryResultVenue? = this as? InlineQueryResultVenue + @PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVenue(): InlineQueryResultVenue = this as InlineQueryResultVenue + @PreviewFeature -inline fun InlineQueryResult.asDescribedInlineQueryResult(): DescribedInlineQueryResult? = this as? DescribedInlineQueryResult +inline fun InlineQueryResult.asDescribedInlineQueryResult(): DescribedInlineQueryResult? = + this as? DescribedInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.requireDescribedInlineQueryResult(): DescribedInlineQueryResult = this as DescribedInlineQueryResult +inline fun InlineQueryResult.requireDescribedInlineQueryResult(): DescribedInlineQueryResult = + this as DescribedInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.asFileInlineQueryResult(): FileInlineQueryResult? = this as? FileInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.requireFileInlineQueryResult(): FileInlineQueryResult = this as FileInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.asOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult? = this as? OptionallyTitledInlineQueryResult +inline fun InlineQueryResult.asOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult? = + this as? OptionallyTitledInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.requireOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult = this as OptionallyTitledInlineQueryResult +inline fun InlineQueryResult.requireOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult = + this as OptionallyTitledInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.asSizedInlineQueryResult(): SizedInlineQueryResult? = this as? SizedInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.requireSizedInlineQueryResult(): SizedInlineQueryResult = this as SizedInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.asThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult? = this as? ThumbSizedInlineQueryResult +inline fun InlineQueryResult.asThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult? = + this as? ThumbSizedInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.requireThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult = this as ThumbSizedInlineQueryResult +inline fun InlineQueryResult.requireThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult = + this as ThumbSizedInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.asThumbedInlineQueryResult(): ThumbedInlineQueryResult? = this as? ThumbedInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.requireThumbedInlineQueryResult(): ThumbedInlineQueryResult = this as ThumbedInlineQueryResult +inline fun InlineQueryResult.requireThumbedInlineQueryResult(): ThumbedInlineQueryResult = + this as ThumbedInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.asThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult? = this as? ThumbedWithMimeTypeInlineQueryResult +inline fun InlineQueryResult.asThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult? = + this as? ThumbedWithMimeTypeInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.requireThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult = this as ThumbedWithMimeTypeInlineQueryResult +inline fun InlineQueryResult.requireThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult = + this as ThumbedWithMimeTypeInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.asTitledInlineQueryResult(): TitledInlineQueryResult? = this as? TitledInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.requireTitledInlineQueryResult(): TitledInlineQueryResult = this as TitledInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.asUrlInlineQueryResult(): UrlInlineQueryResult? = this as? UrlInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.requireUrlInlineQueryResult(): UrlInlineQueryResult = this as UrlInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.asWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult? = this as? WithInputMessageContentInlineQueryResult +inline fun InlineQueryResult.asWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult? = + this as? WithInputMessageContentInlineQueryResult + @PreviewFeature -inline fun InlineQueryResult.requireWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult = this as WithInputMessageContentInlineQueryResult +inline fun InlineQueryResult.requireWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult = + this as WithInputMessageContentInlineQueryResult + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultAudio(): InlineQueryResultAudio? = this as? InlineQueryResultAudio + @PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultAudio(): InlineQueryResultAudio = this as InlineQueryResultAudio + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultAudioCached(): InlineQueryResultAudioCached? = this as? InlineQueryResultAudioCached +inline fun InlineQueryResult.asInlineQueryResultAudioCached(): InlineQueryResultAudioCached? = + this as? InlineQueryResultAudioCached + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultAudioCached(): InlineQueryResultAudioCached = this as InlineQueryResultAudioCached +inline fun InlineQueryResult.requireInlineQueryResultAudioCached(): InlineQueryResultAudioCached = + this as InlineQueryResultAudioCached + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon? = this as? InlineQueryResultAudioCommon +inline fun InlineQueryResult.asInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon? = + this as? InlineQueryResultAudioCommon + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon = this as InlineQueryResultAudioCommon +inline fun InlineQueryResult.requireInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon = + this as InlineQueryResultAudioCommon + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultDocument(): InlineQueryResultDocument? = this as? InlineQueryResultDocument +inline fun InlineQueryResult.asInlineQueryResultDocument(): InlineQueryResultDocument? = + this as? InlineQueryResultDocument + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultDocument(): InlineQueryResultDocument = this as InlineQueryResultDocument +inline fun InlineQueryResult.requireInlineQueryResultDocument(): InlineQueryResultDocument = + this as InlineQueryResultDocument + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached? = this as? InlineQueryResultDocumentCached +inline fun InlineQueryResult.asInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached? = + this as? InlineQueryResultDocumentCached + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached = this as InlineQueryResultDocumentCached +inline fun InlineQueryResult.requireInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached = + this as InlineQueryResultDocumentCached + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon? = this as? InlineQueryResultDocumentCommon +inline fun InlineQueryResult.asInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon? = + this as? InlineQueryResultDocumentCommon + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon = this as InlineQueryResultDocumentCommon +inline fun InlineQueryResult.requireInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon = + this as InlineQueryResultDocumentCommon + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultGif(): InlineQueryResultGif? = this as? InlineQueryResultGif + @PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultGif(): InlineQueryResultGif = this as InlineQueryResultGif + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultGifCached(): InlineQueryResultGifCached? = this as? InlineQueryResultGifCached +inline fun InlineQueryResult.asInlineQueryResultGifCached(): InlineQueryResultGifCached? = + this as? InlineQueryResultGifCached + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultGifCached(): InlineQueryResultGifCached = this as InlineQueryResultGifCached +inline fun InlineQueryResult.requireInlineQueryResultGifCached(): InlineQueryResultGifCached = + this as InlineQueryResultGifCached + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultGifCommon(): InlineQueryResultGifCommon? = this as? InlineQueryResultGifCommon +inline fun InlineQueryResult.asInlineQueryResultGifCommon(): InlineQueryResultGifCommon? = + this as? InlineQueryResultGifCommon + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultGifCommon(): InlineQueryResultGifCommon = this as InlineQueryResultGifCommon +inline fun InlineQueryResult.requireInlineQueryResultGifCommon(): InlineQueryResultGifCommon = + this as InlineQueryResultGifCommon + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif? = this as? InlineQueryResultMpeg4Gif +inline fun InlineQueryResult.asInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif? = + this as? InlineQueryResultMpeg4Gif + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif = this as InlineQueryResultMpeg4Gif +inline fun InlineQueryResult.requireInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif = + this as InlineQueryResultMpeg4Gif + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached? = this as? InlineQueryResultMpeg4GifCached +inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached? = + this as? InlineQueryResultMpeg4GifCached + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached = this as InlineQueryResultMpeg4GifCached +inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached = + this as InlineQueryResultMpeg4GifCached + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon? = this as? InlineQueryResultMpeg4GifCommon +inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon? = + this as? InlineQueryResultMpeg4GifCommon + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon = this as InlineQueryResultMpeg4GifCommon +inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon = + this as InlineQueryResultMpeg4GifCommon + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultPhoto(): InlineQueryResultPhoto? = this as? InlineQueryResultPhoto + @PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultPhoto(): InlineQueryResultPhoto = this as InlineQueryResultPhoto + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached? = this as? InlineQueryResultPhotoCached +inline fun InlineQueryResult.asInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached? = + this as? InlineQueryResultPhotoCached + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached = this as InlineQueryResultPhotoCached +inline fun InlineQueryResult.requireInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached = + this as InlineQueryResultPhotoCached + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon? = this as? InlineQueryResultPhotoCommon +inline fun InlineQueryResult.asInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon? = + this as? InlineQueryResultPhotoCommon + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon = this as InlineQueryResultPhotoCommon +inline fun InlineQueryResult.requireInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon = + this as InlineQueryResultPhotoCommon + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVideo(): InlineQueryResultVideo? = this as? InlineQueryResultVideo + @PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVideo(): InlineQueryResultVideo = this as InlineQueryResultVideo + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultVideoCached(): InlineQueryResultVideoCached? = this as? InlineQueryResultVideoCached +inline fun InlineQueryResult.asInlineQueryResultVideoCached(): InlineQueryResultVideoCached? = + this as? InlineQueryResultVideoCached + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultVideoCached(): InlineQueryResultVideoCached = this as InlineQueryResultVideoCached +inline fun InlineQueryResult.requireInlineQueryResultVideoCached(): InlineQueryResultVideoCached = + this as InlineQueryResultVideoCached + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon? = this as? InlineQueryResultVideoCommon +inline fun InlineQueryResult.asInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon? = + this as? InlineQueryResultVideoCommon + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon = this as InlineQueryResultVideoCommon +inline fun InlineQueryResult.requireInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon = + this as InlineQueryResultVideoCommon + @PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVoice(): InlineQueryResultVoice? = this as? InlineQueryResultVoice + @PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVoice(): InlineQueryResultVoice = this as InlineQueryResultVoice + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached? = this as? InlineQueryResultVoiceCached +inline fun InlineQueryResult.asInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached? = + this as? InlineQueryResultVoiceCached + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached = this as InlineQueryResultVoiceCached +inline fun InlineQueryResult.requireInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached = + this as InlineQueryResultVoiceCached + @PreviewFeature -inline fun InlineQueryResult.asInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon? = this as? InlineQueryResultVoiceCommon +inline fun InlineQueryResult.asInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon? = + this as? InlineQueryResultVoiceCommon + @PreviewFeature -inline fun InlineQueryResult.requireInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon = this as InlineQueryResultVoiceCommon +inline fun InlineQueryResult.requireInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon = + this as InlineQueryResultVoiceCommon + @PreviewFeature inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember + @PreviewFeature inline fun ChatMember.requireCreatorChatMember(): CreatorChatMember = this as CreatorChatMember + @PreviewFeature inline fun ChatMember.asKickedChatMember(): KickedChatMember? = this as? KickedChatMember + @PreviewFeature inline fun ChatMember.requireKickedChatMember(): KickedChatMember = this as KickedChatMember + @PreviewFeature inline fun ChatMember.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember + @PreviewFeature inline fun ChatMember.requireLeftChatMember(): LeftChatMember = this as LeftChatMember + @PreviewFeature inline fun ChatMember.asMemberChatMember(): MemberChatMember? = this as? MemberChatMember + @PreviewFeature inline fun ChatMember.requireMemberChatMember(): MemberChatMember = this as MemberChatMember + @PreviewFeature inline fun ChatMember.asRestrictedChatMember(): RestrictedChatMember? = this as? RestrictedChatMember + @PreviewFeature inline fun ChatMember.requireRestrictedChatMember(): RestrictedChatMember = this as RestrictedChatMember + @PreviewFeature inline fun ChatMember.asAdministratorChatMember(): AdministratorChatMember? = this as? AdministratorChatMember + @PreviewFeature inline fun ChatMember.requireAdministratorChatMember(): AdministratorChatMember = this as AdministratorChatMember + @PreviewFeature inline fun ChatMember.asBannedChatMember(): BannedChatMember? = this as? BannedChatMember + @PreviewFeature inline fun ChatMember.requireBannedChatMember(): BannedChatMember = this as BannedChatMember + @PreviewFeature inline fun ChatMember.asSpecialRightsChatMember(): SpecialRightsChatMember? = this as? SpecialRightsChatMember + @PreviewFeature inline fun ChatMember.requireSpecialRightsChatMember(): SpecialRightsChatMember = this as SpecialRightsChatMember + @PreviewFeature -inline fun InputMedia.asAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia? = this as? AudioMediaGroupMemberInputMedia +inline fun InputMedia.asAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia? = + this as? AudioMediaGroupMemberInputMedia + @PreviewFeature -inline fun InputMedia.requireAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia = this as AudioMediaGroupMemberInputMedia +inline fun InputMedia.requireAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia = + this as AudioMediaGroupMemberInputMedia + @PreviewFeature -inline fun InputMedia.asDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia? = this as? DocumentMediaGroupMemberInputMedia +inline fun InputMedia.asDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia? = + this as? DocumentMediaGroupMemberInputMedia + @PreviewFeature -inline fun InputMedia.requireDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia = this as DocumentMediaGroupMemberInputMedia +inline fun InputMedia.requireDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia = + this as DocumentMediaGroupMemberInputMedia + @PreviewFeature inline fun InputMedia.asDuratedInputMedia(): DuratedInputMedia? = this as? DuratedInputMedia + @PreviewFeature inline fun InputMedia.requireDuratedInputMedia(): DuratedInputMedia = this as DuratedInputMedia + @PreviewFeature inline fun InputMedia.asInputMediaAnimation(): InputMediaAnimation? = this as? InputMediaAnimation + @PreviewFeature inline fun InputMedia.requireInputMediaAnimation(): InputMediaAnimation = this as InputMediaAnimation + @PreviewFeature inline fun InputMedia.asInputMediaAudio(): InputMediaAudio? = this as? InputMediaAudio + @PreviewFeature inline fun InputMedia.requireInputMediaAudio(): InputMediaAudio = this as InputMediaAudio + @PreviewFeature inline fun InputMedia.asInputMediaDocument(): InputMediaDocument? = this as? InputMediaDocument + @PreviewFeature inline fun InputMedia.requireInputMediaDocument(): InputMediaDocument = this as InputMediaDocument + @PreviewFeature inline fun InputMedia.asInputMediaPhoto(): InputMediaPhoto? = this as? InputMediaPhoto + @PreviewFeature inline fun InputMedia.requireInputMediaPhoto(): InputMediaPhoto = this as InputMediaPhoto + @PreviewFeature inline fun InputMedia.asInputMediaVideo(): InputMediaVideo? = this as? InputMediaVideo + @PreviewFeature inline fun InputMedia.requireInputMediaVideo(): InputMediaVideo = this as InputMediaVideo + @PreviewFeature inline fun InputMedia.asMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia? = this as? MediaGroupMemberInputMedia + @PreviewFeature -inline fun InputMedia.requireMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = this as MediaGroupMemberInputMedia +inline fun InputMedia.requireMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = + this as MediaGroupMemberInputMedia + @PreviewFeature inline fun InputMedia.asSizedInputMedia(): SizedInputMedia? = this as? SizedInputMedia + @PreviewFeature inline fun InputMedia.requireSizedInputMedia(): SizedInputMedia = this as SizedInputMedia + @PreviewFeature inline fun InputMedia.asThumbedInputMedia(): ThumbedInputMedia? = this as? ThumbedInputMedia + @PreviewFeature inline fun InputMedia.requireThumbedInputMedia(): ThumbedInputMedia = this as ThumbedInputMedia + @PreviewFeature inline fun InputMedia.asTitledInputMedia(): TitledInputMedia? = this as? TitledInputMedia + @PreviewFeature inline fun InputMedia.requireTitledInputMedia(): TitledInputMedia = this as TitledInputMedia + @PreviewFeature -inline fun InputMedia.asVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia? = this as? VisualMediaGroupMemberInputMedia +inline fun InputMedia.asVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia? = + this as? VisualMediaGroupMemberInputMedia + @PreviewFeature -inline fun InputMedia.requireVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia = this as VisualMediaGroupMemberInputMedia +inline fun InputMedia.requireVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia = + this as VisualMediaGroupMemberInputMedia + @PreviewFeature inline fun Update.asCallbackQueryUpdate(): CallbackQueryUpdate? = this as? CallbackQueryUpdate + @PreviewFeature inline fun Update.requireCallbackQueryUpdate(): CallbackQueryUpdate = this as CallbackQueryUpdate + @PreviewFeature inline fun Update.asChannelPostUpdate(): ChannelPostUpdate? = this as? ChannelPostUpdate + @PreviewFeature inline fun Update.requireChannelPostUpdate(): ChannelPostUpdate = this as ChannelPostUpdate + @PreviewFeature inline fun Update.asChosenInlineResultUpdate(): ChosenInlineResultUpdate? = this as? ChosenInlineResultUpdate + @PreviewFeature inline fun Update.requireChosenInlineResultUpdate(): ChosenInlineResultUpdate = this as ChosenInlineResultUpdate + @PreviewFeature inline fun Update.asEditChannelPostUpdate(): EditChannelPostUpdate? = this as? EditChannelPostUpdate + @PreviewFeature inline fun Update.requireEditChannelPostUpdate(): EditChannelPostUpdate = this as EditChannelPostUpdate + @PreviewFeature inline fun Update.asEditMessageUpdate(): EditMessageUpdate? = this as? EditMessageUpdate + @PreviewFeature inline fun Update.requireEditMessageUpdate(): EditMessageUpdate = this as EditMessageUpdate + @PreviewFeature inline fun Update.asInlineQueryUpdate(): InlineQueryUpdate? = this as? InlineQueryUpdate + @PreviewFeature inline fun Update.requireInlineQueryUpdate(): InlineQueryUpdate = this as InlineQueryUpdate + @PreviewFeature inline fun Update.asChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate? = this as? ChannelPostMediaGroupUpdate + @PreviewFeature -inline fun Update.requireChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate = this as ChannelPostMediaGroupUpdate +inline fun Update.requireChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate = + this as ChannelPostMediaGroupUpdate + @PreviewFeature -inline fun Update.asEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate? = this as? EditChannelPostMediaGroupUpdate +inline fun Update.asEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate? = + this as? EditChannelPostMediaGroupUpdate + @PreviewFeature -inline fun Update.requireEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate = this as EditChannelPostMediaGroupUpdate +inline fun Update.requireEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate = + this as EditChannelPostMediaGroupUpdate + @PreviewFeature inline fun Update.asEditMediaGroupUpdate(): EditMediaGroupUpdate? = this as? EditMediaGroupUpdate + @PreviewFeature inline fun Update.requireEditMediaGroupUpdate(): EditMediaGroupUpdate = this as EditMediaGroupUpdate + @PreviewFeature inline fun Update.asEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate? = this as? EditMessageMediaGroupUpdate + @PreviewFeature -inline fun Update.requireEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate = this as EditMessageMediaGroupUpdate +inline fun Update.requireEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate = + this as EditMessageMediaGroupUpdate + @PreviewFeature inline fun Update.asMediaGroupUpdate(): MediaGroupUpdate? = this as? MediaGroupUpdate + @PreviewFeature inline fun Update.requireMediaGroupUpdate(): MediaGroupUpdate = this as MediaGroupUpdate + @PreviewFeature inline fun Update.asMessageMediaGroupUpdate(): MessageMediaGroupUpdate? = this as? MessageMediaGroupUpdate + @PreviewFeature inline fun Update.requireMessageMediaGroupUpdate(): MessageMediaGroupUpdate = this as MessageMediaGroupUpdate + @PreviewFeature inline fun Update.asSentMediaGroupUpdate(): SentMediaGroupUpdate? = this as? SentMediaGroupUpdate + @PreviewFeature inline fun Update.requireSentMediaGroupUpdate(): SentMediaGroupUpdate = this as SentMediaGroupUpdate + @PreviewFeature inline fun Update.asMessageUpdate(): MessageUpdate? = this as? MessageUpdate + @PreviewFeature inline fun Update.requireMessageUpdate(): MessageUpdate = this as MessageUpdate + @PreviewFeature inline fun Update.asPollAnswerUpdate(): PollAnswerUpdate? = this as? PollAnswerUpdate + @PreviewFeature inline fun Update.requirePollAnswerUpdate(): PollAnswerUpdate = this as PollAnswerUpdate + @PreviewFeature inline fun Update.asPollUpdate(): PollUpdate? = this as? PollUpdate + @PreviewFeature inline fun Update.requirePollUpdate(): PollUpdate = this as PollUpdate + @PreviewFeature inline fun Update.asPreCheckoutQueryUpdate(): PreCheckoutQueryUpdate? = this as? PreCheckoutQueryUpdate + @PreviewFeature inline fun Update.requirePreCheckoutQueryUpdate(): PreCheckoutQueryUpdate = this as PreCheckoutQueryUpdate + @PreviewFeature inline fun Update.asShippingQueryUpdate(): ShippingQueryUpdate? = this as? ShippingQueryUpdate + @PreviewFeature inline fun Update.requireShippingQueryUpdate(): ShippingQueryUpdate = this as ShippingQueryUpdate + @PreviewFeature inline fun Update.asBaseEditMessageUpdate(): BaseEditMessageUpdate? = this as? BaseEditMessageUpdate + @PreviewFeature inline fun Update.requireBaseEditMessageUpdate(): BaseEditMessageUpdate = this as BaseEditMessageUpdate + @PreviewFeature inline fun Update.asBaseMessageUpdate(): BaseMessageUpdate? = this as? BaseMessageUpdate + @PreviewFeature inline fun Update.requireBaseMessageUpdate(): BaseMessageUpdate = this as BaseMessageUpdate + @PreviewFeature inline fun Update.asBaseSentMessageUpdate(): BaseSentMessageUpdate? = this as? BaseSentMessageUpdate + @PreviewFeature inline fun Update.requireBaseSentMessageUpdate(): BaseSentMessageUpdate = this as BaseSentMessageUpdate + @PreviewFeature inline fun Update.asUnknownUpdate(): UnknownUpdate? = this as? UnknownUpdate + @PreviewFeature inline fun Update.requireUnknownUpdate(): UnknownUpdate = this as UnknownUpdate + @PreviewFeature -inline fun Update.asCommonChatMemberUpdatedUpdate(): CommonChatMemberUpdatedUpdate? = this as? CommonChatMemberUpdatedUpdate +inline fun Update.asCommonChatMemberUpdatedUpdate(): CommonChatMemberUpdatedUpdate? = + this as? CommonChatMemberUpdatedUpdate + @PreviewFeature -inline fun Update.requireCommonChatMemberUpdatedUpdate(): CommonChatMemberUpdatedUpdate = this as CommonChatMemberUpdatedUpdate +inline fun Update.requireCommonChatMemberUpdatedUpdate(): CommonChatMemberUpdatedUpdate = + this as CommonChatMemberUpdatedUpdate + @PreviewFeature inline fun Update.asMyChatMemberUpdatedUpdate(): MyChatMemberUpdatedUpdate? = this as? MyChatMemberUpdatedUpdate + @PreviewFeature inline fun Update.requireMyChatMemberUpdatedUpdate(): MyChatMemberUpdatedUpdate = this as MyChatMemberUpdatedUpdate + @PreviewFeature inline fun Update.asChatMemberUpdatedUpdate(): ChatMemberUpdatedUpdate? = this as? ChatMemberUpdatedUpdate + @PreviewFeature inline fun Update.requireChatMemberUpdatedUpdate(): ChatMemberUpdatedUpdate = this as ChatMemberUpdatedUpdate + @PreviewFeature inline fun TelegramMediaFile.asAnimationFile(): AnimationFile? = this as? AnimationFile + @PreviewFeature inline fun TelegramMediaFile.requireAnimationFile(): AnimationFile = this as AnimationFile + @PreviewFeature inline fun TelegramMediaFile.asAudioFile(): AudioFile? = this as? AudioFile + @PreviewFeature inline fun TelegramMediaFile.requireAudioFile(): AudioFile = this as AudioFile + @PreviewFeature inline fun TelegramMediaFile.asDocumentFile(): DocumentFile? = this as? DocumentFile + @PreviewFeature inline fun TelegramMediaFile.requireDocumentFile(): DocumentFile = this as DocumentFile + @PreviewFeature inline fun TelegramMediaFile.asFile(): File? = this as? File + @PreviewFeature inline fun TelegramMediaFile.requireFile(): File = this as File + @PreviewFeature inline fun TelegramMediaFile.asPathedFile(): PathedFile? = this as? PathedFile + @PreviewFeature inline fun TelegramMediaFile.requirePathedFile(): PathedFile = this as PathedFile + @PreviewFeature inline fun TelegramMediaFile.asPhotoSize(): PhotoSize? = this as? PhotoSize + @PreviewFeature inline fun TelegramMediaFile.requirePhotoSize(): PhotoSize = this as PhotoSize + @PreviewFeature inline fun TelegramMediaFile.asSticker(): Sticker? = this as? Sticker + @PreviewFeature inline fun TelegramMediaFile.requireSticker(): Sticker = this as Sticker + @PreviewFeature inline fun TelegramMediaFile.asVideoFile(): VideoFile? = this as? VideoFile + @PreviewFeature inline fun TelegramMediaFile.requireVideoFile(): VideoFile = this as VideoFile + @PreviewFeature inline fun TelegramMediaFile.asVideoNoteFile(): VideoNoteFile? = this as? VideoNoteFile + @PreviewFeature inline fun TelegramMediaFile.requireVideoNoteFile(): VideoNoteFile = this as VideoNoteFile + @PreviewFeature inline fun TelegramMediaFile.asVoiceFile(): VoiceFile? = this as? VoiceFile + @PreviewFeature inline fun TelegramMediaFile.requireVoiceFile(): VoiceFile = this as VoiceFile + @PreviewFeature inline fun TelegramMediaFile.asMimedMediaFile(): MimedMediaFile? = this as? MimedMediaFile + @PreviewFeature inline fun TelegramMediaFile.requireMimedMediaFile(): MimedMediaFile = this as MimedMediaFile + @PreviewFeature inline fun TelegramMediaFile.asPlayableMediaFile(): PlayableMediaFile? = this as? PlayableMediaFile + @PreviewFeature inline fun TelegramMediaFile.requirePlayableMediaFile(): PlayableMediaFile = this as PlayableMediaFile + @PreviewFeature inline fun TelegramMediaFile.asSizedMediaFile(): SizedMediaFile? = this as? SizedMediaFile + @PreviewFeature inline fun TelegramMediaFile.requireSizedMediaFile(): SizedMediaFile = this as SizedMediaFile + @PreviewFeature inline fun TelegramMediaFile.asThumbedMediaFile(): ThumbedMediaFile? = this as? ThumbedMediaFile + @PreviewFeature inline fun TelegramMediaFile.requireThumbedMediaFile(): ThumbedMediaFile = this as ThumbedMediaFile + @PreviewFeature inline fun KeyboardMarkup.asForceReply(): ReplyForce? = this as? ReplyForce + @PreviewFeature inline fun KeyboardMarkup.requireForceReply(): ReplyForce = this as ReplyForce + @PreviewFeature inline fun KeyboardMarkup.asInlineKeyboardMarkup(): InlineKeyboardMarkup? = this as? InlineKeyboardMarkup + @PreviewFeature inline fun KeyboardMarkup.requireInlineKeyboardMarkup(): InlineKeyboardMarkup = this as InlineKeyboardMarkup + @PreviewFeature inline fun KeyboardMarkup.asReplyKeyboardMarkup(): ReplyKeyboardMarkup? = this as? ReplyKeyboardMarkup + @PreviewFeature inline fun KeyboardMarkup.requireReplyKeyboardMarkup(): ReplyKeyboardMarkup = this as ReplyKeyboardMarkup + @PreviewFeature inline fun KeyboardMarkup.asReplyKeyboardRemove(): ReplyKeyboardRemove? = this as? ReplyKeyboardRemove + @PreviewFeature inline fun KeyboardMarkup.requireReplyKeyboardRemove(): ReplyKeyboardRemove = this as ReplyKeyboardRemove + @PreviewFeature -inline fun InlineKeyboardButton.asCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton? = this as? CallbackDataInlineKeyboardButton +inline fun InlineKeyboardButton.asCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton? = + this as? CallbackDataInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.requireCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton = this as CallbackDataInlineKeyboardButton +inline fun InlineKeyboardButton.requireCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton = + this as CallbackDataInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.asCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton? = this as? CallbackGameInlineKeyboardButton +inline fun InlineKeyboardButton.asCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton? = + this as? CallbackGameInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.requireCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton = this as CallbackGameInlineKeyboardButton +inline fun InlineKeyboardButton.requireCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton = + this as CallbackGameInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.asLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton? = this as? LoginURLInlineKeyboardButton +inline fun InlineKeyboardButton.asLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton? = + this as? LoginURLInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.requireLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton = this as LoginURLInlineKeyboardButton +inline fun InlineKeyboardButton.requireLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton = + this as LoginURLInlineKeyboardButton + @PreviewFeature inline fun InlineKeyboardButton.asPayInlineKeyboardButton(): PayInlineKeyboardButton? = this as? PayInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.requirePayInlineKeyboardButton(): PayInlineKeyboardButton = this as PayInlineKeyboardButton +inline fun InlineKeyboardButton.requirePayInlineKeyboardButton(): PayInlineKeyboardButton = + this as PayInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.asSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton? = this as? SwitchInlineQueryCurrentChatInlineKeyboardButton +inline fun InlineKeyboardButton.asSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton? = + this as? SwitchInlineQueryCurrentChatInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.requireSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton = this as SwitchInlineQueryCurrentChatInlineKeyboardButton +inline fun InlineKeyboardButton.requireSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton = + this as SwitchInlineQueryCurrentChatInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.asSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton? = this as? SwitchInlineQueryInlineKeyboardButton +inline fun InlineKeyboardButton.asSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton? = + this as? SwitchInlineQueryInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.requireSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton = this as SwitchInlineQueryInlineKeyboardButton +inline fun InlineKeyboardButton.requireSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton = + this as SwitchInlineQueryInlineKeyboardButton + @PreviewFeature inline fun InlineKeyboardButton.asURLInlineKeyboardButton(): URLInlineKeyboardButton? = this as? URLInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.requireURLInlineKeyboardButton(): URLInlineKeyboardButton = this as URLInlineKeyboardButton +inline fun InlineKeyboardButton.requireURLInlineKeyboardButton(): URLInlineKeyboardButton = + this as URLInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.asUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton? = this as? UnknownInlineKeyboardButton +inline fun InlineKeyboardButton.asUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton? = + this as? UnknownInlineKeyboardButton + @PreviewFeature -inline fun InlineKeyboardButton.requireUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton = this as UnknownInlineKeyboardButton +inline fun InlineKeyboardButton.requireUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton = + this as UnknownInlineKeyboardButton + @PreviewFeature inline fun Poll.asMultipleAnswersPoll(): MultipleAnswersPoll? = this as? MultipleAnswersPoll + @PreviewFeature inline fun Poll.requireMultipleAnswersPoll(): MultipleAnswersPoll = this as MultipleAnswersPoll + @PreviewFeature inline fun Poll.asQuizPoll(): QuizPoll? = this as? QuizPoll + @PreviewFeature inline fun Poll.requireQuizPoll(): QuizPoll = this as QuizPoll + @PreviewFeature inline fun Poll.asRegularPoll(): RegularPoll? = this as? RegularPoll + @PreviewFeature inline fun Poll.requireRegularPoll(): RegularPoll = this as RegularPoll + @PreviewFeature inline fun Poll.asUnknownPollType(): UnknownPollType? = this as? UnknownPollType + @PreviewFeature inline fun Poll.requireUnknownPollType(): UnknownPollType = this as UnknownPollType + @PreviewFeature inline fun ResendableContent.asContactContent(): ContactContent? = this as? ContactContent + @PreviewFeature inline fun ResendableContent.requireContactContent(): ContactContent = this as ContactContent + @PreviewFeature inline fun ResendableContent.asDiceContent(): DiceContent? = this as? DiceContent + @PreviewFeature inline fun ResendableContent.requireDiceContent(): DiceContent = this as DiceContent + @PreviewFeature inline fun ResendableContent.asGameContent(): GameContent? = this as? GameContent + @PreviewFeature inline fun ResendableContent.requireGameContent(): GameContent = this as GameContent + @PreviewFeature inline fun ResendableContent.asLocationContent(): LocationContent? = this as? LocationContent + @PreviewFeature inline fun ResendableContent.requireLocationContent(): LocationContent = this as LocationContent + @PreviewFeature inline fun ResendableContent.asPollContent(): PollContent? = this as? PollContent + @PreviewFeature inline fun ResendableContent.requirePollContent(): PollContent = this as PollContent + @PreviewFeature inline fun ResendableContent.asTextContent(): TextContent? = this as? TextContent + @PreviewFeature inline fun ResendableContent.requireTextContent(): TextContent = this as TextContent + @PreviewFeature inline fun ResendableContent.asVenueContent(): VenueContent? = this as? VenueContent + @PreviewFeature inline fun ResendableContent.requireVenueContent(): VenueContent = this as VenueContent + @PreviewFeature inline fun ResendableContent.asAudioMediaGroupContent(): AudioMediaGroupContent? = this as? AudioMediaGroupContent + @PreviewFeature inline fun ResendableContent.requireAudioMediaGroupContent(): AudioMediaGroupContent = this as AudioMediaGroupContent + @PreviewFeature -inline fun ResendableContent.asDocumentMediaGroupContent(): DocumentMediaGroupContent? = this as? DocumentMediaGroupContent +inline fun ResendableContent.asDocumentMediaGroupContent(): DocumentMediaGroupContent? = + this as? DocumentMediaGroupContent + @PreviewFeature -inline fun ResendableContent.requireDocumentMediaGroupContent(): DocumentMediaGroupContent = this as DocumentMediaGroupContent +inline fun ResendableContent.requireDocumentMediaGroupContent(): DocumentMediaGroupContent = + this as DocumentMediaGroupContent + @PreviewFeature -inline fun ResendableContent.asMediaCollectionContent(): MediaCollectionContent? = this as? MediaCollectionContent +inline fun ResendableContent.asMediaCollectionContent(): MediaCollectionContent? = + this as? MediaCollectionContent + @PreviewFeature -inline fun ResendableContent.requireMediaCollectionContent(): MediaCollectionContent = this as MediaCollectionContent +inline fun ResendableContent.requireMediaCollectionContent(): MediaCollectionContent = + this as MediaCollectionContent + @PreviewFeature inline fun ResendableContent.asMediaContent(): MediaContent? = this as? MediaContent + @PreviewFeature inline fun ResendableContent.requireMediaContent(): MediaContent = this as MediaContent + @PreviewFeature inline fun ResendableContent.asMediaGroupContent(): MediaGroupContent? = this as? MediaGroupContent + @PreviewFeature inline fun ResendableContent.requireMediaGroupContent(): MediaGroupContent = this as MediaGroupContent + @PreviewFeature inline fun ResendableContent.asMessageContent(): MessageContent? = this as? MessageContent + @PreviewFeature inline fun ResendableContent.requireMessageContent(): MessageContent = this as MessageContent + @PreviewFeature inline fun ResendableContent.asVisualMediaGroupContent(): VisualMediaGroupContent? = this as? VisualMediaGroupContent + @PreviewFeature inline fun ResendableContent.requireVisualMediaGroupContent(): VisualMediaGroupContent = this as VisualMediaGroupContent + @PreviewFeature inline fun ResendableContent.asAnimationContent(): AnimationContent? = this as? AnimationContent + @PreviewFeature inline fun ResendableContent.requireAnimationContent(): AnimationContent = this as AnimationContent + @PreviewFeature inline fun ResendableContent.asAudioContent(): AudioContent? = this as? AudioContent + @PreviewFeature inline fun ResendableContent.requireAudioContent(): AudioContent = this as AudioContent + @PreviewFeature inline fun ResendableContent.asDocumentContent(): DocumentContent? = this as? DocumentContent + @PreviewFeature inline fun ResendableContent.requireDocumentContent(): DocumentContent = this as DocumentContent + @PreviewFeature inline fun ResendableContent.asPhotoContent(): PhotoContent? = this as? PhotoContent + @PreviewFeature inline fun ResendableContent.requirePhotoContent(): PhotoContent = this as PhotoContent + @PreviewFeature inline fun ResendableContent.asStickerContent(): StickerContent? = this as? StickerContent + @PreviewFeature inline fun ResendableContent.requireStickerContent(): StickerContent = this as StickerContent + @PreviewFeature inline fun ResendableContent.asVideoContent(): VideoContent? = this as? VideoContent + @PreviewFeature inline fun ResendableContent.requireVideoContent(): VideoContent = this as VideoContent + @PreviewFeature inline fun ResendableContent.asVideoNoteContent(): VideoNoteContent? = this as? VideoNoteContent + @PreviewFeature inline fun ResendableContent.requireVideoNoteContent(): VideoNoteContent = this as VideoNoteContent + @PreviewFeature inline fun ResendableContent.asVoiceContent(): VoiceContent? = this as? VoiceContent + @PreviewFeature inline fun ResendableContent.requireVoiceContent(): VoiceContent = this as VoiceContent + @PreviewFeature inline fun ResendableContent.asInvoiceContent(): InvoiceContent? = this as? InvoiceContent + @PreviewFeature inline fun ResendableContent.requireInvoiceContent(): InvoiceContent = this as InvoiceContent + @PreviewFeature inline fun TextSource.asMultilevelTextSource(): MultilevelTextSource? = this as? MultilevelTextSource + @PreviewFeature inline fun TextSource.requireMultilevelTextSource(): MultilevelTextSource = this as MultilevelTextSource + @PreviewFeature inline fun TextSource.asBoldTextSource(): BoldTextSource? = this as? BoldTextSource + @PreviewFeature inline fun TextSource.requireBoldTextSource(): BoldTextSource = this as BoldTextSource + @PreviewFeature inline fun TextSource.asBotCommandTextSource(): BotCommandTextSource? = this as? BotCommandTextSource + @PreviewFeature inline fun TextSource.requireBotCommandTextSource(): BotCommandTextSource = this as BotCommandTextSource + @PreviewFeature inline fun TextSource.asCashTagTextSource(): CashTagTextSource? = this as? CashTagTextSource + @PreviewFeature inline fun TextSource.requireCashTagTextSource(): CashTagTextSource = this as CashTagTextSource + @PreviewFeature inline fun TextSource.asCodeTextSource(): CodeTextSource? = this as? CodeTextSource + @PreviewFeature inline fun TextSource.requireCodeTextSource(): CodeTextSource = this as CodeTextSource + @PreviewFeature inline fun TextSource.asEMailTextSource(): EMailTextSource? = this as? EMailTextSource + @PreviewFeature inline fun TextSource.requireEMailTextSource(): EMailTextSource = this as EMailTextSource + @PreviewFeature inline fun TextSource.asHashTagTextSource(): HashTagTextSource? = this as? HashTagTextSource + @PreviewFeature inline fun TextSource.requireHashTagTextSource(): HashTagTextSource = this as HashTagTextSource + @PreviewFeature inline fun TextSource.asItalicTextSource(): ItalicTextSource? = this as? ItalicTextSource + @PreviewFeature inline fun TextSource.requireItalicTextSource(): ItalicTextSource = this as ItalicTextSource + @PreviewFeature inline fun TextSource.asMentionTextSource(): MentionTextSource? = this as? MentionTextSource + @PreviewFeature inline fun TextSource.requireMentionTextSource(): MentionTextSource = this as MentionTextSource + @PreviewFeature inline fun TextSource.asPhoneNumberTextSource(): PhoneNumberTextSource? = this as? PhoneNumberTextSource + @PreviewFeature inline fun TextSource.requirePhoneNumberTextSource(): PhoneNumberTextSource = this as PhoneNumberTextSource + @PreviewFeature inline fun TextSource.asPreTextSource(): PreTextSource? = this as? PreTextSource + @PreviewFeature inline fun TextSource.requirePreTextSource(): PreTextSource = this as PreTextSource + @PreviewFeature inline fun TextSource.asRegularTextSource(): RegularTextSource? = this as? RegularTextSource + @PreviewFeature inline fun TextSource.requireRegularTextSource(): RegularTextSource = this as RegularTextSource + @PreviewFeature inline fun TextSource.asStrikethroughTextSource(): StrikethroughTextSource? = this as? StrikethroughTextSource + @PreviewFeature inline fun TextSource.requireStrikethroughTextSource(): StrikethroughTextSource = this as StrikethroughTextSource + @PreviewFeature inline fun TextSource.asTextLinkTextSource(): TextLinkTextSource? = this as? TextLinkTextSource + @PreviewFeature inline fun TextSource.requireTextLinkTextSource(): TextLinkTextSource = this as TextLinkTextSource + @PreviewFeature inline fun TextSource.asTextMentionTextSource(): TextMentionTextSource? = this as? TextMentionTextSource + @PreviewFeature inline fun TextSource.requireTextMentionTextSource(): TextMentionTextSource = this as TextMentionTextSource + @PreviewFeature inline fun TextSource.asURLTextSource(): URLTextSource? = this as? URLTextSource + @PreviewFeature inline fun TextSource.requireURLTextSource(): URLTextSource = this as URLTextSource + @PreviewFeature inline fun TextSource.asUnderlineTextSource(): UnderlineTextSource? = this as? UnderlineTextSource + @PreviewFeature inline fun TextSource.requireUnderlineTextSource(): UnderlineTextSource = this as UnderlineTextSource + @PreviewFeature -inline fun DiceAnimationType.asBasketballDiceAnimationType(): BasketballDiceAnimationType? = this as? BasketballDiceAnimationType +inline fun DiceAnimationType.asBasketballDiceAnimationType(): BasketballDiceAnimationType? = + this as? BasketballDiceAnimationType + @PreviewFeature -inline fun DiceAnimationType.requireBasketballDiceAnimationType(): BasketballDiceAnimationType = this as BasketballDiceAnimationType +inline fun DiceAnimationType.requireBasketballDiceAnimationType(): BasketballDiceAnimationType = + this as BasketballDiceAnimationType + @PreviewFeature inline fun DiceAnimationType.asBowlingDiceAnimationType(): BowlingDiceAnimationType? = this as? BowlingDiceAnimationType + @PreviewFeature -inline fun DiceAnimationType.requireBowlingDiceAnimationType(): BowlingDiceAnimationType = this as BowlingDiceAnimationType +inline fun DiceAnimationType.requireBowlingDiceAnimationType(): BowlingDiceAnimationType = + this as BowlingDiceAnimationType + @PreviewFeature inline fun DiceAnimationType.asCubeDiceAnimationType(): CubeDiceAnimationType? = this as? CubeDiceAnimationType + @PreviewFeature inline fun DiceAnimationType.requireCubeDiceAnimationType(): CubeDiceAnimationType = this as CubeDiceAnimationType + @PreviewFeature inline fun DiceAnimationType.asCustomDiceAnimationType(): CustomDiceAnimationType? = this as? CustomDiceAnimationType + @PreviewFeature inline fun DiceAnimationType.requireCustomDiceAnimationType(): CustomDiceAnimationType = this as CustomDiceAnimationType + @PreviewFeature inline fun DiceAnimationType.asDartsDiceAnimationType(): DartsDiceAnimationType? = this as? DartsDiceAnimationType + @PreviewFeature inline fun DiceAnimationType.requireDartsDiceAnimationType(): DartsDiceAnimationType = this as DartsDiceAnimationType + @PreviewFeature -inline fun DiceAnimationType.asFootballDiceAnimationType(): FootballDiceAnimationType? = this as? FootballDiceAnimationType +inline fun DiceAnimationType.asFootballDiceAnimationType(): FootballDiceAnimationType? = + this as? FootballDiceAnimationType + @PreviewFeature -inline fun DiceAnimationType.requireFootballDiceAnimationType(): FootballDiceAnimationType = this as FootballDiceAnimationType +inline fun DiceAnimationType.requireFootballDiceAnimationType(): FootballDiceAnimationType = + this as FootballDiceAnimationType + @PreviewFeature -inline fun DiceAnimationType.asSlotMachineDiceAnimationType(): SlotMachineDiceAnimationType? = this as? SlotMachineDiceAnimationType +inline fun DiceAnimationType.asSlotMachineDiceAnimationType(): SlotMachineDiceAnimationType? = + this as? SlotMachineDiceAnimationType + @PreviewFeature -inline fun DiceAnimationType.requireSlotMachineDiceAnimationType(): SlotMachineDiceAnimationType = this as SlotMachineDiceAnimationType +inline fun DiceAnimationType.requireSlotMachineDiceAnimationType(): SlotMachineDiceAnimationType = + this as SlotMachineDiceAnimationType + @PreviewFeature inline fun ChatEvent.asChannelChatCreated(): ChannelChatCreated? = this as? ChannelChatCreated + @PreviewFeature inline fun ChatEvent.requireChannelChatCreated(): ChannelChatCreated = this as ChannelChatCreated + @PreviewFeature inline fun ChatEvent.asDeleteChatPhoto(): DeleteChatPhoto? = this as? DeleteChatPhoto + @PreviewFeature inline fun ChatEvent.requireDeleteChatPhoto(): DeleteChatPhoto = this as DeleteChatPhoto + @PreviewFeature inline fun ChatEvent.asGroupChatCreated(): GroupChatCreated? = this as? GroupChatCreated + @PreviewFeature inline fun ChatEvent.requireGroupChatCreated(): GroupChatCreated = this as GroupChatCreated + @PreviewFeature inline fun ChatEvent.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember + @PreviewFeature inline fun ChatEvent.requireLeftChatMember(): LeftChatMember = this as LeftChatMember + @PreviewFeature -inline fun ChatEvent.asMessageAutoDeleteTimerChanged(): MessageAutoDeleteTimerChanged? = this as? MessageAutoDeleteTimerChanged +inline fun ChatEvent.asMessageAutoDeleteTimerChanged(): MessageAutoDeleteTimerChanged? = + this as? MessageAutoDeleteTimerChanged + @PreviewFeature -inline fun ChatEvent.requireMessageAutoDeleteTimerChanged(): MessageAutoDeleteTimerChanged = this as MessageAutoDeleteTimerChanged +inline fun ChatEvent.requireMessageAutoDeleteTimerChanged(): MessageAutoDeleteTimerChanged = + this as MessageAutoDeleteTimerChanged + @PreviewFeature inline fun ChatEvent.asNewChatMembers(): NewChatMembers? = this as? NewChatMembers + @PreviewFeature inline fun ChatEvent.requireNewChatMembers(): NewChatMembers = this as NewChatMembers + @PreviewFeature inline fun ChatEvent.asNewChatPhoto(): NewChatPhoto? = this as? NewChatPhoto + @PreviewFeature inline fun ChatEvent.requireNewChatPhoto(): NewChatPhoto = this as NewChatPhoto + @PreviewFeature inline fun ChatEvent.asNewChatTitle(): NewChatTitle? = this as? NewChatTitle + @PreviewFeature inline fun ChatEvent.requireNewChatTitle(): NewChatTitle = this as NewChatTitle + @PreviewFeature inline fun ChatEvent.asPinnedMessage(): PinnedMessage? = this as? PinnedMessage + @PreviewFeature inline fun ChatEvent.requirePinnedMessage(): PinnedMessage = this as PinnedMessage + @PreviewFeature inline fun ChatEvent.asProximityAlertTriggered(): ProximityAlertTriggered? = this as? ProximityAlertTriggered + @PreviewFeature inline fun ChatEvent.requireProximityAlertTriggered(): ProximityAlertTriggered = this as ProximityAlertTriggered + @PreviewFeature inline fun ChatEvent.asSupergroupChatCreated(): SupergroupChatCreated? = this as? SupergroupChatCreated + @PreviewFeature inline fun ChatEvent.requireSupergroupChatCreated(): SupergroupChatCreated = this as SupergroupChatCreated + @PreviewFeature inline fun ChatEvent.asChannelEvent(): ChannelEvent? = this as? ChannelEvent + @PreviewFeature inline fun ChatEvent.requireChannelEvent(): ChannelEvent = this as ChannelEvent + @PreviewFeature inline fun ChatEvent.asCommonEvent(): CommonEvent? = this as? CommonEvent + @PreviewFeature inline fun ChatEvent.requireCommonEvent(): CommonEvent = this as CommonEvent + @PreviewFeature inline fun ChatEvent.asGroupEvent(): GroupEvent? = this as? GroupEvent + @PreviewFeature inline fun ChatEvent.requireGroupEvent(): GroupEvent = this as GroupEvent + @PreviewFeature inline fun ChatEvent.asSupergroupEvent(): SupergroupEvent? = this as? SupergroupEvent + @PreviewFeature inline fun ChatEvent.requireSupergroupEvent(): SupergroupEvent = this as SupergroupEvent + @PreviewFeature inline fun ChatEvent.asVoiceChatEvent(): VoiceChatEvent? = this as? VoiceChatEvent + @PreviewFeature inline fun ChatEvent.requireVoiceChatEvent(): VoiceChatEvent = this as VoiceChatEvent + @PreviewFeature inline fun ChatEvent.asVoiceChatEnded(): VoiceChatEnded? = this as? VoiceChatEnded + @PreviewFeature inline fun ChatEvent.requireVoiceChatEnded(): VoiceChatEnded = this as VoiceChatEnded + @PreviewFeature -inline fun ChatEvent.asVoiceChatParticipantsInvited(): VoiceChatParticipantsInvited? = this as? VoiceChatParticipantsInvited +inline fun ChatEvent.asVoiceChatParticipantsInvited(): VoiceChatParticipantsInvited? = + this as? VoiceChatParticipantsInvited + @PreviewFeature -inline fun ChatEvent.requireVoiceChatParticipantsInvited(): VoiceChatParticipantsInvited = this as VoiceChatParticipantsInvited +inline fun ChatEvent.requireVoiceChatParticipantsInvited(): VoiceChatParticipantsInvited = + this as VoiceChatParticipantsInvited + @PreviewFeature inline fun ChatEvent.asVoiceChatStarted(): VoiceChatStarted? = this as? VoiceChatStarted + @PreviewFeature inline fun ChatEvent.requireVoiceChatStarted(): VoiceChatStarted = this as VoiceChatStarted + @PreviewFeature inline fun CommonSendInvoiceData.asSendInvoice(): SendInvoice? = this as? SendInvoice + @PreviewFeature inline fun CommonSendInvoiceData.requireVoiceChatParticipantsInvited(): SendInvoice = this as SendInvoice + @PreviewFeature -inline fun CommonSendInvoiceData.asInputInvoiceMessageContent(): InputInvoiceMessageContent? = this as? InputInvoiceMessageContent +inline fun CommonSendInvoiceData.asInputInvoiceMessageContent(): InputInvoiceMessageContent? = + this as? InputInvoiceMessageContent + @PreviewFeature -inline fun CommonSendInvoiceData.requireInputInvoiceMessageContent(): InputInvoiceMessageContent = this as InputInvoiceMessageContent +inline fun CommonSendInvoiceData.requireInputInvoiceMessageContent(): InputInvoiceMessageContent = + this as InputInvoiceMessageContent 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 d49f366f75..ddcbd77ebd 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 @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.extensions.utils.extensions -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedWithTextSources import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage 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 b6f4bcefd9..a758bf4fc8 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,9 +2,11 @@ package dev.inmo.tgbotapi.extensions.utils.formatting +import dev.inmo.tgbotapi.types.MessageEntity.textsources.MutableTextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.User -fun buildEntities(init: EntitiesBuilder.() -> Unit): List = EntitiesBuilder().apply(init).build() +fun buildEntities(init: EntitiesBuilder.() -> Unit): TextSourcesList = EntitiesBuilder().apply(init).build() /** * This builder can be used to provide building of [TextSource]s [List] @@ -12,25 +14,25 @@ fun buildEntities(init: EntitiesBuilder.() -> Unit): List = mutableListOf() + private val entitiesList: MutableTextSourcesList = mutableListOf() ) { /** * It is not safe field which contains potentially changeable [List] */ - val entities: List + val entities: TextSourcesList get() = entitiesList /** * @return New immutable list which will be deattached from this builder */ - fun build(): List = entities.toList() + fun build(): TextSourcesList = entities.toList() fun add(source: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) { entitiesList.add(source) } operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.unaryPlus() = add(this) - operator fun List.unaryPlus() = entitiesList.addAll(this) + operator fun TextSourcesList.unaryPlus() = entitiesList.addAll(this) operator fun invoke(vararg source: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = entitiesList.addAll(source) operator fun String.unaryPlus() { @@ -38,7 +40,7 @@ class EntitiesBuilder internal constructor( } } -inline fun EntitiesBuilder.bold(parts: List) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(parts)) +inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(parts)) inline fun EntitiesBuilder.bold(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(*parts)) @@ -48,7 +50,7 @@ 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: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(parts)) inline fun EntitiesBuilder.cashTag(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = @@ -58,7 +60,7 @@ inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.M 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: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(parts)) inline fun EntitiesBuilder.email(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = @@ -67,7 +69,7 @@ inline fun EntitiesBuilder.email(vararg parts: dev.inmo.tgbotapi.types.MessageEn 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: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(parts)) inline fun EntitiesBuilder.hashtag(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = @@ -75,7 +77,7 @@ inline fun EntitiesBuilder.hashtag(vararg parts: dev.inmo.tgbotapi.types.Message 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: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(parts)) inline fun EntitiesBuilder.italic(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = @@ -83,7 +85,7 @@ inline fun EntitiesBuilder.italic(vararg parts: dev.inmo.tgbotapi.types.MessageE 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: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(parts)) inline fun EntitiesBuilder.mention(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = @@ -92,7 +94,7 @@ inline fun EntitiesBuilder.mention(vararg parts: dev.inmo.tgbotapi.types.Message 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: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(parts, user)) inline fun EntitiesBuilder.mention( @@ -104,7 +106,7 @@ inline fun EntitiesBuilder.mention( 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: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(parts)) inline fun EntitiesBuilder.phone(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = @@ -119,7 +121,7 @@ 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: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(parts)) inline fun EntitiesBuilder.strikethrough(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = @@ -134,7 +136,7 @@ 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: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(parts)) inline fun EntitiesBuilder.underline(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt index b36599ec67..ef809d74b3 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.extensions.utils.formatting -import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.* import dev.inmo.tgbotapi.types.message.content.TextContent @@ -56,8 +56,6 @@ fun TextSourcesList.toMarkdownCaptions(): List = createMarkdownText( captionLength.last ) -fun CaptionedInput.toMarkdownCaptions(): List = textSources.toMarkdownCaptions() - fun TextSourcesList.toMarkdownTexts(): List = createMarkdownText( this, textLength.last @@ -70,8 +68,6 @@ fun TextSourcesList.toMarkdownExplanations(): List = createMarkdownText( explanationLimit.last ) -fun ExplainedInput.toMarkdownExplanations(): List = textSources.toMarkdownTexts() - fun createMarkdownV2Text( entities: TextSourcesList, @@ -83,8 +79,6 @@ fun TextSourcesList.toMarkdownV2Captions(): List = createMarkdownV2Text( captionLength.last ) -fun CaptionedInput.toMarkdownV2Captions(): List = textSources.toMarkdownV2Captions() - fun TextSourcesList.toMarkdownV2Texts(): List = createMarkdownV2Text( this, textLength.last @@ -97,8 +91,6 @@ fun TextSourcesList.toMarkdownV2Explanations(): List = createMarkdownV2T explanationLimit.last ) -fun ExplainedInput.toMarkdownV2Explanations(): List = textSources.toMarkdownV2Texts() - fun createHtmlText( entities: TextSourcesList, @@ -110,8 +102,6 @@ fun TextSourcesList.toHtmlCaptions(): List = createHtmlText( captionLength.last ) -fun CaptionedInput.toHtmlCaptions(): List = textSources.toHtmlCaptions() - fun TextSourcesList.toHtmlTexts(): List = createHtmlText( this, textLength.last @@ -124,6 +114,4 @@ fun TextSourcesList.toHtmlExplanations(): List = createHtmlText( explanationLimit.last ) -fun ExplainedInput.toHtmlExplanations(): List = textSources.toHtmlTexts() - 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 1bfe7b70b0..864d0c77ef 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 @@ -2,8 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.updates import dev.inmo.tgbotapi.extensions.utils.onlyTextContentMessages import dev.inmo.tgbotapi.extensions.utils.shortcuts.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate @@ -59,4 +58,4 @@ fun Flow.filterCommandsInsideTextMessages( */ fun Flow.filterCommandsWithArgs( commandRegex: Regex -): Flow, List>> = textMessages().filterCommandsWithArgs(commandRegex) +): Flow, TextSourcesList>> = textMessages().filterCommandsWithArgs(commandRegex) diff --git a/tgbotapi/build.gradle b/tgbotapi/build.gradle index 895e728acf..24fccc4e69 100644 --- a/tgbotapi/build.gradle +++ b/tgbotapi/build.gradle @@ -29,10 +29,8 @@ repositories { } kotlin { - jvm { - compilations.main.kotlinOptions.useIR = true - } - js(BOTH) { + jvm() + js(IR) { browser() nodejs() } From bb7d47a33b2b7c3be5af2fc30b5092793d5b799c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 15:46:13 +0600 Subject: [PATCH 53/63] fix build --- .../dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt | 10 +++++----- .../dev/inmo/tgbotapi/types/ChatIdentifierTests.kt | 8 ++++---- .../kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt | 1 + .../dev/inmo/tgbotapi/types/TelegramDateTests.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt | 8 ++++---- 5 files changed, 15 insertions(+), 13 deletions(-) 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 cf2222ddd2..65a70a03da 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 @@ -9,25 +9,25 @@ import kotlinx.serialization.encoding.Encoder internal const val parseModeField = "parse_mode" -@Serializable(ParseModeSerializerObject::class) +@Serializable(ParseModeSerializer::class) sealed interface ParseMode { val parseModeName: String } -@Serializable(ParseModeSerializerObject::class) +@Serializable(ParseModeSerializer::class) object MarkdownParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "Markdown" } -@Serializable(ParseModeSerializerObject::class) +@Serializable(ParseModeSerializer::class) object MarkdownV2ParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "MarkdownV2" } -@Serializable(ParseModeSerializerObject::class) +@Serializable(ParseModeSerializer::class) object HTMLParseMode : ParseMode { @Serializable @SerialName(parseModeField) @@ -47,7 +47,7 @@ typealias HTML = HTMLParseMode var defaultParseMode: ParseMode = HTML @RiskFeature -object ParseModeSerializerObject : KSerializer { +object ParseModeSerializer : KSerializer { override val descriptor: SerialDescriptor = String.serializer().descriptor override fun deserialize(decoder: Decoder): ParseMode { return when (decoder.decodeString()) { diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt index 226357c4b2..a90efac2c1 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt @@ -40,13 +40,13 @@ class ChatIdentifierTests { } } + @Serializable + data class Example( + val identifier: ChatIdentifier + ) @Test fun `Deserializing_from_String_must_work_correctly`() { - @Serializable - data class Example( - val identifier: ChatIdentifier - ) Example(chatIdentifierChatId.toChatId()).let { withChatId -> val stringified = TestsJsonFormat.encodeToString(Example.serializer(), withChatId) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt index 981a7f6abc..ffe13a75ae 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt @@ -9,6 +9,7 @@ import kotlin.test.assertEquals class ParseModeTests { @Serializable data class Example( + @Serializable(ParseModeSerializer::class) val mode: ParseMode ) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TelegramDateTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TelegramDateTests.kt index 7ac90e6b71..a79e0aba6e 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TelegramDateTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TelegramDateTests.kt @@ -13,6 +13,7 @@ private val dateTime = DateTime(dateTimeMillis) class TelegramDateTests { @Serializable data class Example( + @Serializable(TelegramDateSerializer::class) val dateTime: TelegramDate ) @Test 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 d544f21c70..12596f0922 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,9 +1,9 @@ package dev.inmo.tgbotapi.types -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.TestsJsonFormat import dev.inmo.tgbotapi.extensions.utils.formatting.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourceSerializer +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import kotlinx.serialization.builtins.ListSerializer import kotlin.test.Test import kotlin.test.assertEquals @@ -26,9 +26,9 @@ class TextSourcesTests { regular(" ") pre("text", "kotlin") } - val serialized = TestsJsonFormat.encodeToString(ListSerializer(TextSource.serializer()), testList) + val serialized = TestsJsonFormat.encodeToString(ListSerializer(TextSourceSerializer), testList) val deserialized = TestsJsonFormat.decodeFromString( - ListSerializer(TextSource.serializer()), + ListSerializer(TextSourceSerializer), serialized ) assertEquals(testList, deserialized) From 173839c677e4e6bd5ad0890310d4873539a5cbe5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 15:51:45 +0600 Subject: [PATCH 54/63] small refactoring --- .../behaviour_builder/expectations/WaitInlineQuery.kt | 5 ++--- .../triggers_handling/InlineQueryTriggers.kt | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt index c5afff5667..4a35953f2b 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt @@ -3,8 +3,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate import dev.inmo.tgbotapi.requests.abstracts.Request -import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery -import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.query.* import kotlinx.coroutines.flow.toList typealias InlineQueryMapper = suspend T.() -> T? @@ -48,7 +47,7 @@ suspend fun BehaviourContext.waitAnyInlineQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: InlineQueryMapper? = null + filter: InlineQueryMapper? = null ) = waitInlines(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitBaseInlineQuery( diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt index 621d1fd8bb..e50d66fd0d 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt @@ -5,8 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat -import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery -import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.query.* internal suspend inline fun BehaviourContext.onInlineQuery( includeFilterByChatInBehaviourSubContext: Boolean = true, @@ -36,7 +35,7 @@ internal suspend inline fun Boolean)? = null, + additionalFilter: (suspend (InlineQuery) -> Boolean)? = null, scenarioReceiver: BehaviourContextAndTypeReceiver ) = onInlineQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) From 521a3a8c3586a24104c23551a2907433233e0d3b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 16:02:55 +0600 Subject: [PATCH 55/63] fix internal deprecations --- .../tgbotapi/CommonAbstracts/TextSource.kt | 10 +++++----- .../edit/caption/EditChatMessageCaption.kt | 2 +- .../edit/caption/EditInlineMessageCaption.kt | 2 +- .../requests/edit/text/EditChatMessageText.kt | 2 +- .../edit/text/EditInlineMessageText.kt | 2 +- .../tgbotapi/requests/send/CopyMessage.kt | 15 +++++++++++++-- .../tgbotapi/requests/send/SendMessage.kt | 2 +- .../requests/send/media/SendAnimation.kt | 2 +- .../tgbotapi/requests/send/media/SendAudio.kt | 2 +- .../requests/send/media/SendDocument.kt | 2 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 4 ++-- .../tgbotapi/requests/send/media/SendVideo.kt | 2 +- .../tgbotapi/requests/send/media/SendVoice.kt | 2 +- .../tgbotapi/requests/send/polls/SendPoll.kt | 2 +- .../InlineQueryResultAudioCachedImpl.kt | 12 ++++++++++-- .../InlineQueryResultAudioImpl.kt | 15 +++++++++++++-- .../InlineQueryResultDocumentCachedImpl.kt | 16 ++++++++++++---- .../InlineQueryResultDocumentImpl.kt | 18 ++++++++++++++++-- .../InlineQueryResultGifCachedImpl.kt | 13 +++++++++++-- .../InlineQueryResultGifImpl.kt | 18 ++++++++++++++++-- .../InlineQueryResultMpeg4GifCachedImpl.kt | 13 +++++++++++-- .../InlineQueryResultMpeg4GifImpl.kt | 18 ++++++++++++++++-- .../InlineQueryResultPhotoCachedImpl.kt | 14 ++++++++++++-- .../InlineQueryResultPhotoImpl.kt | 17 +++++++++++++++-- .../InlineQueryResultVideoCachedImpl.kt | 14 ++++++++++++-- .../InlineQueryResultVideoImpl.kt | 19 +++++++++++++++++-- .../InlineQueryResultVoiceCachedImpl.kt | 15 +++++++++++---- .../InlineQueryResultVoiceImpl.kt | 16 ++++++++++++---- .../types/InputMedia/InputMediaAnimation.kt | 15 +++++++++++---- .../types/InputMedia/InputMediaAudio.kt | 3 ++- .../types/InputMedia/InputMediaDocument.kt | 13 +++++++++---- .../types/InputMedia/InputMediaPhoto.kt | 4 +--- .../types/InputMedia/InputMediaVideo.kt | 4 +--- .../MessageEntity/StringFormattingTests.kt | 1 - 34 files changed, 239 insertions(+), 70 deletions(-) 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 2f5e3a38e9..d485657209 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 @@ -21,21 +21,21 @@ const val DirectInvocationOfTextSourceConstructor = typealias TextSourcesList = TextSourcesList @Deprecated("Replaced", ReplaceWith("TextSource", "dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource")) -typealias TextSource = dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +typealias TextSource = TextSource @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) = +inline operator fun TextSource.plus(other: TextSource) = listOf(this, other) @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) = +inline operator fun TextSource.plus(other: List) = listOf(this) + other @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) = +inline operator fun TextSource.plus(text: String) = listOf(this, regular(text)) @Suppress("NOTHING_TO_INLINE") @@ -48,7 +48,7 @@ inline operator fun List.plus(text: String) = this + regular(text) ) typealias MultilevelTextSource = MultilevelTextSource -@Deprecated("Replaced", ReplaceWith("makeString", "dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString")) +@Deprecated("Replaced", ReplaceWith("makeString()", "dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString")) fun List.makeString() = makeString() @Deprecated( 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 fdc8cc8e55..189db1b32f 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,11 +1,11 @@ package dev.inmo.tgbotapi.requests.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup 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 21a96caf51..9b083f7a5c 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,10 +1,10 @@ package dev.inmo.tgbotapi.requests.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup 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 82644f8e4e..1fa5cd07bb 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,11 +1,11 @@ package dev.inmo.tgbotapi.requests.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup 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 2d92305b31..15b3cbd32d 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,10 +1,10 @@ package dev.inmo.tgbotapi.requests.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup 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 61f88c08e3..56aa097cac 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 @@ -1,13 +1,13 @@ package dev.inmo.tgbotapi.requests.send import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.CommonAbstracts.types.MessageAction 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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -34,7 +34,18 @@ fun CopyMessage( replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = CopyMessage(fromChatId, toChatId, messageId, entities.makeString(), null, entities.toRawMessageEntities(), disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = CopyMessage( + fromChatId, + toChatId, + messageId, + entities.makeString(), + null, + entities.toRawMessageEntities(), + disableNotification, + replyToMessageId, + allowSendingWithoutReply, + replyMarkup +) @Serializable data class CopyMessage internal constructor( 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 3449b0bc01..c64ba21146 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,11 +1,11 @@ package dev.inmo.tgbotapi.requests.send -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup 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 cd05c978d3..ed1850ab78 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,12 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* 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.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup 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 ca2040d1f2..2de6a3229f 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 @@ -1,13 +1,13 @@ package dev.inmo.tgbotapi.requests.send.media import dev.inmo.tgbotapi.CommonAbstracts.Performerable -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* 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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup 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 0e17106f28..06cc58a104 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,12 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* 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.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup 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 a6ad86c385..87cc0e1c80 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,12 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* 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.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -56,7 +56,7 @@ fun SendPhoto( ): Request> { val data = SendPhotoData( chatId, - (photo as? FileId) ?.fileId, + (photo as? FileId)?.fileId, entities.makeString(), null, entities.toRawMessageEntities(), 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 ce0366c437..7fc73a202e 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,12 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* 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.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup 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 0a951a97e5..98d8ec1075 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,12 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.* 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.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup 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 72bc2cb98a..2a6a35efdc 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 @@ -2,12 +2,12 @@ package dev.inmo.tgbotapi.requests.send.polls import com.soywiz.klock.DateTime import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest 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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage 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 2d0c578208..703d5ca43b 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.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached @@ -8,6 +7,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -29,7 +29,15 @@ fun InlineQueryResultAudioCachedImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultAudioCachedImpl(id, fileId, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultAudioCachedImpl( + id, + fileId, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultAudioCachedImpl internal constructor( 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 3ba051f937..c475060374 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,12 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -34,7 +34,18 @@ fun InlineQueryResultAudioImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultAudioImpl(id, url, title, performer, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultAudioImpl( + id, + url, + title, + performer, + duration, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultAudioImpl internal constructor( 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 49fe37fcf9..6d242e32f9 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,14 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -34,7 +32,17 @@ fun InlineQueryResultDocumentCachedImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultDocumentCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultDocumentCachedImpl( + id, + fileId, + title, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultDocumentCachedImpl internal constructor( 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 62a37d5ffd..1541ae783b 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,12 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -42,7 +42,21 @@ fun InlineQueryResultDocumentImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultDocumentImpl(id, url, title, mimeType, thumbUrl, thumbWidth, thumbHeight, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultDocumentImpl( + id, + url, + title, + mimeType, + thumbUrl, + thumbWidth, + thumbHeight, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultDocumentImpl internal constructor( 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 07a5139df1..c0af32ce1a 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.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached @@ -8,6 +7,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -31,7 +31,16 @@ fun InlineQueryResultGifCachedImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultGifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultGifCachedImpl( + id, + fileId, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultGifCachedImpl internal constructor( 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 69e491a43a..b78b03d017 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,12 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -41,7 +41,21 @@ fun InlineQueryResultGifImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultGifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultGifImpl( + id, + url, + thumbUrl, + thumbMimeType, + width, + height, + duration, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultGifImpl internal constructor( 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 76f9dc7c5e..c2a8154121 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.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached @@ -8,6 +7,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -31,7 +31,16 @@ fun InlineQueryResultMpeg4GifCachedImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultMpeg4GifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultMpeg4GifCachedImpl( + id, + fileId, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultMpeg4GifCachedImpl internal constructor( 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 b789a849e1..9810cd6f27 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,12 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -41,7 +41,21 @@ fun InlineQueryResultMpeg4GifImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultMpeg4GifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultMpeg4GifImpl( + id, + url, + thumbUrl, + thumbMimeType, + width, + height, + duration, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultMpeg4GifImpl internal constructor( 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 b39a025b5c..0a1aed3b2c 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.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached @@ -8,6 +7,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -33,7 +33,17 @@ fun InlineQueryResultPhotoCachedImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultPhotoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultPhotoCachedImpl( + id, + fileId, + title, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultPhotoCachedImpl internal constructor( 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 d3e9c722d2..c835c7e469 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,12 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -38,7 +38,20 @@ fun InlineQueryResultPhotoImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultPhotoImpl(id, url, thumbUrl, width, height, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultPhotoImpl( + id, + url, + thumbUrl, + width, + height, + title, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultPhotoImpl internal constructor( 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 6b61eee0d3..4d65516edc 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.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached @@ -8,6 +7,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -33,7 +33,17 @@ fun InlineQueryResultVideoCachedImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultVideoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultVideoCachedImpl( + id, + fileId, + title, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultVideoCachedImpl internal constructor( 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 478e8590b9..fbf4a330b3 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,12 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -44,7 +44,22 @@ fun InlineQueryResultVideoImpl( 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) +) = InlineQueryResultVideoImpl( + id, + url, + thumbUrl, + mimeType, + title, + width, + height, + duration, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultVideoImpl internal constructor( 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 52969b6696..55c91a8686 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,14 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -32,7 +30,16 @@ fun InlineQueryResultVoiceCachedImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultVoiceCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultVoiceCachedImpl( + id, + fileId, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultVoiceCachedImpl internal constructor( 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 4239a43126..7bece71430 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,13 +1,11 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent import dev.inmo.tgbotapi.types.MessageEntity.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -43,7 +41,17 @@ fun InlineQueryResultVoiceImpl( entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null, inputMessageContent: InputMessageContent? = null -) = InlineQueryResultVoiceImpl(id, url, title, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) +) = InlineQueryResultVoiceImpl( + id, + url, + title, + duration, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultVoiceImpl internal constructor( 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 4f64b24563..aa9ec48be9 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 @@ -1,13 +1,11 @@ package dev.inmo.tgbotapi.types.InputMedia import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput -import dev.inmo.tgbotapi.CommonAbstracts.makeString 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.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.SerialName @@ -30,7 +28,16 @@ fun InputMediaAnimation( height: Int? = null, duration: Long? = null, thumb: InputFile? = null -) = InputMediaAnimation(file, entities.makeString(), null, entities.toRawMessageEntities(), width, height, duration, thumb) +) = InputMediaAnimation( + file, + entities.makeString(), + null, + entities.toRawMessageEntities(), + width, + height, + duration, + thumb +) @Serializable data class InputMediaAnimation internal constructor( 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 fcd164a2b1..c8a9a79b3d 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,7 +5,8 @@ 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.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.AudioFile 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 3da2e9bb7c..06dc0d724d 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 @@ -1,11 +1,9 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.makeString 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.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.DocumentFile @@ -26,7 +24,14 @@ fun InputMediaDocument( entities: TextSourcesList, thumb: InputFile? = null, disableContentTypeDetection: Boolean? = null -) = InputMediaDocument(file, entities.makeString(), null, entities.toRawMessageEntities(), thumb, disableContentTypeDetection) +) = InputMediaDocument( + file, + entities.makeString(), + null, + entities.toRawMessageEntities(), + thumb, + disableContentTypeDetection +) /** * Represents a general file to be sent. See https://core.telegram.org/bots/api#inputmediadocument 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 c6c6f671ac..c243befc9b 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 @@ -1,12 +1,10 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.makeString 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.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.PhotoSize 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 fbe67ad528..cc8c545216 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,12 +1,10 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.makeString 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.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.* 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 98f36e7b28..747dcc8588 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.plus import dev.inmo.tgbotapi.extensions.utils.formatting.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import kotlin.test.Test From a6451ca39465b03a1ee7f740395ed2c5d2b3ab16 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 17:03:28 +0600 Subject: [PATCH 56/63] update workflows to separate build and publishing --- .github/workflows/build.yml | 12 ++++++++++++ .github/workflows/packages_publishing.yml | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..738b5c9f66 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,12 @@ +name: Build +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build + run: ./gradlew build diff --git a/.github/workflows/packages_publishing.yml b/.github/workflows/packages_publishing.yml index 21dd2a8cc8..373c1a58d2 100644 --- a/.github/workflows/packages_publishing.yml +++ b/.github/workflows/packages_publishing.yml @@ -14,8 +14,6 @@ jobs: cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp rm gradle.properties mv gradle.properties.tmp gradle.properties - - name: Build - run: ./gradlew build - name: Publish run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication -x signMetadataPublication env: From 86e78c4ba03f0b91da0d66867aac6df46feedaf5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 30 May 2021 01:20:25 +0600 Subject: [PATCH 57/63] Update packages_publishing.yml --- .github/workflows/packages_publishing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packages_publishing.yml b/.github/workflows/packages_publishing.yml index 373c1a58d2..9d26482cd4 100644 --- a/.github/workflows/packages_publishing.yml +++ b/.github/workflows/packages_publishing.yml @@ -15,7 +15,7 @@ jobs: rm gradle.properties mv gradle.properties.tmp gradle.properties - name: Publish - run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication -x signMetadataPublication + run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication env: GITHUBPACKAGES_USER: ${{ github.actor }} GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} From a265e5ecbffc294471c6b6c9810b4db62947b2a7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 3 Jun 2021 23:09:46 +0600 Subject: [PATCH 58/63] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1f23dbf58..70b79f2a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.35.0 **ALL PREVIOUS DEPRECATIONS HAVE BEEN REMOVED** +**JS PART NOW USE IR COMPILER ONLY** * `Common`: * `Version`: @@ -17,6 +18,7 @@ * `ForceReply` has been renamed to `ReplyForce` * `Captioned` and `Explained` interfaces have been removed * `RecordAudioAction` and `UploadAudioAction` (and all related to these actions functionality) have been removed + * `TextSource` interface and all related things have been replaced ## 0.34.1 From 39fa36426f61603107d185fdac1374b48730d654 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 3 Jun 2021 23:25:19 +0600 Subject: [PATCH 59/63] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70b79f2a2d..cc082a67e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ * `Captioned` and `Explained` interfaces have been removed * `RecordAudioAction` and `UploadAudioAction` (and all related to these actions functionality) have been removed * `TextSource` interface and all related things have been replaced + * `CallbackQuery` interface and all its extenders/implementers become `sealed` + * `ChatMember` become `sealed` + * `LeftChatMember` and `MemberChatMember` become interfaces. All their code were replaced to the `*Impl` classes ## 0.34.1 From 3829e04b0c943bc4ea360877d657886df76d181e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 3 Jun 2021 23:34:11 +0600 Subject: [PATCH 60/63] Update CHANGELOG.md --- CHANGELOG.md | 7 ++++- .../requests/answers/AnswerInlineQuery.kt | 3 +- .../dev/inmo/tgbotapi/types/ChatInviteLink.kt | 2 ++ .../tgbotapi/types/chat/ChatSerializers.kt | 2 ++ .../encrypted/EncryptedElementSerializer.kt | 1 + .../api/answers/AnswerInlineQuery.kt | 3 +- .../expectations/WaitInlineQuery.kt | 4 +-- .../triggers_handling/InlineQueryTriggers.kt | 4 +-- .../tgbotapi/extensions/utils/ClassCasts.kt | 11 ++++--- .../utils/formatting/EntitiesBuilder.kt | 29 +++++++++---------- 10 files changed, 38 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc082a67e9..10d00f4941 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,8 +20,13 @@ * `RecordAudioAction` and `UploadAudioAction` (and all related to these actions functionality) have been removed * `TextSource` interface and all related things have been replaced * `CallbackQuery` interface and all its extenders/implementers become `sealed` - * `ChatMember` become `sealed` + * `InputMedia` interface and all its extenders/implementers become `sealed` + * `ParseMode` interface and all its extenders/implementers become `sealed` + * `ChatMember` becomes `sealed` + * `KeyboardMarkup` becomes `sealed` * `LeftChatMember` and `MemberChatMember` become interfaces. All their code were replaced to the `*Impl` classes + * Most of `sealed` classes have been modified to be interfaces + * Most serializers becomes public, but they are still `RistFeature` ## 0.34.1 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/AnswerInlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/AnswerInlineQuery.kt index 0971c24ed5..e721e2389b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/AnswerInlineQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/answers/AnswerInlineQuery.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer +import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer @@ -34,7 +35,7 @@ data class AnswerInlineQuery( get() = serializer() } -fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.createAnswer( +fun InlineQuery.createAnswer( results: List = emptyList(), cachedTime: Int? = null, isPersonal: Boolean? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt index 945e2b9616..e7771b2ad0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types import com.soywiz.klock.DateTime +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder @@ -79,6 +80,7 @@ data class CommonInviteLink( get() = expireDate ?.asDate } +@RiskFeature object ChatInviteLinkSerializer : KSerializer { override val descriptor: SerialDescriptor get() = RawChatInviteLink.serializer().descriptor diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt index e02220a3ad..d68461a5d5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt @@ -40,6 +40,8 @@ val String.asChatType ChatType.ChannelChatType.stringified -> ChatType.ChannelChatType else -> ChatType.UnknownChatType(this) } + +@RiskFeature object ChatTypeSerializer : KSerializer { override val descriptor: SerialDescriptor = String.serializer().descriptor override fun deserialize(decoder: Decoder): ChatType { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/EncryptedElementSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/EncryptedElementSerializer.kt index 1c83f349c9..b617d3c4c3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/EncryptedElementSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/EncryptedElementSerializer.kt @@ -35,6 +35,7 @@ val encryptedElementsClassesByTypes = mapOf( val EncryptedPassportElement.type: String get() = encryptedElementsClassesByTypes.keys.firstOrNull { encryptedElementsClassesByTypes.getValue(it).klass.isInstance(this) } ?: "unknown" +@RiskFeature object EncryptedElementSerializer : KSerializer { private val jsonSerializer = JsonObject.serializer() override val descriptor: SerialDescriptor = jsonSerializer.descriptor diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt index e549143781..c356576c80 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.answers import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult +import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.InlineQueryIdentifier suspend fun TelegramBot.answerInlineQuery( @@ -18,7 +19,7 @@ suspend fun TelegramBot.answerInlineQuery( ) suspend fun TelegramBot.answerInlineQuery( - inlineQuery: dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery, + inlineQuery: InlineQuery, results: List = emptyList(), cachedTime: Int? = null, isPersonal: Boolean? = null, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt index 4a35953f2b..3c6ecf4a6f 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt @@ -12,7 +12,7 @@ private suspend fun BehaviourContext.waitInlineQueries( count: Int = 1, initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - mapper: suspend dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.() -> O? + mapper: suspend InlineQuery.() -> O? ): List = expectFlow( initRequest, count, @@ -22,7 +22,7 @@ private suspend fun BehaviourContext.waitInlineQueries( }.toList().toList() -private suspend inline fun BehaviourContext.waitInlines( +private suspend inline fun BehaviourContext.waitInlines( count: Int = 1, initRequest: Request<*>? = null, noinline errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt index e50d66fd0d..8ced3c83e4 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt @@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat import dev.inmo.tgbotapi.types.InlineQueries.query.* -internal suspend inline fun BehaviourContext.onInlineQuery( +internal suspend inline fun BehaviourContext.onInlineQuery( includeFilterByChatInBehaviourSubContext: Boolean = true, noinline additionalFilter: (suspend (T) -> Boolean)? = null, noinline scenarioReceiver: BehaviourContextAndTypeReceiver @@ -36,7 +36,7 @@ internal suspend inline fun Boolean)? = null, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: BehaviourContextAndTypeReceiver ) = onInlineQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) 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 ac235c56df..92dc65b601 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 @@ -20,8 +20,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.* import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.* import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent -import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery -import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.query.* import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.actions.* @@ -924,19 +923,19 @@ inline fun BotAction.asUploadVideoNoteAction(): UploadVideoNoteAction? = this as inline fun BotAction.requireUploadVideoNoteAction(): UploadVideoNoteAction = this as UploadVideoNoteAction @PreviewFeature -inline fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.asBaseInlineQuery(): BaseInlineQuery? = +inline fun InlineQuery.asBaseInlineQuery(): BaseInlineQuery? = this as? BaseInlineQuery @PreviewFeature -inline fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.requireBaseInlineQuery(): BaseInlineQuery = +inline fun InlineQuery.requireBaseInlineQuery(): BaseInlineQuery = this as BaseInlineQuery @PreviewFeature -inline fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = +inline fun InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = this as? LocationInlineQuery @PreviewFeature -inline fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.requireLocationInlineQuery(): LocationInlineQuery = +inline fun InlineQuery.requireLocationInlineQuery(): LocationInlineQuery = this as LocationInlineQuery @PreviewFeature 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 a758bf4fc8..88ed4ffdf7 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,8 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.formatting -import dev.inmo.tgbotapi.types.MessageEntity.textsources.MutableTextSourcesList -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.User fun buildEntities(init: EntitiesBuilder.() -> Unit): TextSourcesList = EntitiesBuilder().apply(init).build() @@ -27,13 +26,13 @@ class EntitiesBuilder internal constructor( */ fun build(): TextSourcesList = entities.toList() - fun add(source: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) { + fun add(source: TextSource) { entitiesList.add(source) } - operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.unaryPlus() = add(this) + operator fun TextSource.unaryPlus() = add(this) operator fun TextSourcesList.unaryPlus() = entitiesList.addAll(this) - operator fun invoke(vararg source: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = entitiesList.addAll(source) + operator fun invoke(vararg source: TextSource) = entitiesList.addAll(source) operator fun String.unaryPlus() { add(dev.inmo.tgbotapi.types.MessageEntity.textsources.regular(this)) @@ -42,7 +41,7 @@ class EntitiesBuilder internal constructor( inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(parts)) -inline fun EntitiesBuilder.bold(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.bold(vararg parts: 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)) @@ -53,7 +52,7 @@ inline fun EntitiesBuilder.botCommand(command: String) = inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(parts)) -inline fun EntitiesBuilder.cashTag(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.cashTag(vararg parts: 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)) @@ -63,7 +62,7 @@ inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.Mess inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(parts)) -inline fun EntitiesBuilder.email(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(*parts)) inline fun EntitiesBuilder.email(emailAddress: String) = @@ -72,7 +71,7 @@ inline fun EntitiesBuilder.email(emailAddress: String) = inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(parts)) -inline fun EntitiesBuilder.hashtag(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.hashtag(vararg parts: 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)) @@ -80,7 +79,7 @@ inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.type inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(parts)) -inline fun EntitiesBuilder.italic(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.italic(vararg parts: 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)) @@ -88,7 +87,7 @@ inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.Me inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(parts)) -inline fun EntitiesBuilder.mention(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(*parts)) inline fun EntitiesBuilder.mention(whoToMention: String) = @@ -99,7 +98,7 @@ inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = inline fun EntitiesBuilder.mention( user: User, - vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource + vararg parts: TextSource ) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(user, *parts)) @@ -109,7 +108,7 @@ inline fun EntitiesBuilder.mention(text: String, user: User) = inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(parts)) -inline fun EntitiesBuilder.phone(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(*parts)) inline fun EntitiesBuilder.phone(number: String) = @@ -124,7 +123,7 @@ inline fun EntitiesBuilder.regular(text: String) = inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(parts)) -inline fun EntitiesBuilder.strikethrough(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(*parts)) inline fun EntitiesBuilder.strikethrough(text: String) = @@ -139,7 +138,7 @@ inline fun EntitiesBuilder.link(url: String) = inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(parts)) -inline fun EntitiesBuilder.underline(vararg parts: dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource) = +inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(*parts)) inline fun EntitiesBuilder.underline(text: String) = From 3ebcbe2860f6991ec74a6303ee6be8f779e1300f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 4 Jun 2021 01:07:53 +0600 Subject: [PATCH 61/63] builder extending --- CHANGELOG.md | 3 ++- .../extensions/utils/formatting/EntitiesBuilder.kt | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10d00f4941..94e7777081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,8 @@ * `KeyboardMarkup` becomes `sealed` * `LeftChatMember` and `MemberChatMember` become interfaces. All their code were replaced to the `*Impl` classes * Most of `sealed` classes have been modified to be interfaces - * Most serializers becomes public, but they are still `RistFeature` + * Most serializers becomes public, but they are still `RistFeature` + * For `EntitiesBuilder` multilevel text sources builders with callback have been added ## 0.34.1 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 88ed4ffdf7..c0f09e5d9a 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 @@ -5,7 +5,9 @@ package dev.inmo.tgbotapi.extensions.utils.formatting import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.User -fun buildEntities(init: EntitiesBuilder.() -> Unit): TextSourcesList = EntitiesBuilder().apply(init).build() +typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit + +fun buildEntities(init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder().apply(init).build() /** * This builder can be used to provide building of [TextSource]s [List] @@ -40,6 +42,7 @@ class EntitiesBuilder internal constructor( } inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(parts)) +inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(buildEntities(init))) inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(*parts)) @@ -51,6 +54,7 @@ inline fun EntitiesBuilder.botCommand(command: String) = inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(parts)) +inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(buildEntities(init))) inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(*parts)) @@ -61,6 +65,7 @@ inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.Mess inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(parts)) +inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(buildEntities(init))) inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(*parts)) @@ -70,6 +75,7 @@ inline fun EntitiesBuilder.email(emailAddress: String) = inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(parts)) +inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(buildEntities(init))) inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(*parts)) @@ -78,6 +84,7 @@ inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.type inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(parts)) +inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(buildEntities(init))) inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(*parts)) @@ -86,6 +93,7 @@ inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.Me inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(parts)) +inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(buildEntities(init))) inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(*parts)) @@ -107,6 +115,7 @@ inline fun EntitiesBuilder.mention(text: String, user: User) = inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(parts)) +inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(buildEntities(init))) inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(*parts)) @@ -122,6 +131,7 @@ inline fun EntitiesBuilder.regular(text: String) = inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(parts)) +inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(buildEntities(init))) inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(*parts)) @@ -137,6 +147,7 @@ inline fun EntitiesBuilder.link(url: String) = inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(parts)) +inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(buildEntities(init))) inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(*parts)) From f5b248f534320971b0b31e445f7ca0da428166a9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 5 Jun 2021 15:48:38 +0600 Subject: [PATCH 62/63] update micro_utils --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94e7777081..15281370fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ * `Common`: * `Version`: * `Kotlin`: `1.4.72` -> `1.5.10` - * `MicroUtils`: `0.4.36` -> `0.5.5` + * `MicroUtils`: `0.4.36` -> `0.5.6` * `Coroutines`: `1.4.3` -> `1.5.0` * `Serialization`: `1.1.0` -> `1.2.1` * `Klock`: `2.0.7` -> `2.1.2` diff --git a/gradle.properties b/gradle.properties index 4264d5b0b6..5fe3601c03 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.1.2 uuid_version=0.3.0 ktor_version=1.6.0 -micro_utils_version=0.5.5 +micro_utils_version=0.5.6 javax_activation_version=1.1.1 From fcd8f20a9030658fb52c2975638892a1272029e4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 17 Jun 2021 15:34:53 +0600 Subject: [PATCH 63/63] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 512a0dfe10..c8ed2c416f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Hello! This is a set of libraries for working with Telegram Bot API. | Common info | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://github.com/InsanusMokrassar/TelegramBotAPI/workflows/Build/badge.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [Small survey](https://forms.gle/2Hex2ynbHWHhi1KY7)| | -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| Useful links | [![Chat in Telegram](badges/chat.svg)](https://t.me/InMoTelegramBotAPI) [![Create bot](badges/template.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![KDocs](badges/kdocs.svg)](https://tgbotapi.inmo.dev/docs/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | +| Useful links | [![Chat in Telegram](badges/chat.svg)](https://t.me/InMoTelegramBotAPI) [![Create bot](badges/template.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![KDocs](badges/kdocs.svg)](https://tgbotapi.inmo.dev/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | | TelegramBotAPI Core status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) | | TelegramBotAPI API Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) | | TelegramBotAPI Util Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils) |