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..9d26482cd4 100644 --- a/.github/workflows/packages_publishing.yml +++ b/.github/workflows/packages_publishing.yml @@ -14,10 +14,8 @@ 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 + run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication env: GITHUBPACKAGES_USER: ${{ github.actor }} GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 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/CHANGELOG.md b/CHANGELOG.md index 20e22e133d..15281370fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,71 @@ # TelegramBotAPI changelog +## 0.35.0 + +**ALL PREVIOUS DEPRECATIONS HAVE BEEN REMOVED** +**JS PART NOW USE IR COMPILER ONLY** + +* `Common`: + * `Version`: + * `Kotlin`: `1.4.72` -> `1.5.10` + * `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` + * `UUID`: `0.2.3` -> `0.3.0` + * `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 + * `TextSource` interface and all related things have been replaced + * `CallbackQuery` interface and all its extenders/implementers 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` + * For `EntitiesBuilder` multilevel text sources builders with callback have been added + +## 0.34.1 + +* `Common`: + * `Version`: + * `ktor`: `1.5.3` -> `1.5.4` + * `MicroUtils`: `0.4.35` -> `0.4.36` +* `Core` + * Fix in creating of text sources list + +## 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**_ + +* `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 + * New type `InputInvoiceMessageContent` has been added + * 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 + * Interface `VoiceChatEvent` now is `CommonEvent` + * Mechanism of `RawMessageEntity` converting were fully rewritten + ## 0.33.4 * `Common`: 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) | diff --git a/build.gradle b/build.gradle index bfdfa696d5..b421f2d67a 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,13 @@ plugins { allprojects { repositories { maven { url 'https://jitpack.io' } + if (it != rootProject.findProject("docs")) { + tasks.whenTaskAdded { task -> + if (task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") { + task.enabled = false + } + } + } } } 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/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 diff --git a/gradle.properties b/gradle.properties index a74e4d5857..5fe3601c03 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,18 +5,18 @@ 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 -ktor_version=1.5.3 +kotlin_version=1.5.10 +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.6.0 -micro_utils_version=0.4.35 +micro_utils_version=0.5.6 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.33.4 +library_version=0.35.0 github_release_plugin_version=2.2.12 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 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? diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index be6596e3be..e0db3fa289 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -31,10 +31,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/Captioned.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt deleted file mode 100644 index 0b5ed05d2c..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt +++ /dev/null @@ -1,26 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -import dev.inmo.tgbotapi.types.ParseMode.ParseMode - -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] - */ - val captionEntities: List -} - -/** - * @see CaptionedInput.captionEntities - * @see justTextSources - */ -val CaptionedInput.textSources - get() = captionEntities.justTextSources() 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..4c7e225ff7 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt @@ -0,0 +1,36 @@ +package dev.inmo.tgbotapi.CommonAbstracts + +import dev.inmo.tgbotapi.types.payments.abstracts.Currencied +import dev.inmo.tgbotapi.types.payments.abstracts.Priced + +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/CommonAbstracts/Explained.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt deleted file mode 100644 index 05e7cd1c63..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt +++ /dev/null @@ -1,31 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -import dev.inmo.tgbotapi.types.ParseMode.ParseMode - -interface Explained { - val explanation: String? -} - -interface ParsableExplainedOutput : Explained { - val parseMode: ParseMode? -} - -interface EntitiesExplainedOutput : Explained { - val entities: List? -} - -interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput - -interface ExplainedInput : Explained { - /** - * Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - */ - val explanationEntities: List -} - -/** - * @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..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 @@ -1,98 +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.toTextParts +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.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.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" +const val DirectInvocationOfTextSourceConstructor = + "It is strongly not recommended to use constructors directly instead of factory methods" -typealias TextSourcesList = List +@Deprecated( + "Replaced", + ReplaceWith("TextSourcesList", "dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList") +) +typealias TextSourcesList = TextSourcesList -@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 - } -} +@Deprecated("Replaced", ReplaceWith("TextSource", "dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource")) +typealias TextSource = TextSource @Suppress("NOTHING_TO_INLINE") -inline operator fun TextSource.plus(other: TextSource) = listOf(this, other) +@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) +inline operator fun TextSource.plus(other: TextSource) = + listOf(this, other) + @Suppress("NOTHING_TO_INLINE") -inline operator fun TextSource.plus(other: List) = listOf(this) + other +@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) +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)) +@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) +inline operator fun TextSource.plus(text: String) = + listOf(this, regular(text)) + @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) -@Serializable(TextSourceSerializer::class) -interface MultilevelTextSource : TextSource { - val subsources: List - - companion object { - fun serializer() = TextSourceSerializer - } -} - -data class TextPart( - val range: IntRange, - val source: TextSource +@Deprecated( + "Replaced", + ReplaceWith("MultilevelTextSource", "dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource") ) +typealias MultilevelTextSource = MultilevelTextSource -fun List.justTextSources() = map { it.source } -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() - } +@Deprecated("Replaced", ReplaceWith("makeString()", "dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString")) +fun List.makeString() = makeString() - 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 -} +@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 0b556444e5..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 @@ -1,35 +1,29 @@ package dev.inmo.tgbotapi.CommonAbstracts +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.ParseMode.ParseMode interface Texted { val text: String? } +interface TextedWithTextSources : Texted { + /** + * Full list of [TextSource]s + */ + 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 { - /** - * 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 +interface TextedInput : TextedWithTextSources { + override val textSources: List } - -/** - * 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/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..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,7 +4,8 @@ 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.types.InlineQueries.query.InlineQuery +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.serializer @@ -26,7 +27,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() @@ -51,6 +52,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 617970f108..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,10 +1,11 @@ package dev.inmo.tgbotapi.requests.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -32,7 +33,7 @@ fun EditChatMessageCaption( fun EditChatMessageCaption( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageCaption( chatId, @@ -58,8 +59,8 @@ data class EditChatMessageCaption internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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..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,9 +1,10 @@ package dev.inmo.tgbotapi.requests.edit.caption -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -24,7 +25,7 @@ fun EditInlineMessageCaption( fun EditInlineMessageCaption( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageCaption( inlineMessageId, @@ -47,8 +48,8 @@ data class EditInlineMessageCaption internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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..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,10 +1,11 @@ package dev.inmo.tgbotapi.requests.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -34,7 +35,7 @@ fun EditChatMessageText( fun EditChatMessageText( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageText( @@ -64,8 +65,8 @@ data class EditChatMessageText internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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..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,9 +1,10 @@ package dev.inmo.tgbotapi.requests.edit.text -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -26,7 +27,7 @@ fun EditInlineMessageText( fun EditInlineMessageText( inlineMessageId: InlineMessageIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageText( @@ -53,8 +54,8 @@ data class EditInlineMessageText internal constructor( @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + rawEntities ?.asTextSources(text) } override fun method(): String = editMessageTextMethod 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 4ddbf8e68f..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,11 +1,13 @@ package dev.inmo.tgbotapi.requests.send -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput 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 @@ -32,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( @@ -62,8 +75,8 @@ data class CopyMessage internal constructor( TextedOutput { override val chatId: ChatIdentifier get() = fromChatId - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: List? by lazy { + 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..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,10 +1,11 @@ package dev.inmo.tgbotapi.requests.send -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -40,7 +41,7 @@ fun SendTextMessage( fun SendTextMessage( chatId: ChatIdentifier, - entities: List, + entities: TextSourcesList, disableWebPagePreview: Boolean? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -83,8 +84,8 @@ data class SendTextMessage internal constructor( TextableSendMessageRequest>, DisableWebPagePreview { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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 4e58cc23a4..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,11 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -20,7 +21,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, @@ -39,7 +40,7 @@ fun SendAnimation( chatId, animationAsFileId, thumbAsFileId, - caption, + text, parseMode, null, duration, @@ -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,8 +145,8 @@ data class SendAnimationData internal constructor( DuratedSendMessageRequest>, SizedSendMessageRequest> { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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 82e15305a9..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,11 +1,13 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.Performerable 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 @@ -20,7 +22,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, @@ -39,7 +41,7 @@ fun SendAudio( chatId, audioAsFileId, thumbAsFileId, - caption, + text, parseMode, null, duration, @@ -145,8 +147,8 @@ data class SendAudioData internal constructor( DuratedSendMessageRequest>, Performerable { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: List? by lazy { + 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 6a515be8a4..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,11 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -29,7 +30,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, @@ -46,7 +47,7 @@ fun SendDocument( chatId, documentAsFileId, thumbAsFileId, - caption, + text, parseMode, null, disableNotification, @@ -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,8 +158,8 @@ data class SendDocumentData internal constructor( TextableSendMessageRequest>, ThumbedSendMessageRequest> { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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 c492456f31..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,11 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -18,7 +19,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, @@ -28,7 +29,7 @@ fun SendPhoto( val data = SendPhotoData( chatId, (photo as? FileId) ?.fileId, - caption, + text, parseMode, null, disableNotification, @@ -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, @@ -55,7 +56,7 @@ fun SendPhoto( ): Request> { val data = SendPhotoData( chatId, - (photo as? FileId) ?.fileId, + (photo as? FileId)?.fileId, entities.makeString(), null, entities.toRawMessageEntities(), @@ -100,8 +101,8 @@ data class SendPhotoData internal constructor( ReplyingMarkupSendMessageRequest>, TextableSendMessageRequest> { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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 52e7ae8ba3..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,11 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -20,7 +21,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, @@ -40,7 +41,7 @@ fun SendVideo( chatId, videoAsFileId, thumbAsFileId, - caption, + text, parseMode, null, duration, @@ -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,8 +151,8 @@ data class SendVideoData internal constructor( DuratedSendMessageRequest>, SizedSendMessageRequest> { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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 69e6d0f756..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,11 +1,12 @@ package dev.inmo.tgbotapi.requests.send.media -import dev.inmo.tgbotapi.CommonAbstracts.* 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 @@ -19,7 +20,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, @@ -33,7 +34,7 @@ fun SendVoice( val data = SendVoiceData( chatId, voiceAsFileId, - caption, + text, parseMode, null, duration, @@ -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,8 +121,8 @@ data class SendVoiceData internal constructor( TextableSendMessageRequest>, DuratedSendMessageRequest> { - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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..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 @@ -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.* @@ -9,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> @@ -23,36 +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, - @SerialName(startParameterField) - val startParameter: StartParameter, + 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(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) @@ -61,8 +66,7 @@ data class SendInvoice( override val allowSendingWithoutReply: Boolean? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null -) : Currencied, - Priced, +) : CommonSendInvoiceData, ChatRequest, DisableNotification, ReplyMessageId, @@ -75,24 +79,35 @@ 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 - fun setPhoto( + init { + suggestedTipAmounts ?.let { _ -> + require(suggestedTipAmounts.size in suggestedTipAmountsLimit) + maxTipAmount ?.let { _ -> + require( + suggestedTipAmounts.none { it > maxTipAmount } + ) + } + } + } + + 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 @@ -100,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/requests/send/polls/SendPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt index 2af52017ef..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 @@ -1,11 +1,13 @@ 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.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 @@ -338,7 +340,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 +357,12 @@ data class SendQuizPoll internal constructor( override val allowSendingWithoutReply: Boolean? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null -) : SendPoll(), ExplainedOutput { +) : SendPoll(), TextedOutput { override val type: String = quizPollType override val requestSerializer: SerializationStrategy<*> get() = serializer() - override val entities: List? by lazy { - rawEntities ?.asTextParts(explanation ?: return@lazy null) ?.justTextSources() + override val textSources: List? by lazy { + rawEntities ?.asTextSources(text ?: return@lazy null) } init { @@ -371,9 +373,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/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/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..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,7 +80,7 @@ data class CommonInviteLink( get() = expireDate ?.asDate } -@Serializer(ChatInviteLink::class) +@RiskFeature object ChatInviteLinkSerializer : KSerializer { override val descriptor: SerialDescriptor get() = RawChatInviteLink.serializer().descriptor 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..50990b860c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.types.ChatMember + +import dev.inmo.tgbotapi.types.* +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..3adbac1b3c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.types.ChatMember + +import dev.inmo.tgbotapi.types.* +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/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 d7c3f9b0ce..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 @@ -13,11 +13,10 @@ import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.jsonPrimitive @Serializable(ChatMemberSerializer::class) -interface ChatMember { +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/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/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index c1c935fb26..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 @@ -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,10 @@ 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 chatTypeField = "chat_type" + const val explanationEntitiesField = "explanation_entities" const val explanationParseModeField = "explanation_parse_mode" const val openPeriodField = "open_period" @@ -349,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/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 30f23487c8..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,12 +1,13 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* 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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -25,10 +26,18 @@ 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) +) = InlineQueryResultAudioCachedImpl( + id, + fileId, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultAudioCachedImpl internal constructor( @@ -48,7 +57,7 @@ data class InlineQueryResultAudioCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultAudioCached { override val type: String = inlineQueryResultAudioType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 f4221fae20..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,11 +1,12 @@ 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.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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -30,10 +31,21 @@ 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) +) = InlineQueryResultAudioImpl( + id, + url, + title, + performer, + duration, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultAudioImpl internal constructor( @@ -59,7 +71,7 @@ data class InlineQueryResultAudioImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultAudio { override val type: String = inlineQueryResultAudioType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 2b7bd33291..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,12 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* 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.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -29,10 +29,20 @@ 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) +) = InlineQueryResultDocumentCachedImpl( + id, + fileId, + title, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultDocumentCachedImpl internal constructor( @@ -56,7 +66,7 @@ data class InlineQueryResultDocumentCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultDocumentCached { override val type: String = inlineQueryResultDocumentType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 bca7294ef3..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,11 +1,12 @@ 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.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.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,10 +39,24 @@ 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) +) = InlineQueryResultDocumentImpl( + id, + url, + title, + mimeType, + thumbUrl, + thumbWidth, + thumbHeight, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultDocumentImpl internal constructor( @@ -73,7 +88,7 @@ data class InlineQueryResultDocumentImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultDocument { override val type: String = inlineQueryResultDocumentType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 a65dd530ac..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,12 +1,13 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* 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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -27,10 +28,19 @@ 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) +) = InlineQueryResultGifCachedImpl( + id, + fileId, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultGifCachedImpl internal constructor( @@ -52,7 +62,7 @@ data class InlineQueryResultGifCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultGifCached { override val type: String = inlineQueryResultGifType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 d282045d62..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,11 +1,12 @@ 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.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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -37,10 +38,24 @@ 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) +) = InlineQueryResultGifImpl( + id, + url, + thumbUrl, + thumbMimeType, + width, + height, + duration, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultGifImpl internal constructor( @@ -72,8 +87,8 @@ data class InlineQueryResultGifImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultGif { override val type: String = inlineQueryResultGifType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + rawEntities ?.asTextSources(text ?: return@lazy null) } init { 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 d7726fa700..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,12 +1,13 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* 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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -27,10 +28,19 @@ 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) +) = InlineQueryResultMpeg4GifCachedImpl( + id, + fileId, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultMpeg4GifCachedImpl internal constructor( @@ -52,7 +62,7 @@ data class InlineQueryResultMpeg4GifCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultMpeg4GifCached { override val type: String = inlineQueryResultMpeg4GifType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 9b07306447..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,11 +1,12 @@ 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.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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -37,10 +38,24 @@ 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) +) = InlineQueryResultMpeg4GifImpl( + id, + url, + thumbUrl, + thumbMimeType, + width, + height, + duration, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultMpeg4GifImpl internal constructor( @@ -72,8 +87,8 @@ data class InlineQueryResultMpeg4GifImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultMpeg4Gif { override val type: String = inlineQueryResultMpeg4GifType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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..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,12 +1,13 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* 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.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,10 +30,20 @@ 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) +) = InlineQueryResultPhotoCachedImpl( + id, + fileId, + title, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultPhotoCachedImpl internal constructor( @@ -56,7 +67,7 @@ data class InlineQueryResultPhotoCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultPhotoCached { override val type: String = inlineQueryResultPhotoType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? 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 332a2ce09c..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,11 +1,12 @@ 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.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.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,10 +35,23 @@ 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) +) = InlineQueryResultPhotoImpl( + id, + url, + thumbUrl, + width, + height, + title, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultPhotoImpl internal constructor( @@ -67,7 +81,7 @@ data class InlineQueryResultPhotoImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultPhoto { override val type: String = inlineQueryResultPhotoType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 8fe16705c5..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,12 +1,13 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* 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.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,10 +30,20 @@ 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) +) = InlineQueryResultVideoCachedImpl( + id, + fileId, + title, + description, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultVideoCachedImpl internal constructor( @@ -56,7 +67,7 @@ data class InlineQueryResultVideoCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVideoCached { override val type: String = inlineQueryResultVideoType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 e055c7f468..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,11 +1,12 @@ 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.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.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -43,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( @@ -77,7 +93,7 @@ data class InlineQueryResultVideoImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVideo { override val type: String = inlineQueryResultVideoType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 e5e236120d..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,12 +1,12 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult -import dev.inmo.tgbotapi.CommonAbstracts.* 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.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -27,10 +27,19 @@ 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) +) = InlineQueryResultVoiceCachedImpl( + id, + fileId, + title, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultVoiceCachedImpl internal constructor( @@ -52,7 +61,7 @@ data class InlineQueryResultVoiceCachedImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVoiceCached { override val type: String = inlineQueryResultVoiceType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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 02c4189ed8..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,11 +1,11 @@ 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.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.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -38,10 +38,20 @@ 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) +) = InlineQueryResultVoiceImpl( + id, + url, + title, + duration, + entities.makeString(), + null, + entities.toRawMessageEntities(), + replyMarkup, + inputMessageContent +) @Serializable data class InlineQueryResultVoiceImpl internal constructor( @@ -65,7 +75,7 @@ data class InlineQueryResultVoiceImpl internal constructor( override val inputMessageContent: InputMessageContent? = null ) : InlineQueryResultVoice { override val type: String = inlineQueryResultVoiceType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + 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/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 new file mode 100644 index 0000000000..9f129a847a --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputInvoiceMessageContent.kt @@ -0,0 +1,79 @@ +package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent + +import dev.inmo.tgbotapi.CommonAbstracts.CommonSendInvoiceData +import dev.inmo.tgbotapi.types.* +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/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 5871b5a144..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.InlineQueries.abstracts.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 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 entities: List? by lazy { - rawEntities ?.asTextParts(text) ?.justTextSources() + override val textSources: TextSourcesList? 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/InputMessageContentSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSerializer.kt index 58e4c76a13..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) { @@ -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") } } 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..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,11 +1,6 @@ package dev.inmo.tgbotapi.types.InlineQueries.abstracts -import dev.inmo.tgbotapi.types.InlineQueryIdentifier -import dev.inmo.tgbotapi.types.User +import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery -interface InlineQuery { - val id: InlineQueryIdentifier - val from: User - val query: String - val offset: String -} \ 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..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,7 +1,6 @@ package dev.inmo.tgbotapi.types.InlineQueries.abstracts -import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContentSerializer -import kotlinx.serialization.Serializable +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent -@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 ba1e09280a..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,12 +1,13 @@ 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/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 fe94c7e34d..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,8 +1,8 @@ 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 data class LocationInlineQuery( @@ -10,5 +10,6 @@ data class LocationInlineQuery( 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..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 @@ -1,6 +1,8 @@ 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 @@ -15,12 +17,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/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 77eaec8b68..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,10 +1,11 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput 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.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.SerialName @@ -22,12 +23,21 @@ fun InputMediaAnimation( fun InputMediaAnimation( file: InputFile, - entities: List, + entities: TextSourcesList, width: Int? = null, 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( @@ -44,8 +54,8 @@ 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 { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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 5dc1aba16f..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,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.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 @@ -14,7 +16,7 @@ internal const val audioInputMediaType = "audio" fun InputMediaAudio( file: InputFile, - entities: List, + entities: TextSourcesList, duration: Long? = null, performer: String? = null, title: String? = null, @@ -50,8 +52,8 @@ 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 { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + rawEntities ?.asTextSources(text ?: return@lazy null) } override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) @@ -62,12 +64,12 @@ data class InputMediaAudio internal constructor( } fun AudioFile.toInputMediaAudio( - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null, 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/InputMediaDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt index 94e5af6b31..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,9 +1,9 @@ package dev.inmo.tgbotapi.types.InputMedia -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.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.DocumentFile @@ -13,18 +13,25 @@ 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, - entities: List, + 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 @@ -50,8 +57,8 @@ data class InputMediaDocument internal constructor( val disableContentTypeDetection: Boolean? = null ) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia { override val type: String = documentInputMediaType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + rawEntities ?.asTextSources(text ?: return@lazy null) } override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) @@ -62,11 +69,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..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,10 +1,10 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.* 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.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.files.PhotoSize @@ -20,7 +20,7 @@ fun InputMediaPhoto( fun InputMediaPhoto( file: InputFile, - entities: List + entities: TextSourcesList ) = InputMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities()) @Serializable @@ -34,8 +34,8 @@ data class InputMediaPhoto internal constructor( private val rawEntities: List? = null ) : InputMedia, VisualMediaGroupMemberInputMedia { override val type: String = photoInputMediaType - override val entities: List? by lazy { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + rawEntities ?.asTextSources(text ?: return@lazy null) } override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this) @@ -46,11 +46,11 @@ data class InputMediaPhoto internal constructor( } fun PhotoSize.toInputMediaPhoto( - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null ): InputMediaPhoto = InputMediaPhoto( fileId, - caption, + text, parseMode ) 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 f7907dd023..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,10 +1,10 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.* 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.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import kotlinx.serialization.* @@ -23,7 +23,7 @@ fun InputMediaVideo( fun InputMediaVideo( file: InputFile, - entities: List, + entities: TextSourcesList, width: Int? = null, height: Int? = null, duration: Long? = null, @@ -45,8 +45,8 @@ 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 { - rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() + override val textSources: TextSourcesList? by lazy { + 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/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/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/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 d8bff5f11d..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,10 +1,7 @@ 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 +12,125 @@ 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: TextSourcesList +): 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 TextSourcesList.fillWithRegulars(source: String): TextSourcesList { + 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, index) + 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 +): TextSourcesList { + 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,60 +138,54 @@ 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 TextSourcesList.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 { textSource -> + textSource.toRawMessageEntities(i).also { + 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 = toTextParts().asRawMessageEntities() +internal fun TextSourcesList.toRawMessageEntities(): List = toRawMessageEntities(0) -internal fun RawMessageEntities.asTextParts(sourceString: String): List = sourceString.fullListOfSubSource( - createTextPart(sourceString, this) -) +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 b577bc040f..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 @@ -1,9 +1,7 @@ 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 /** @@ -12,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() } @@ -20,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/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..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 @@ -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 @@ -11,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() } @@ -19,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/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..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 @@ -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 @@ -11,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) } @@ -19,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 506bc6a584..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 @@ -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 @@ -11,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() } @@ -25,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 61bb66bde3..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 @@ -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 @@ -11,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() } @@ -19,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 0dce181677..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 @@ -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 @@ -18,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() } @@ -32,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 ae1ef0239f..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 @@ -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 @@ -11,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() } @@ -19,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/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..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 @@ -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 @@ -11,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() } @@ -19,8 +18,8 @@ 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") -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..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 @@ -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.* @@ -13,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) } @@ -21,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 new file mode 100644 index 0000000000..3ac89386a4 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt @@ -0,0 +1,89 @@ +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 +typealias MutableTextSourcesList = MutableList + +@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 a9f76a93ad..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,15 +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.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.* +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/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..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 @@ -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 @@ -11,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() } @@ -19,8 +18,8 @@ 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") -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..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 @@ -1,31 +1,34 @@ 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 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 +@Serializable(ParseModeSerializer::class) +sealed interface ParseMode { + val parseModeName: String } -@Serializable(ParseModeSerializerObject::class) -object MarkdownParseMode : ParseMode() { +@Serializable(ParseModeSerializer::class) +object MarkdownParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "Markdown" } -@Serializable(ParseModeSerializerObject::class) -object MarkdownV2ParseMode : ParseMode() { +@Serializable(ParseModeSerializer::class) +object MarkdownV2ParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "MarkdownV2" } -@Serializable(ParseModeSerializerObject::class) -object HTMLParseMode : ParseMode() { +@Serializable(ParseModeSerializer::class) +object HTMLParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "HTML" @@ -43,8 +46,9 @@ typealias HTML = HTMLParseMode */ var defaultParseMode: ParseMode = HTML -@Serializer(ParseMode::class) -internal object ParseModeSerializerObject : KSerializer { +@RiskFeature +object ParseModeSerializer : 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/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 6732f68fad..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 @@ -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,13 @@ 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 { +object BotActionSerializer: KSerializer { + override val descriptor: SerialDescriptor = String.serializer().descriptor + override fun serialize(encoder: Encoder, value: BotAction) { encoder.encodeString(value.actionName) } @@ -24,8 +27,8 @@ 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 FindLocationAction.actionName -> FindLocationAction RecordVideoNoteAction.actionName -> RecordVideoNoteAction @@ -39,7 +42,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 @@ -50,7 +53,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 @@ -61,7 +64,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 @@ -72,7 +75,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 @@ -83,29 +86,29 @@ inline fun BotAction.asUploadVideo() = this as? UploadVideoAction * Will notify user that bot is recording some audio */ @Serializable(BotActionSerializer::class) -object RecordAudioAction : BotAction() { - override val actionName: String = "record_audio" +object RecordVoiceAction : BotAction { + override val actionName: String = "record_voice" } -inline val recordAudio - get() = RecordAudioAction -inline fun BotAction.asRecordAudio() = this as? RecordAudioAction +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 UploadAudioAction : BotAction() { - override val actionName: String = "upload_audio" +object UploadVoiceAction : BotAction { + override val actionName: String = "upload_voice" } -inline val uploadAudio - get() = UploadAudioAction -inline fun BotAction.asUploadAudio() = this as? UploadAudioAction +inline val uploadVoice + get() = UploadVoiceAction +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 @@ -116,7 +119,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 @@ -127,7 +130,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 @@ -138,7 +141,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 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/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 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/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") } } } 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..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,32 +1,34 @@ 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 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 +36,7 @@ data class RequestContactKeyboardButton( @Serializable data class RequestLocationKeyboardButton( override val text: String -) : KeyboardButton() { +) : KeyboardButton { @SerialName(requestLocationField) val requestLocation: Boolean = true } @@ -44,12 +46,15 @@ data class RequestPollKeyboardButton( override val text: String, @SerialName(requestPollField) val requestPoll: KeyboardButtonPollType -) : KeyboardButton() +) : KeyboardButton + +@RiskFeature +object KeyboardButtonSerializer : KSerializer { + private val internalSerializer = JsonElement.serializer() + override val descriptor: SerialDescriptor = internalSerializer.descriptor -@Serializer(KeyboardButton::class) -internal object KeyboardButtonSerializer : KSerializer { 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 +67,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..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,35 +1,38 @@ 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 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) +@RiskFeature +object KeyboardButtonPollTypeSerializer : KSerializer { + 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 +48,7 @@ internal object KeyboardButtonPollTypeSerializer : KSerializer { +@RiskFeature +object KeyboardMarkupSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor( KeyboardMarkup::class.toString(), @@ -14,7 +15,7 @@ internal object KeyboardMarkupSerializer : 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/chat/ChatSerializers.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt index 23a27339a0..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 @@ -4,10 +4,11 @@ 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.RiskFeature 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,21 +18,57 @@ import kotlinx.serialization.json.* private val formatter get() = nonstrictJsonFormat -internal object PreviewChatSerializer : KSerializer { +@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) + } + +@RiskFeature +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) + } +} + +@RiskFeature +object PreviewChatSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) 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() ) @@ -49,21 +86,26 @@ internal object PreviewChatSerializer : KSerializer { } } -internal object ExtendedChatSerializer : KSerializer { +@RiskFeature +object ExtendedChatSerializer : KSerializer { @InternalSerializationApi override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) 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 +} 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..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,48 +1,49 @@ 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 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,13 +51,13 @@ 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") } -@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 45b4525896..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 @@ -1,9 +1,9 @@ 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 +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 @@ -34,11 +34,11 @@ data class VideoFile( @Suppress("NOTHING_TO_INLINE") inline fun VideoFile.toInputMediaVideo( - caption: String? = null, + text: String? = null, parseMode: ParseMode? = null ) = InputMediaVideo( fileId, - caption, + text, parseMode, width, height, 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..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,8 @@ 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 @@ -8,7 +10,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 textSources: TextSourcesList = emptyList(), val animation: AnimationFile? = null -) : Titled, CaptionedInput +) : Titled, 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..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 @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.games 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.* @@ -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.asTextSources(text) } ?: emptyList(), animation ) } 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..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 @@ -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,12 @@ 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/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.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..8db852aecc --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.voice + +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 + +@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..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 @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.message 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 @@ -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, @@ -101,11 +102,11 @@ internal data class RawMessage( ) { private val content: MessageContent? by lazy { val adaptedCaptionEntities = caption ?.let { - (caption_entities ?: emptyList()).asTextParts(caption) + (caption_entities ?: emptyList()).asTextSources(caption) } ?: emptyList() when { - text != null -> TextContent(text, (entities ?: emptyList()).asTextParts(text)) + text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text)) audio != null -> AudioContent( audio, caption, @@ -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 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 abc204e63e..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 @@ -1,19 +1,18 @@ package dev.inmo.tgbotapi.types.message.content -import dev.inmo.tgbotapi.CommonAbstracts.* +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.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 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/abstracts/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/MediaGroupContent.kt index 7cf2eb6b16..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,9 +1,9 @@ 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 { +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 edbcb2312b..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,10 +1,11 @@ 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 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 @@ -15,9 +16,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 textSources: TextSourcesList = emptyList() +) : 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 2d4f9a7148..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 @@ -1,12 +1,11 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextPart -import dev.inmo.tgbotapi.CommonAbstracts.textSources import dev.inmo.tgbotapi.requests.abstracts.Request 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 @@ -15,8 +14,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 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 747cc77fdb..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,11 +1,12 @@ 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.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 @@ -16,8 +17,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 textSources: TextSourcesList = emptyList() ) : DocumentMediaGroupContent { override fun createResend( chatId: ChatIdentifier, @@ -43,10 +44,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, + 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 27fc6102fa..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,12 +1,11 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextPart -import dev.inmo.tgbotapi.CommonAbstracts.textSources 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.* @@ -16,8 +15,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 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 5b1ec9197b..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,11 +1,10 @@ package dev.inmo.tgbotapi.types.message.content.media -import dev.inmo.tgbotapi.CommonAbstracts.TextPart -import dev.inmo.tgbotapi.CommonAbstracts.textSources 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 @@ -15,8 +14,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 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 421f2b6a75..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,10 +1,11 @@ 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 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 @@ -13,9 +14,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 textSources: TextSourcesList = emptyList() +) : MediaContent, TextedInput { override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, 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..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,7 +35,7 @@ val encryptedElementsClassesByTypes = mapOf( val EncryptedPassportElement.type: String get() = encryptedElementsClassesByTypes.keys.firstOrNull { encryptedElementsClassesByTypes.getValue(it).klass.isInstance(this) } ?: "unknown" -@Serializer(EncryptedPassportElement::class) +@RiskFeature 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 8ca845fcd0..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.ExplainedInput -import dev.inmo.tgbotapi.CommonAbstracts.TextPart +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 @@ -13,19 +14,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 +43,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 +106,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 +124,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( @@ -135,15 +136,15 @@ 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 explanationEntities: List = emptyList(), + override val text: String? = null, + override val textSources: List = emptyList(), 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 { +@RiskFeature +object PollSerializer : KSerializer { override val descriptor: SerialDescriptor get() = RawPoll.serializer().descriptor @@ -159,7 +160,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 @@ -210,8 +211,8 @@ internal object PollSerializer : KSerializer { value.isAnonymous, regularPollType, correctOptionId = value.correctOptionId, - explanation = value.explanation, - explanationEntities = value.explanationEntities.asRawMessageEntities(), + 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.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 bac1e06c41..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,82 +1,16 @@ 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.* 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("") { +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 a0f688c821..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 ) @@ -20,8 +21,8 @@ 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 FindLocationAction -> example.botAction.actionName RecordVideoNoteAction -> example.botAction.actionName @@ -49,8 +50,8 @@ class BotActionTests { UploadPhotoAction.example(), RecordVideoAction.example(), UploadVideoAction.example(), - RecordAudioAction.example(), - UploadAudioAction.example(), + RecordVoiceAction.example(), + UploadVoiceAction.example(), UploadDocumentAction.example(), FindLocationAction.example(), RecordVideoNoteAction.example(), 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/MessageEntity/EntitiesTestText.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt index b75814dcf1..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 @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity -import dev.inmo.tgbotapi.CommonAbstracts.TextPart import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import kotlin.test.assertTrue @@ -36,19 +35,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 TextSourcesList.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..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,7 +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.* import kotlin.test.Test @@ -40,7 +38,7 @@ class StringFormattingTests { @Test fun testThatCreatingOfStringWithSimpleDSLWorksCorrectly() { - val sources: List = regular("It ") + + val sources: TextSourcesList = regular("It ") + bold(italic("is") + " " + strikethrough(underline("simple"))) + @@ -48,7 +46,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.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 1dd7e893ef..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,13 +1,10 @@ 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.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourceSerializer -import kotlinx.serialization.PolymorphicSerializer +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.encodeToString import kotlin.test.Test import kotlin.test.assertEquals @@ -29,12 +26,12 @@ 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) assertEquals(testList.makeString(), deserialized.makeString()) } -} \ No newline at end of file +} 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..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,7 +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.abstracts.InlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.InlineQueryIdentifier suspend fun TelegramBot.answerInlineQuery( 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..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.CaptionedInput -import dev.inmo.tgbotapi.CommonAbstracts.TextSource +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 @@ -35,14 +36,14 @@ suspend fun TelegramBot.editMessageCaption( text: String, parseMode: ParseMode? = null, replyMarkup: InlineKeyboardMarkup? = null -): ContentMessage where T : CaptionedInput, T : MediaContent { +): ContentMessage where T : TextedWithTextSources, T : MediaContent { return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) } suspend fun TelegramBot.editMessageCaption( chatId: ChatIdentifier, messageId: MessageIdentifier, - entities: List, + entities: TextSourcesList, replyMarkup: InlineKeyboardMarkup? = null ) = execute( EditChatMessageCaption(chatId, messageId, entities, replyMarkup) @@ -59,6 +60,6 @@ suspend fun TelegramBot.editMessageCaption( message: ContentMessage, entities: List, replyMarkup: InlineKeyboardMarkup? = null -): ContentMessage where T : CaptionedInput, T : MediaContent { +): ContentMessage where T : TextedWithTextSources, 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/edit/caption/EditInlineMessageCaption.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt index 00df5eea1e..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 @@ -1,9 +1,9 @@ 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 +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -16,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 1e9f460310..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 @@ -1,9 +1,9 @@ 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 +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 +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( @@ -52,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) \ 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..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 @@ -1,9 +1,9 @@ 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 +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -17,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/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.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..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 @@ -1,9 +1,9 @@ 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 +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 @@ -87,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, @@ -100,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, @@ -111,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, @@ -122,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, @@ -132,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, @@ -142,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/SendAction.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt index 05ab7eb80f..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,13 +35,13 @@ suspend fun TelegramBot.sendActionUploadVideo( chatId: ChatIdentifier ) = sendBotAction(chatId, UploadVideoAction) -suspend fun TelegramBot.sendActionRecordAudio( +suspend fun TelegramBot.sendActionRecordVoice( chatId: ChatIdentifier -) = sendBotAction(chatId, RecordAudioAction) +) = sendBotAction(chatId, RecordVoiceAction) -suspend fun TelegramBot.sendActionUploadAudio( +suspend fun TelegramBot.sendActionUploadVoice( chatId: ChatIdentifier -) = sendBotAction(chatId, UploadAudioAction) +) = sendBotAction(chatId, UploadVoiceAction) suspend fun TelegramBot.sendActionUploadDocument( chatId: ChatIdentifier @@ -76,13 +76,13 @@ suspend fun TelegramBot.sendActionUploadVideo( chat: Chat ) = sendBotAction(chat, UploadVideoAction) -suspend fun TelegramBot.sendActionRecordAudio( +suspend fun TelegramBot.sendActionRecordVoice( chat: Chat -) = sendBotAction(chat, RecordAudioAction) +) = sendBotAction(chat, RecordVoiceAction) -suspend fun TelegramBot.sendActionUploadAudio( +suspend fun TelegramBot.sendActionUploadVoice( chat: Chat -) = sendBotAction(chat, UploadAudioAction) +) = sendBotAction(chat, UploadVoiceAction) suspend fun TelegramBot.sendActionUploadDocument( chat: Chat 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..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,8 +56,8 @@ 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) -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) @@ -68,8 +68,8 @@ 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) -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.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..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 @@ -1,9 +1,9 @@ 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 +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 @@ -61,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, @@ -73,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, @@ -85,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, @@ -96,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, @@ -124,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 95a4c4bcdc..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 @@ -1,10 +1,10 @@ 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 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 @@ -145,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, @@ -172,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, @@ -188,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, @@ -201,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, @@ -215,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, @@ -239,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, @@ -251,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 e6cfab19f9..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 @@ -1,10 +1,10 @@ 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 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 @@ -122,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, @@ -150,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, @@ -163,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, @@ -174,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, @@ -186,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, @@ -198,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, @@ -208,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 1fab4cc11b..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 @@ -1,10 +1,10 @@ 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 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 @@ -116,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, @@ -140,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, @@ -151,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, @@ -164,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, @@ -176,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, @@ -186,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, @@ -196,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 d4ee9ed59d..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 @@ -1,10 +1,10 @@ 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 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 @@ -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,71 +38,71 @@ 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( chatId: ChatIdentifier, fileId: InputFile, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, allowSendingWithoutReply: Boolean? = null, @@ -122,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, @@ -132,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, @@ -142,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, @@ -152,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 @@ -161,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 @@ -170,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 962b265ace..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 @@ -1,10 +1,10 @@ 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 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 @@ -120,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, @@ -148,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, @@ -159,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, @@ -173,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, @@ -184,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, @@ -196,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 @@ -205,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 21b87b0e66..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 @@ -1,10 +1,10 @@ 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 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 @@ -107,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, @@ -129,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, @@ -140,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, @@ -152,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, @@ -162,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, @@ -172,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 @@ -181,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/payments/SendInvoice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt index 3af85856f1..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 @@ -14,9 +14,11 @@ suspend fun TelegramBot.sendInvoice( description: String, payload: String, providerToken: String, - startParameter: StartParameter, currency: Currency, prices: List, + maxTipAmount: Int? = null, + suggestedTipAmounts: List? = null, + startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, requirePhoneNumber: Boolean = false, @@ -30,7 +32,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, maxTipAmount, suggestedTipAmounts ?.sorted(), startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) suspend fun TelegramBot.sendInvoice( @@ -39,9 +41,11 @@ suspend fun TelegramBot.sendInvoice( description: String, payload: String, providerToken: String, - startParameter: StartParameter, currency: Currency, prices: List, + maxTipAmount: Int? = null, + suggestedTipAmounts: List? = null, + startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, requirePhoneNumber: 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, startParameter, currency, prices, 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, @@ -62,9 +66,11 @@ suspend inline fun TelegramBot.replyWithInvoice( description: String, payload: String, providerToken: String, - startParameter: StartParameter, currency: Currency, prices: List, + maxTipAmount: Int? = null, + suggestedTipAmounts: List? = null, + startParameter: StartParameter? = null, providerData: String? = null, requireName: Boolean = false, requirePhoneNumber: 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, 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, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) 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..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 @@ -1,10 +1,10 @@ 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 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 @@ -162,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, @@ -181,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, @@ -199,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, @@ -217,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, @@ -292,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, @@ -307,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/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/expectations/WaitInlineQuery.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt index c3de533c8e..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 @@ -3,9 +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.abstracts.InlineQuery -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? 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 0946a99140..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,8 +1,8 @@ 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.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.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..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 @@ -5,9 +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.abstracts.InlineQuery -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, 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 999f165c15..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 @@ -1,12 +1,14 @@ @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.CommonSendInvoiceData +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.* 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.* @@ -17,10 +19,8 @@ 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.query.BaseInlineQuery -import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent +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.* @@ -54,1241 +54,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.asRecordAudioAction(): RecordAudioAction? = this as? RecordAudioAction +inline fun BotAction.asRecordVoiceAction(): RecordVoiceAction? = this as? RecordVoiceAction + @PreviewFeature -inline fun BotAction.requireRecordAudioAction(): RecordAudioAction = this as RecordAudioAction +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.asUploadAudioAction(): UploadAudioAction? = this as? UploadAudioAction +inline fun BotAction.asUploadVoiceAction(): UploadVoiceAction? = this as? UploadVoiceAction + @PreviewFeature -inline fun BotAction.requireUploadAudioAction(): UploadAudioAction = this as UploadAudioAction +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 InlineQuery.asBaseInlineQuery(): BaseInlineQuery? = + this as? BaseInlineQuery + @PreviewFeature -inline fun InlineQuery.requireBaseInlineQuery(): BaseInlineQuery = this as BaseInlineQuery +inline fun InlineQuery.requireBaseInlineQuery(): BaseInlineQuery = + this as BaseInlineQuery + @PreviewFeature -inline fun InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = this as? LocationInlineQuery +inline fun InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = + this as? LocationInlineQuery + @PreviewFeature -inline fun InlineQuery.requireLocationInlineQuery(): LocationInlineQuery = this as LocationInlineQuery +inline fun 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 + +@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 +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(): 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 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 + +@PreviewFeature +inline fun CommonSendInvoiceData.requireInputInvoiceMessageContent(): InputInvoiceMessageContent = + this as InputInvoiceMessageContent 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..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,10 +1,10 @@ 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 import dev.inmo.tgbotapi.types.message.content.TextContent -import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent val defaultArgsSeparator = Regex(" ") @@ -19,10 +19,13 @@ 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 = "" + currentBotCommandSource = null } for (textSource in this) { if (textSource is BotCommandTextSource) { @@ -39,23 +42,9 @@ fun List.parseCommandsWithParams( /** * Parse commands and their args. Logic will find command, get all subsequent data as args until new command */ -fun TextedInput.parseCommandsWithParams( +fun TextedWithTextSources.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( - argsSeparator: Regex = defaultArgsSeparator -) = entities ?.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) +) = textSources ?.parseCommandsWithParams(argsSeparator) ?: emptyMap() /** * Parse commands and their args. Logic will find command, get all subsequent data as args until new command 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..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 @@ -2,10 +2,12 @@ package dev.inmo.tgbotapi.extensions.utils.formatting -import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.User -fun buildEntities(init: EntitiesBuilder.() -> Unit): List = 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] @@ -13,23 +15,25 @@ fun buildEntities(init: EntitiesBuilder.() -> Unit): List = Entities * @see buildEntities */ class EntitiesBuilder internal constructor( - private val entitiesList: MutableList = 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: TextSource) { entitiesList.add(source) } + fun add(source: TextSource) { + entitiesList.add(source) + } operator fun TextSource.unaryPlus() = add(this) - operator fun List.unaryPlus() = entitiesList.addAll(this) + operator fun TextSourcesList.unaryPlus() = entitiesList.addAll(this) operator fun invoke(vararg source: TextSource) = entitiesList.addAll(source) operator fun String.unaryPlus() { @@ -37,7 +41,8 @@ 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(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)) @@ -47,8 +52,9 @@ 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(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)) @@ -57,8 +63,9 @@ 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(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)) @@ -66,24 +73,27 @@ inline fun EntitiesBuilder.email(vararg parts: TextSource) = 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(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)) 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(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)) 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(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)) @@ -91,17 +101,21 @@ inline fun EntitiesBuilder.mention(vararg parts: TextSource) = 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(user: User, vararg parts: TextSource) = +inline fun EntitiesBuilder.mention( + user: User, + vararg parts: 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: 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)) @@ -115,8 +129,9 @@ 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(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)) @@ -130,8 +145,9 @@ 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(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)) 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..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 @@ -55,19 +55,18 @@ 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() fun createMarkdownV2Text( @@ -79,19 +78,18 @@ 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() fun createHtmlText( @@ -103,18 +101,17 @@ 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() 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..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,7 +1,5 @@ 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 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..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 @@ -1,10 +1,8 @@ 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 -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 @@ -60,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.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( 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() }