diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59783cda06..08eae08ea7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,33 @@
# TelegramBotAPI changelog
+## 3.0.0
+
+**ALL OLD DEPRECATIONS HAVE BEEN REMOVED**
+
+**`copyMessage` HAVE CHANGED THEIR SIGNATURE BY SWAPPING FROM AND TO CHAT IDS**
+
+* `Versions`:
+ * `Kotlin`: `1.6.21` -> `1.7.10`
+ * `Serialization`: `1.3.3` -> `1.4.0-RC`
+ * `Korlibs`: `2.7.0` -> `3.0.0`
+ * `UUID`: `0.4.1` -> `0.5.0`
+ * `MicroUtils`: `0.11.13` -> `0.12.0`
+* `Core`:
+ * Interface `ReplyMakrup` has been renamed to `WithReplyMarkup` to correspond its purpose
+ * Data class `LeftChatMember` has been renamed to `LeftChatMemberEvent` to avoid type ambiguite with the other `LeftChatMember`
+ * `ForwardInfo` hierarchy has been fully reworked:
+ * `AnonymousForwardInfo` -> `ForwardInfo.ByAnonymous`
+ * `UserForwardInfo` -> `ForwardInfo.ByUser`
+ * `ForwardFromPublicChatInfo` -> `ForwardInfo.PublicChat`
+ * `ForwardFromChannelInfo` -> `ForwardInfo.PublicChat.FromChannel`
+ * `ForwardFromSupergroupInfo` -> `ForwardInfo.PublicChat.FromSupergroup`
+ * `ForwardInfo.PublicChat.SentByChannel` ___has been created___
+* `API`:
+ * Add new `Flow`-based live locations API
+ * Add `sendLocation` for sending live locations
+* `Utils`:
+ * **BREAKING CHANGES** Now all new classcasts (like `Chat.ifPrivateChat` etc.) have been rewritten to be generated with `ksp` and `kotlin poet`
+
## 2.2.2
* `Utils`:
diff --git a/README.md b/README.md
index cdc25d9127..57749cc97f 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,17 @@
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.1-blue)](https://core.telegram.org/bots/api-changelog#june-20-2022)
-| [![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://img.shields.io/static/v1?label=Google&message=Survey&color=blue&logo=google-sheets)](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) [![Chat in Telegram](https://img.shields.io/static/v1?label=Telegram&message=Chat&color=blue&logo=telegram)](https://t.me/InMoTelegramBotAPI) |
-|:---:|
-| [![Create bot](https://img.shields.io/static/v1?label=Github&message=Template&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![Examples](https://img.shields.io/static/v1?label=Github&message=Examples&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Bookstack&message=Tutorial&color=blue&logo=bookstack)](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
-| [![Telegram Channel](./resources/tg_channel_qr.jpg)](https://t.me/InMoTelegramBotAPI) |
+| Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Bookstack&message=Tutorial&color=blue&logo=bookstack)](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
+|:---:|:---:|
+| Useful repos | [![Create bot](https://img.shields.io/static/v1?label=Github&message=Template&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![Examples](https://img.shields.io/static/v1?label=Github&message=Examples&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
+| Misc | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Small survey](https://img.shields.io/static/v1?label=Google&message=Survey&color=blue&logo=google-sheets)](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
+
+
+
+
+
+
+
+
Hello! This is a set of libraries for working with Telegram Bot API.
diff --git a/build.gradle b/build.gradle
index 6b49962838..8be94d48a0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,6 +7,7 @@ buildscript {
dependencies {
classpath libs.kotlin.gradle.plugin
+ classpath libs.kotlin.ksp.plugin
classpath libs.kotlin.serialization.plugin
classpath libs.kotlin.dokka.plugin
classpath libs.github.release.plugin
diff --git a/gradle.properties b/gradle.properties
index 6271ea497e..f56050c6a2 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true
library_group=dev.inmo
-library_version=2.2.2
+library_version=3.0.0
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index b2776fb4d2..3674f3a5cc 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,17 +1,19 @@
[versions]
-kotlin = "1.6.21"
-kotlin-serialization = "1.3.3"
+kotlin = "1.7.10"
+kotlin-serialization = "1.4.0-RC"
kotlin-coroutines = "1.6.4"
-kotlin-gradle-plugin = "7.0.4"
javax-activation = "1.1.1"
-korlibs = "2.7.0"
-uuid = "0.4.1"
+korlibs = "3.0.0"
+uuid = "0.5.0"
ktor = "2.0.3"
-microutils = "0.11.13"
+ksp = "1.7.10-1.0.6"
+kotlin-poet = "1.12.0"
+
+microutils = "0.12.0"
github-release-plugin = "2.4.1"
@@ -46,14 +48,21 @@ microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", ver
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
+# ksp dependencies
+
+kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" }
+ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
+
# buildscript classpaths
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
+kotlin-ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "kotlin" }
github-release-plugin = { module = "com.github.breadmoirai:github-release", version.ref = "github-release-plugin" }
[plugins]
+kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
diff --git a/settings.gradle b/settings.gradle
index 6cf2139f0b..d8603ea158 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -12,6 +12,8 @@ pluginManagement {
}
include ":tgbotapi.core"
+include ":tgbotapi.ksp:processor"
+include ":tgbotapi.ksp:lib"
include ":tgbotapi.api"
include ":tgbotapi.utils"
include ":tgbotapi.behaviour_builder"
diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt
new file mode 100644
index 0000000000..6caa782d64
--- /dev/null
+++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt
@@ -0,0 +1,151 @@
+package dev.inmo.tgbotapi.extensions.api
+
+import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
+import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
+import dev.inmo.tgbotapi.abstracts.*
+import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
+import dev.inmo.tgbotapi.bot.TelegramBot
+import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
+import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
+import dev.inmo.tgbotapi.types.*
+import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
+import dev.inmo.tgbotapi.types.location.LiveLocation
+import dev.inmo.tgbotapi.types.location.Location
+import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
+import dev.inmo.tgbotapi.types.message.content.LocationContent
+import kotlinx.coroutines.*
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.map
+import kotlinx.serialization.Serializable
+import kotlin.js.JsName
+import kotlin.jvm.JvmName
+import kotlin.math.ceil
+
+@Serializable
+data class EditLiveLocationInfo(
+ override val latitude: Double,
+ override val longitude: Double,
+ override val horizontalAccuracy: Meters? = null,
+ override val heading: Degrees? = null,
+ override val proximityAlertRadius: Meters? = null,
+ override val replyMarkup: InlineKeyboardMarkup? = null
+) : Locationed, HorizontallyAccured, ProximityAlertable, Headed, WithReplyMarkup
+
+/**
+ * Will [sendLiveLocation] with the first [EditLiveLocationInfo] data and update than. Each [liveTimeMillis] passing,
+ * the message will be sent again and new edits will be applied to the new message
+ */
+suspend fun TelegramBot.handleLiveLocation(
+ chatId: ChatIdentifier,
+ locationsFlow: Flow,
+ liveTimeMillis: Long = defaultLivePeriodDelayMillis,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null
+) {
+ var currentLiveLocationMessage: ContentMessage? = null
+ val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
+ while (isActive) {
+ delay(liveTimeMillis)
+ // Remove previous location message info to resend live location message
+ currentLiveLocationMessage = null
+ }
+ }
+ locationsFlow.collect {
+ val capturedLiveLocationMessage = currentLiveLocationMessage
+ if (capturedLiveLocationMessage == null) {
+ updateMessageJob.start()
+ currentLiveLocationMessage = sendLiveLocation(
+ chatId,
+ it.latitude,
+ it.longitude,
+ ceil(liveTimeMillis.toDouble() / 1000).toInt(),
+ it.horizontalAccuracy,
+ it.heading,
+ it.proximityAlertRadius,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ it.replyMarkup
+ )
+ } else {
+ editLiveLocation(
+ capturedLiveLocationMessage,
+ it.latitude,
+ it.longitude,
+ it.horizontalAccuracy,
+ it.heading,
+ it.proximityAlertRadius,
+ it.replyMarkup
+ )
+ }
+ }
+}
+
+/**
+ * Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
+ * [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
+ */
+@JvmName("handleLiveLocationWithLocation")
+@JsName("handleLiveLocationWithLocation")
+suspend fun TelegramBot.handleLiveLocation(
+ chatId: ChatIdentifier,
+ locationsFlow: Flow,
+ liveTimeMillis: Long = defaultLivePeriodDelayMillis,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null
+) {
+ handleLiveLocation(
+ chatId,
+ locationsFlow.map {
+ EditLiveLocationInfo(
+ it.latitude,
+ it.longitude,
+ it.horizontalAccuracy,
+ (it as? LiveLocation) ?.heading,
+ (it as? LiveLocation) ?.proximityAlertRadius,
+ (it as? WithReplyMarkup) ?.replyMarkup as? InlineKeyboardMarkup
+ )
+ },
+ liveTimeMillis,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply
+ )
+}
+
+/**
+ * Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
+ * [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
+ */
+@JvmName("handleLiveLocationWithLatLong")
+@JsName("handleLiveLocationWithLatLong")
+suspend fun TelegramBot.handleLiveLocation(
+ chatId: ChatIdentifier,
+ locationsFlow: Flow>,
+ liveTimeMillis: Long = defaultLivePeriodDelayMillis,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null
+) {
+ handleLiveLocation(
+ chatId,
+ locationsFlow.map { (lat, long) ->
+ EditLiveLocationInfo(
+ lat,
+ long
+ )
+ },
+ liveTimeMillis,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply
+ )
+}
diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt
index 3ddc68161e..5cb4239dd1 100644
--- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt
+++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt
@@ -229,3 +229,224 @@ suspend inline fun TelegramBot.copyMessage(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend inline fun TelegramBot.copyMessage(
+ toChatId: ChatIdentifier,
+ fromChatId: ChatIdentifier,
+ messageId: MessageIdentifier,
+ text: String? = null,
+ parseMode: ParseMode? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = execute(
+ CopyMessage(
+ fromChatId,
+ messageId,
+ toChatId,
+ text,
+ parseMode,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+ )
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend inline fun TelegramBot.copyMessage(
+ toChatId: ChatIdentifier,
+ fromChat: Chat,
+ messageId: MessageIdentifier,
+ text: String? = null,
+ parseMode: ParseMode? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = copyMessage(
+ toChatId,
+ fromChat.id,
+ messageId,
+ text,
+ parseMode,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend inline fun TelegramBot.copyMessage(
+ toChat: Chat,
+ fromChatId: ChatIdentifier,
+ messageId: MessageIdentifier,
+ text: String? = null,
+ parseMode: ParseMode? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = copyMessage(
+ toChat.id,
+ fromChatId,
+ messageId,
+ text,
+ parseMode,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend inline fun TelegramBot.copyMessage(
+ toChat: Chat,
+ fromChat: Chat,
+ messageId: MessageIdentifier,
+ text: String? = null,
+ parseMode: ParseMode? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = copyMessage(
+ toChat.id,
+ fromChat.id,
+ messageId,
+ text,
+ parseMode,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
+
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend inline fun TelegramBot.copyMessage(
+ toChatId: ChatIdentifier,
+ fromChatId: ChatIdentifier,
+ messageId: MessageIdentifier,
+ entities: TextSourcesList,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = execute(
+ CopyMessage(
+ fromChatId,
+ messageId,
+ toChatId,
+ entities,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+ )
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend inline fun TelegramBot.copyMessage(
+ toChatId: ChatIdentifier,
+ fromChat: Chat,
+ messageId: MessageIdentifier,
+ entities: TextSourcesList,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = copyMessage(
+ toChatId,
+ fromChat.id,
+ messageId,
+ entities,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend inline fun TelegramBot.copyMessage(
+ toChat: Chat,
+ fromChatId: ChatIdentifier,
+ messageId: MessageIdentifier,
+ entities: TextSourcesList,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = copyMessage(
+ toChat.id,
+ fromChatId,
+ messageId,
+ entities,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend inline fun TelegramBot.copyMessage(
+ toChat: Chat,
+ fromChat: Chat,
+ messageId: MessageIdentifier,
+ entities: TextSourcesList,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = copyMessage(
+ toChat.id,
+ fromChat.id,
+ messageId,
+ entities,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/OldCopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/OldCopyMessage.kt
deleted file mode 100644
index f546a93451..0000000000
--- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/OldCopyMessage.kt
+++ /dev/null
@@ -1,180 +0,0 @@
-package dev.inmo.tgbotapi.extensions.api.send
-
-import dev.inmo.tgbotapi.bot.TelegramBot
-import dev.inmo.tgbotapi.requests.send.CopyMessage
-import dev.inmo.tgbotapi.requests.send.OrderChangingDeprecationWarn
-import dev.inmo.tgbotapi.types.ChatIdentifier
-import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
-import dev.inmo.tgbotapi.types.MessageIdentifier
-import dev.inmo.tgbotapi.types.message.ParseMode
-import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
-import dev.inmo.tgbotapi.types.chat.Chat
-import dev.inmo.tgbotapi.types.message.abstracts.Message
-
-// TODO:: Swap fromChatId and toChatId for more correct order of parameters
-
-/**
- * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
- * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
- */
-@Deprecated(OrderChangingDeprecationWarn)
-suspend inline fun TelegramBot.copyMessage(
- fromChatId: ChatIdentifier,
- toChatId: ChatIdentifier,
- messageId: MessageIdentifier,
- text: String? = null,
- parseMode: ParseMode? = null,
- disableNotification: Boolean = false,
- protectContent: Boolean = false,
- replyToMessageId: MessageIdentifier? = null,
- allowSendingWithoutReply: Boolean? = null,
- replyMarkup: KeyboardMarkup? = null
-) = execute(
- CopyMessage(
- fromChatId,
- messageId,
- toChatId,
- text,
- parseMode,
- disableNotification,
- protectContent,
- replyToMessageId,
- allowSendingWithoutReply,
- replyMarkup
- )
-)
-
-/**
- * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
- * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
- */
-@Deprecated(OrderChangingDeprecationWarn)
-suspend inline fun TelegramBot.copyMessage(
- fromChat: Chat,
- toChatId: ChatIdentifier,
- messageId: MessageIdentifier,
- text: String? = null,
- parseMode: ParseMode? = null,
- disableNotification: Boolean = false,
- protectContent: Boolean = false,
- replyToMessageId: MessageIdentifier? = null,
- allowSendingWithoutReply: Boolean? = null,
- replyMarkup: KeyboardMarkup? = null
-) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
-
-/**
- * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
- * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
- */
-@Deprecated(OrderChangingDeprecationWarn)
-suspend inline fun TelegramBot.copyMessage(
- fromChatId: ChatIdentifier,
- toChat: Chat,
- messageId: MessageIdentifier,
- text: String? = null,
- parseMode: ParseMode? = null,
- disableNotification: Boolean = false,
- protectContent: Boolean = false,
- replyToMessageId: MessageIdentifier? = null,
- allowSendingWithoutReply: Boolean? = null,
- replyMarkup: KeyboardMarkup? = null
-) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
-
-/**
- * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
- * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
- */
-@Deprecated(OrderChangingDeprecationWarn)
-suspend inline fun TelegramBot.copyMessage(
- fromChat: Chat,
- toChat: Chat,
- messageId: MessageIdentifier,
- text: String? = null,
- parseMode: ParseMode? = null,
- disableNotification: Boolean = false,
- protectContent: Boolean = false,
- replyToMessageId: MessageIdentifier? = null,
- allowSendingWithoutReply: Boolean? = null,
- replyMarkup: KeyboardMarkup? = null
-) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
-
-
-/**
- * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
- * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
- */
-@Deprecated(OrderChangingDeprecationWarn)
-suspend inline fun TelegramBot.copyMessage(
- fromChatId: ChatIdentifier,
- toChatId: ChatIdentifier,
- messageId: MessageIdentifier,
- entities: TextSourcesList,
- disableNotification: Boolean = false,
- protectContent: Boolean = false,
- replyToMessageId: MessageIdentifier? = null,
- allowSendingWithoutReply: Boolean? = null,
- replyMarkup: KeyboardMarkup? = null
-) = execute(
- CopyMessage(
- fromChatId,
- messageId,
- toChatId,
- entities,
- disableNotification,
- protectContent,
- replyToMessageId,
- allowSendingWithoutReply,
- replyMarkup
- )
-)
-
-/**
- * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
- * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
- */
-@Deprecated(OrderChangingDeprecationWarn)
-suspend inline fun TelegramBot.copyMessage(
- fromChat: Chat,
- toChatId: ChatIdentifier,
- messageId: MessageIdentifier,
- entities: TextSourcesList,
- disableNotification: Boolean = false,
- protectContent: Boolean = false,
- replyToMessageId: MessageIdentifier? = null,
- allowSendingWithoutReply: Boolean? = null,
- replyMarkup: KeyboardMarkup? = null
-) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
-
-/**
- * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
- * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
- */
-@Deprecated(OrderChangingDeprecationWarn)
-suspend inline fun TelegramBot.copyMessage(
- fromChatId: ChatIdentifier,
- toChat: Chat,
- messageId: MessageIdentifier,
- entities: TextSourcesList,
- disableNotification: Boolean = false,
- protectContent: Boolean = false,
- replyToMessageId: MessageIdentifier? = null,
- allowSendingWithoutReply: Boolean? = null,
- replyMarkup: KeyboardMarkup? = null
-) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
-
-/**
- * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
- * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
- */
-@Deprecated(OrderChangingDeprecationWarn)
-suspend inline fun TelegramBot.copyMessage(
- fromChat: Chat,
- toChat: Chat,
- messageId: MessageIdentifier,
- entities: TextSourcesList,
- disableNotification: Boolean = false,
- protectContent: Boolean = false,
- replyToMessageId: MessageIdentifier? = null,
- allowSendingWithoutReply: Boolean? = null,
- replyMarkup: KeyboardMarkup? = null
-) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt
index a857405cf6..116c1e5387 100644
--- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt
+++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt
@@ -1,6 +1,8 @@
package dev.inmo.tgbotapi.extensions.api.send
+import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.bot.TelegramBot
+import dev.inmo.tgbotapi.extensions.api.*
import dev.inmo.tgbotapi.extensions.api.send.games.sendGame
import dev.inmo.tgbotapi.extensions.api.send.media.*
import dev.inmo.tgbotapi.extensions.api.send.payments.sendInvoice
@@ -29,6 +31,10 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.venue.Venue
import dev.inmo.tgbotapi.utils.RiskFeature
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.map
+import kotlin.js.JsName
+import kotlin.jvm.JvmName
// Contact
@@ -950,7 +956,18 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
-) = copyMessage(fromChatId, to.chat.id, messageId, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
+) = copyMessage(
+ to.chat.id,
+ fromChatId,
+ messageId,
+ text,
+ parseMode,
+ disableNotification,
+ protectContent,
+ to.messageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
suspend inline fun TelegramBot.reply(
to: Message,
@@ -995,6 +1012,80 @@ suspend fun TelegramBot.reply(
)
}
+/**
+ * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
+ *
+ * @see handleLiveLocation
+ */
+suspend fun TelegramBot.reply(
+ message: Message,
+ locationsFlow: Flow,
+ liveTimeMillis: Long = defaultLivePeriodDelayMillis,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ allowSendingWithoutReply: Boolean? = null
+) = handleLiveLocation(
+ message.chat.id,
+ locationsFlow,
+ liveTimeMillis,
+ disableNotification,
+ protectContent,
+ message.messageId,
+ allowSendingWithoutReply
+)
+
+/**
+ * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
+ *
+ * @see handleLiveLocation
+ */
+@JvmName("replyLiveLocationWithLocation")
+@JsName("replyLiveLocationWithLocation")
+suspend fun TelegramBot.reply(
+ message: Message,
+ locationsFlow: Flow,
+ liveTimeMillis: Long = defaultLivePeriodDelayMillis,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ allowSendingWithoutReply: Boolean? = null
+) {
+ handleLiveLocation(
+ message.chat.id,
+ locationsFlow,
+ liveTimeMillis,
+ disableNotification,
+ protectContent,
+ message.messageId,
+ allowSendingWithoutReply
+ )
+}
+
+/**
+ * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
+ *
+ * @see handleLiveLocation
+ */
+@JvmName("replyLiveLocationWithLatLong")
+@JsName("replyLiveLocationWithLatLong")
+suspend fun TelegramBot.reply(
+ message: Message,
+ locationsFlow: Flow>,
+ liveTimeMillis: Long = defaultLivePeriodDelayMillis,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ allowSendingWithoutReply: Boolean? = null
+) {
+ handleLiveLocation(
+ message.chat.id,
+ locationsFlow,
+ liveTimeMillis,
+ disableNotification,
+ protectContent,
+ message.messageId,
+ allowSendingWithoutReply
+ )
+}
+
suspend fun TelegramBot.reply(
to: Message,
mediaFile: TelegramMediaFile,
diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt
new file mode 100644
index 0000000000..c96e676325
--- /dev/null
+++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt
@@ -0,0 +1,212 @@
+package dev.inmo.tgbotapi.extensions.api.send
+
+import dev.inmo.tgbotapi.bot.TelegramBot
+import dev.inmo.tgbotapi.requests.send.SendLiveLocation
+import dev.inmo.tgbotapi.requests.send.SendStaticLocation
+import dev.inmo.tgbotapi.types.*
+import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
+import dev.inmo.tgbotapi.types.chat.Chat
+import dev.inmo.tgbotapi.types.location.Location
+import dev.inmo.tgbotapi.types.location.StaticLocation
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend fun TelegramBot.sendLocation(
+ chatId: ChatIdentifier,
+ latitude: Double,
+ longitude: Double,
+ livePeriod: Seconds,
+ horizontalAccuracy: Meters? = null,
+ heading: Degrees? = null,
+ proximityAlertRadius: Meters? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = execute(
+ SendLiveLocation(
+ chatId,
+ latitude,
+ longitude,
+ livePeriod,
+ horizontalAccuracy,
+ heading,
+ proximityAlertRadius,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+ )
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend fun TelegramBot.sendLocation(
+ chatId: ChatIdentifier,
+ location: Location,
+ livePeriod: Seconds,
+ horizontalAccuracy: Meters? = null,
+ heading: Degrees? = null,
+ proximityAlertRadius: Meters? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = sendLocation(
+ chatId,
+ location.latitude,
+ location.longitude,
+ livePeriod,
+ horizontalAccuracy,
+ heading,
+ proximityAlertRadius,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend fun TelegramBot.sendLocation(
+ chat: Chat,
+ latitude: Double,
+ longitude: Double,
+ livePeriod: Seconds,
+ horizontalAccuracy: Meters? = null,
+ heading: Degrees? = null,
+ proximityAlertRadius: Meters? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = sendLocation(
+ chat.id,
+ latitude,
+ longitude,
+ livePeriod,
+ horizontalAccuracy,
+ heading,
+ proximityAlertRadius,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend fun TelegramBot.sendLocation(
+ chat: Chat,
+ location: Location,
+ livePeriod: Seconds,
+ horizontalAccuracy: Meters? = null,
+ heading: Degrees? = null,
+ proximityAlertRadius: Meters? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = sendLocation(
+ chat.id,
+ location.latitude,
+ location.longitude,
+ livePeriod,
+ horizontalAccuracy,
+ heading,
+ proximityAlertRadius,
+ disableNotification,
+ protectContent,
+ replyToMessageId,
+ allowSendingWithoutReply,
+ replyMarkup
+)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend fun TelegramBot.sendLiveLocation(
+ chatId: ChatIdentifier,
+ latitude: Double,
+ longitude: Double,
+ livePeriod: Seconds,
+ horizontalAccuracy: Meters? = null,
+ heading: Degrees? = null,
+ proximityAlertRadius: Meters? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend fun TelegramBot.sendLiveLocation(
+ chatId: ChatIdentifier,
+ location: Location,
+ livePeriod: Seconds,
+ horizontalAccuracy: Meters? = null,
+ heading: Degrees? = null,
+ proximityAlertRadius: Meters? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend fun TelegramBot.sendLiveLocation(
+ chat: Chat,
+ latitude: Double,
+ longitude: Double,
+ livePeriod: Seconds,
+ horizontalAccuracy: Meters? = null,
+ heading: Degrees? = null,
+ proximityAlertRadius: Meters? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
+
+/**
+ * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
+ * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
+ */
+suspend fun TelegramBot.sendLiveLocation(
+ chat: Chat,
+ location: Location,
+ livePeriod: Seconds,
+ horizontalAccuracy: Meters? = null,
+ heading: Degrees? = null,
+ proximityAlertRadius: Meters? = null,
+ disableNotification: Boolean = false,
+ protectContent: Boolean = false,
+ replyToMessageId: MessageIdentifier? = null,
+ allowSendingWithoutReply: Boolean? = null,
+ replyMarkup: KeyboardMarkup? = null
+) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt
similarity index 97%
rename from tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt
rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt
index d571377951..af941fbb0a 100644
--- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt
+++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt
@@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
+import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.location.StaticLocation
/**
@@ -40,7 +41,7 @@ suspend fun TelegramBot.sendLocation(
*/
suspend fun TelegramBot.sendLocation(
chatId: ChatIdentifier,
- location: StaticLocation,
+ location: Location,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@@ -87,7 +88,7 @@ suspend fun TelegramBot.sendLocation(
*/
suspend fun TelegramBot.sendLocation(
chat: Chat,
- location: StaticLocation,
+ location: Location,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@@ -125,7 +126,7 @@ suspend fun TelegramBot.sendStaticLocation(
*/
suspend fun TelegramBot.sendStaticLocation(
chatId: ChatIdentifier,
- location: StaticLocation,
+ location: Location,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@@ -154,7 +155,7 @@ suspend fun TelegramBot.sendStaticLocation(
*/
suspend fun TelegramBot.sendStaticLocation(
chat: Chat,
- location: StaticLocation,
+ location: Location,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt
index 0210ab3de7..8a8e0f91e6 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt
@@ -6,7 +6,6 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
-import dev.inmo.tgbotapi.utils.PreviewFeature
import kotlinx.coroutines.*
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt
index 9885da3d5a..fbbd954d1b 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt
@@ -57,20 +57,6 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope {
upstreamUpdatesFlow: Flow? = null,
triggersHolder: TriggersHolder = TriggersHolder()
): BehaviourContext
-
- /**
- * @param updatesFilter unused
- */
- @Deprecated("Do not use this method")
- fun copy(
- bot: TelegramBot = this.bot,
- scope: CoroutineScope = this.scope,
- broadcastChannelsSize: Int = 100,
- onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
- upstreamUpdatesFlow: Flow? = null,
- triggersHolder: TriggersHolder = TriggersHolder(),
- updatesFilter: BehaviourContextAndTypeReceiver? = null
- ): BehaviourContext = copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder)
}
class DefaultBehaviourContext(
@@ -79,9 +65,7 @@ class DefaultBehaviourContext(
broadcastChannelsSize: Int = 100,
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
private val upstreamUpdatesFlow: Flow? = null,
- override val triggersHolder: TriggersHolder = TriggersHolder(),
- @Deprecated("This parameter is not used anymore")
- private val updatesFilter: BehaviourContextAndTypeReceiver? = null
+ override val triggersHolder: TriggersHolder = TriggersHolder()
) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext {
private val additionalUpdatesSharedFlow = MutableSharedFlow(0, broadcastChannelsSize, onBufferOverflow)
@@ -137,19 +121,6 @@ fun BC.createSubContext(
triggersHolder = triggersHolder
) as BC
-/**
- * Creates new [BehaviourContext] using its [BehaviourContext.copy] method
- *
- * @param updatesFilter This param will not be used anymore
- */
-@Deprecated("It is not recommended to use updates filter anymore")
-fun BC.createSubContext(
- scope: CoroutineScope = LinkedSupervisorScope(),
- triggersHolder: TriggersHolder = this.triggersHolder,
- updatesUpstreamFlow: Flow = allUpdatesFlow,
- updatesFilter: CustomBehaviourContextAndTypeReceiver?,
-) = createSubContext(scope, triggersHolder, updatesUpstreamFlow)
-
/**
* Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext]
*
@@ -187,27 +158,6 @@ suspend fun BC.createSubContextAndDoWithUpdatesFilter
)
}
-/**
- * Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context
- * using [doInContext]
- *
- * @param stopOnCompletion ___TRUE BY DEFAULT___
- * @param updatesFilter Is not used anymore
- */
-@Deprecated("It is not recommended to use updates filter anymore")
-suspend fun BC.createSubContextAndDoWithUpdatesFilter(
- scope: CoroutineScope = LinkedSupervisorScope(),
- triggersHolder: TriggersHolder = this.triggersHolder,
- updatesUpstreamFlow: Flow = allUpdatesFlow,
- updatesFilter: CustomBehaviourContextAndTypeReceiver?,
- stopOnCompletion: Boolean = true,
- behaviourContextReceiver: CustomBehaviourContextReceiver
-): T {
- return createSubContextAndDoWithUpdatesFilter(
- scope, triggersHolder, updatesUpstreamFlow, stopOnCompletion, behaviourContextReceiver
- )
-}
-
/**
* This method will cancel ALL subsequent contexts, expectations and waiters
*/
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt
index b49e812220..19b06325c4 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt
@@ -1,9 +1,9 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder
import dev.inmo.micro_utils.coroutines.ExceptionHandler
+import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder
import dev.inmo.tgbotapi.bot.ktor.telegramBot
-import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt
index 9266cab99a..7be3ea5ee1 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt
@@ -3,14 +3,12 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
+import dev.inmo.tgbotapi.extensions.utils.callbackQueryUpdateOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.queries.callback.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias CallbackQueryMapper = suspend T.() -> T?
@@ -22,7 +20,7 @@ suspend inline fun BehaviourContext.waitCallbackQueries(
initRequest,
errorFactory
) {
- (it.asCallbackQueryUpdate() ?.data as O).let(::listOfNotNull)
+ (it.callbackQueryUpdateOrNull() ?.data as O).let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt
index ef253dd339..9f1dd58b85 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt
@@ -1,14 +1,12 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
+import dev.inmo.tgbotapi.extensions.utils.chatJoinRequestUpdateOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias ChatJoinRequestsMapper = suspend ChatJoinRequest.() -> ChatJoinRequest?
@@ -20,7 +18,7 @@ suspend inline fun BehaviourContext.internalWaitChatJoinRequests(
initRequest,
errorFactory
) {
- (it.asChatJoinRequestUpdate() ?.data as? O).let(::listOfNotNull)
+ (it.chatJoinRequestUpdateOrNull() ?.data as? O).let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt
index 4f75e36f59..e7b205e56d 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt
@@ -1,7 +1,6 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate
@@ -10,7 +9,6 @@ import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias ChatMemberUpdatedMapper = suspend T.() -> T?
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt
index 2b5744c174..2c8c812acb 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt
@@ -1,14 +1,12 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
+import dev.inmo.tgbotapi.extensions.utils.chosenInlineResultUpdateOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias ChosenInlineResultMapper = suspend T.() -> T?
@@ -20,7 +18,7 @@ suspend inline fun BehaviourContext.waitChosenInlineResults(
initRequest,
errorFactory
) {
- (it.asChosenInlineResultUpdate() ?.data as? O).let(::listOfNotNull)
+ (it.chosenInlineResultUpdateOrNull() ?.data as? O).let(::listOfNotNull)
}
suspend fun BehaviourContext.waitChosenInlineResult(
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt
index 01f9ce1acd..91bce4c17e 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt
@@ -3,18 +3,9 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.InvoiceContent
-import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
-import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt
index 2f67610c3f..9620795bf2 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt
@@ -4,18 +4,12 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.InvoiceContent
-import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
+import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt
index 2ca4af7fbb..a552348dd8 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt
@@ -3,22 +3,12 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asCommonMessage
-import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.requests.abstracts.Request
-import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
-import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.InvoiceContent
-import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
-import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.map
@RiskFeature(lowLevelRiskFeatureMessage)
suspend inline fun BehaviourContext.waitEditedContent(
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt
index 69d9b1b16f..c5204f68ec 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt
@@ -3,23 +3,16 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asCommonMessage
+import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.InvoiceContent
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
@RiskFeature(lowLevelRiskFeatureMessage)
suspend inline fun BehaviourContext.waitEditedContentMessage(
@@ -32,7 +25,7 @@ suspend inline fun BehaviourContext.waitEditedConte
) {
val messages = when (it) {
is BaseEditMessageUpdate -> {
- val commonMessage = it.data.asCommonMessage() ?: return@expectFlow emptyList()
+ val commonMessage = it.data.commonMessageOrNull() ?: return@expectFlow emptyList()
if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) {
listOf(commonMessage)
} else {
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt
index 414fd7b4a1..4b7fc377dc 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt
@@ -3,19 +3,16 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
-import dev.inmo.tgbotapi.types.message.PrivateEventMessage
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias EventMessageToEventMapper = suspend ChatEventMessage.() -> T?
@@ -27,7 +24,7 @@ suspend inline fun BehaviourContext.waitEvents(
initRequest,
errorFactory
) {
- it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.withEvent() ?.chatEvent.let(::listOfNotNull)
+ it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.withEvent() ?.chatEvent.let(::listOfNotNull)
}
suspend fun BehaviourContext.waitChannelEvents(
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt
index f01530cf21..f5db11ad3b 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt
@@ -3,19 +3,16 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.requests.abstracts.Request
-import dev.inmo.tgbotapi.types.message.ChannelEventMessage
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
-import dev.inmo.tgbotapi.types.message.PrivateEventMessage
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
-import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.flow.Flow
@RiskFeature(lowLevelRiskFeatureMessage)
suspend inline fun BehaviourContext.waitEventsMessages(
@@ -25,7 +22,7 @@ suspend inline fun BehaviourContext.waitEventsMessages(
initRequest,
errorFactory
) {
- it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.withEvent().let(::listOfNotNull)
+ it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.withEvent().let(::listOfNotNull)
}
suspend fun BehaviourContext.waitChannelEventsMessages(
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt
index 8c6c5bc393..59bb45108c 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt
@@ -1,14 +1,12 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate
+import dev.inmo.tgbotapi.extensions.utils.inlineQueryUpdateOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.InlineQueries.query.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias InlineQueryMapper = suspend T.() -> T?
@@ -20,7 +18,7 @@ suspend inline fun BehaviourContext.waitInlineQueries(
initRequest,
errorFactory
) {
- (it.asInlineQueryUpdate() ?.data as? O).let(::listOfNotNull)
+ (it.inlineQueryUpdateOrNull() ?.data as? O).let(::listOfNotNull)
}
suspend fun BehaviourContext.waitAnyInlineQuery(
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt
index 542f7a7d46..37260e9340 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt
@@ -2,15 +2,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
-import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt
index 29f03d276e..f75f8767b7 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt
@@ -1,16 +1,11 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
+import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
@@ -20,7 +15,7 @@ suspend inline fun BehaviourContext.buildMediaGr
initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }
): Flow>> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update ->
- update.asSentMediaGroupUpdate() ?.data ?.let { mediaGroup ->
+ update.sentMediaGroupUpdateOrNull() ?.data ?.let { mediaGroup ->
val mapped = mediaGroup.mapNotNull { it.withContent() }
listOf(
mapped
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt
index 2d1c16c90f..e428bbee5d 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt
@@ -1,9 +1,8 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
-import dev.inmo.tgbotapi.extensions.utils.asPassportMessage
+import dev.inmo.tgbotapi.extensions.utils.messageUpdateOrNull
+import dev.inmo.tgbotapi.extensions.utils.passportMessageOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.PassportMessage
import dev.inmo.tgbotapi.types.passport.PassportData
@@ -11,7 +10,6 @@ import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportEle
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias PassportMessageMapper = suspend PassportMessage.() -> PassportData
@@ -23,7 +21,7 @@ suspend inline fun BehaviourContext.waitP
initRequest,
errorFactory
) {
- it.asMessageUpdate() ?.data ?.asPassportMessage() ?.passportData ?.data ?.filterIsInstance() ?: emptyList()
+ it.messageUpdateOrNull() ?.data ?.passportMessageOrNull() ?.passportData ?.data ?.filterIsInstance() ?: emptyList()
}
suspend fun BehaviourContext.waitAnyPassportMessages(
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt
index a59fcccc4b..a04232acfe 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt
@@ -1,14 +1,10 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate
+import dev.inmo.tgbotapi.extensions.utils.pollAnswerUpdateOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.polls.PollAnswer
-import dev.inmo.tgbotapi.utils.RiskFeature
-import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias PollAnswerMapper = suspend PollAnswer.() -> PollAnswer?
@@ -19,5 +15,5 @@ suspend fun BehaviourContext.waitPollAnswers(
initRequest,
errorFactory
) {
- it.asPollAnswerUpdate() ?.data.let(::listOfNotNull)
+ it.pollAnswerUpdateOrNull() ?.data.let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt
index 1dd9ad044c..23ef770caa 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt
@@ -1,14 +1,12 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
+import dev.inmo.tgbotapi.extensions.utils.pollUpdateOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias PollMapper = suspend T.() -> T?
@@ -20,7 +18,7 @@ suspend inline fun BehaviourContext.waitPolls(
initRequest,
errorFactory
) {
- (it.asPollUpdate() ?.data as? O).let(::listOfNotNull)
+ (it.pollUpdateOrNull() ?.data as? O).let(::listOfNotNull)
}
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt
index 0c2fcb5cf3..c3a12896c0 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt
@@ -1,14 +1,10 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
+import dev.inmo.tgbotapi.extensions.utils.preCheckoutQueryUpdateOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
-import dev.inmo.tgbotapi.utils.RiskFeature
-import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery?
@@ -19,5 +15,5 @@ suspend fun BehaviourContext.waitPreCheckoutQueries(
initRequest,
errorFactory
) {
- it.asPreCheckoutQueryUpdate() ?.data.let(::listOfNotNull)
+ it.preCheckoutQueryUpdateOrNull() ?.data.let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt
index a35a7b9a66..493c6d7beb 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt
@@ -1,12 +1,10 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
-import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
+import dev.inmo.tgbotapi.extensions.utils.shippingQueryUpdateOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.payments.ShippingQuery
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.toList
typealias ShippingQueryMapper = suspend ShippingQuery.() -> ShippingQuery?
@@ -17,5 +15,5 @@ suspend fun BehaviourContext.waitShippingQueries(
initRequest,
errorFactory
) {
- (it.asShippingQueryUpdate() ?.data).let(::listOfNotNull)
+ (it.shippingQueryUpdateOrNull() ?.data).let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt
index 90574ebd5e..79f983b9f8 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt
@@ -2,13 +2,13 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
-import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
+import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
-import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
import dev.inmo.tgbotapi.types.payments.ShippingQuery
+import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.update.abstracts.Update
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt
index 49326ae88f..c2ca912858 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt
@@ -6,10 +6,11 @@ import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.micro_utils.coroutines.runCatchingSafely
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CallbackQueryFilterByUser
-import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.*
+import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserCallbackQueryMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
+import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
+import dev.inmo.tgbotapi.extensions.utils.callbackQueryUpdateOrNull
import dev.inmo.tgbotapi.types.queries.callback.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
import kotlinx.coroutines.Job
@@ -20,7 +21,7 @@ internal suspend inline fun B
markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asCallbackQueryUpdate() ?.data as? T) ?.let(::listOfNotNull)
+ (it.callbackQueryUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
}
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatJoinRequestTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatJoinRequestTriggers.kt
index 90e5f5cbae..71d244e100 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatJoinRequestTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatJoinRequestTriggers.kt
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ChatJoinRequestFil
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatChatJoinRequestMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
+import dev.inmo.tgbotapi.extensions.utils.chatJoinRequestUpdateOrNull
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -29,5 +29,5 @@ suspend fun BC.onChatJoinRequest(
markerFactory: MarkerFactory = ByChatChatJoinRequestMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asChatJoinRequestUpdate() ?.data) ?.let(::listOfNotNull)
+ (it.chatJoinRequestUpdateOrNull() ?.data) ?.let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt
index f87eacd415..b4f7a00dfa 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt
@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserIdChosenInlineResultMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
+import dev.inmo.tgbotapi.extensions.utils.chosenInlineResultUpdateOrNull
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -16,7 +16,7 @@ internal suspend inline fun = ByUserIdChosenInlineResultMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asChosenInlineResultUpdate() ?.data as? T) ?.let(::listOfNotNull)
+ (it.chosenInlineResultUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
}
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt
index 151d70b47d..f59aa80629 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt
@@ -10,9 +10,8 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
-import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
+import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
-import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.content.TextMessage
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -35,7 +34,7 @@ internal suspend fun BC.commandUncounted(
true
}
sizeRequirement && textSources.any {
- commandRegex.matches(it.asBotCommandTextSource() ?.command ?: return@any false)
+ commandRegex.matches(it.botCommandTextSourceOrNull() ?.command ?: return@any false)
}
}.let {
initialFilter ?.times(it) ?: it
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandlingUnhandled.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandlingUnhandled.kt
index 9f68928500..0219490400 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandlingUnhandled.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandlingUnhandled.kt
@@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
-import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
+import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.content.TextMessage
@@ -33,7 +33,7 @@ suspend fun BC.unhandledCommand(
true
}
sizeRequirement && textSources.any {
- val command = it.asBotCommandTextSource() ?.command ?: return@any false
+ val command = it.botCommandTextSourceOrNull() ?.command ?: return@any false
!triggersHolder.handleableCommandsHolder.isHandled(command)
}
}.let {
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt
index 1b004b05a0..e9a19d4d7d 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt
@@ -12,12 +12,9 @@ import dev.inmo.tgbotapi.extensions.utils.whenCommonMessage
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.InvoiceContent
-import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
import dev.inmo.tgbotapi.types.update.abstracts.Update
+import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
typealias CommonMessageFilter = SimpleFilter>
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt
index 30aaf7cac5..e339c6f66f 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt
@@ -20,17 +20,11 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilte
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asEditMessageUpdate
+import dev.inmo.tgbotapi.extensions.utils.editMessageUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.InvoiceContent
-import dev.inmo.tgbotapi.types.message.content.MediaCollectionContent
-import dev.inmo.tgbotapi.types.message.content.MediaContent
-import dev.inmo.tgbotapi.types.message.content.MessageContent
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -41,7 +35,7 @@ internal suspend inline fun
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver>
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
when (it) {
- is BaseEditMessageUpdate -> (it.asEditMessageUpdate() ?.data ?.withContent())
+ is BaseEditMessageUpdate -> (it.editMessageUpdateOrNull() ?.data ?.withContent())
else -> null
} ?.let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt
index cde6ed010e..db41229f8b 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt
@@ -7,8 +7,8 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asBaseSentMessageUpdate
-import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage
+import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
+import dev.inmo.tgbotapi.extensions.utils.chatEventMessageOrNull
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
@@ -24,7 +24,7 @@ internal suspend inline fun BC.on
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver>
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
@Suppress("UNCHECKED_CAST")
- (it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.takeIf { it.chatEvent is T } as? ChatEventMessage) ?.let(::listOfNotNull)
+ (it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.takeIf { it.chatEvent is T } as? ChatEventMessage) ?.let(::listOfNotNull)
}
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt
index e850638058..52bc9e271a 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.InlineQueryFilterB
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserInlineQueryMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate
+import dev.inmo.tgbotapi.extensions.utils.inlineQueryUpdateOrNull
import dev.inmo.tgbotapi.types.InlineQueries.query.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -15,7 +15,7 @@ internal suspend inline fun BC.
markerFactory: MarkerFactory = ByUserInlineQueryMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asInlineQueryUpdate() ?.data as? T) ?.let(::listOfNotNull)
+ (it.inlineQueryUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
}
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt
index 108465b116..31f52a2e73 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt
@@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
-import dev.inmo.micro_utils.coroutines.*
+import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt
index 8e868791df..58efa0cee3 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt
@@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessagesFilterByCh
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMediaGroupMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
+import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -20,7 +20,7 @@ internal suspend inline fun >, Any> = ByChatMediaGroupMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver>>
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asSentMediaGroupUpdate() ?.data ?.takeIf { messages ->
+ (it.sentMediaGroupUpdateOrNull() ?.data ?.takeIf { messages ->
messages.all { message ->
message.content is T
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt
index e1705cbf34..b4cd034da8 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt
@@ -5,8 +5,8 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
-import dev.inmo.tgbotapi.extensions.utils.asPassportMessage
+import dev.inmo.tgbotapi.extensions.utils.messageUpdateOrNull
+import dev.inmo.tgbotapi.extensions.utils.passportMessageOrNull
import dev.inmo.tgbotapi.types.message.PassportMessage
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportElement
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -17,7 +17,7 @@ internal suspend inline fun = ByChatMessageMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asMessageUpdate() ?.data ?.asPassportMessage() ?.takeIf { it.passportData.data.any { it is T } }) ?.let(::listOfNotNull)
+ (it.messageUpdateOrNull() ?.data ?.passportMessageOrNull() ?.takeIf { it.passportData.data.any { it is T } }) ?.let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt
index 549e052426..a09639754b 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt
@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdPollAnswerMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate
+import dev.inmo.tgbotapi.extensions.utils.pollAnswerUpdateOrNull
import dev.inmo.tgbotapi.types.polls.PollAnswer
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -16,7 +16,7 @@ internal suspend inline fun BC.onPollAnswered(
markerFactory: MarkerFactory = ByIdPollAnswerMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asPollAnswerUpdate() ?.data) ?.let(::listOfNotNull)
+ (it.pollAnswerUpdateOrNull() ?.data) ?.let(::listOfNotNull)
}
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt
index f9575de5e7..c9098d600d 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt
@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdPollMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
+import dev.inmo.tgbotapi.extensions.utils.pollUpdateOrNull
import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -16,7 +16,7 @@ internal suspend inline fun BC.onPollU
markerFactory: MarkerFactory = ByIdPollMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asPollUpdate() ?.data as? T) ?.let(::listOfNotNull)
+ (it.pollUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
}
/**
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt
index 3df37d6f8f..c53f1ecda0 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.PreCheckoutQueryFi
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserPreCheckoutQueryMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
+import dev.inmo.tgbotapi.extensions.utils.preCheckoutQueryUpdateOrNull
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -31,5 +31,5 @@ suspend fun BC.onPreCheckoutQuery(
markerFactory: MarkerFactory = ByUserPreCheckoutQueryMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asPreCheckoutQueryUpdate() ?.data) ?.let(::listOfNotNull)
+ (it.preCheckoutQueryUpdateOrNull() ?.data) ?.let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt
index 37cb05be12..1f82cf12cb 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ShippingQueryFilte
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserShippingQueryMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
-import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
+import dev.inmo.tgbotapi.extensions.utils.shippingQueryUpdateOrNull
import dev.inmo.tgbotapi.types.payments.ShippingQuery
import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -31,5 +31,5 @@ suspend fun BC.onShippingQuery(
markerFactory: MarkerFactory = ByUserShippingQueryMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
- (it.asShippingQueryUpdate() ?.data) ?.let(::listOfNotNull)
+ (it.shippingQueryUpdateOrNull() ?.data) ?.let(::listOfNotNull)
}
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt
index 5d7cfcc624..45a626be00 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt
@@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.utils
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTypeReceiver
-import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitEditedLocation
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitEditedLocationMessage
import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt
index a5d25816cd..f22d54379f 100644
--- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt
+++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt
@@ -1,9 +1,9 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
-import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
import dev.inmo.tgbotapi.types.payments.ShippingQuery
+import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
object ByUserCallbackQueryMarkerFactory : MarkerFactory {
override suspend fun invoke(data: CallbackQuery) = data.user
diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle
index 00c88b6d62..41b0bd2c47 100644
--- a/tgbotapi.core/build.gradle
+++ b/tgbotapi.core/build.gradle
@@ -1,6 +1,7 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
+ id "com.google.devtools.ksp"
}
project.description = "Core part of tgbotapi with all (and only) required functionality for working with Telegram Bot API"
@@ -28,6 +29,8 @@ kotlin {
api libs.microutils.languageCodes
api libs.ktor.client.core
+
+ api project(":tgbotapi.ksp:lib")
}
}
commonTest {
@@ -46,12 +49,15 @@ kotlin {
}
}
}
-
-// targets.all {
-// compilations.all {
-// kotlinOptions {
-// freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"]
-// }
-// }
-// }
+}
+
+dependencies {
+ add("kspCommonMainMetadata", project(":tgbotapi.ksp:processor"))
+ add("kspJvm", project(":tgbotapi.ksp:processor"))
+}
+
+ksp {
+ arg("cctargetPackage", "dev.inmo.tgbotapi.extensions.utils")
+ arg("ccoutputFileName", "ClassCastsNew")
+ arg("ccoutputFolder", project(":tgbotapi.utils").file("src/commonMain/kotlin").absolutePath)
}
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/CommonSendInvoiceData.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/CommonSendInvoiceData.kt
index 14c1f8ea76..cd31df05fb 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/CommonSendInvoiceData.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/CommonSendInvoiceData.kt
@@ -1,8 +1,10 @@
package dev.inmo.tgbotapi.abstracts
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.payments.abstracts.Currencied
import dev.inmo.tgbotapi.types.payments.abstracts.Priced
+@ClassCastsIncluded
interface CommonSendInvoiceData : Titled, Currencied, Priced {
val description: String
val payload: String
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithUser.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithUser.kt
index 6aeb8100b7..a9e76b96db 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithUser.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithUser.kt
@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.abstracts
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.chat.User
/**
@@ -7,6 +8,7 @@ import dev.inmo.tgbotapi.types.chat.User
*
* @see FromUser
*/
+@ClassCastsIncluded
interface WithUser {
val user: User
}
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMarkup.kt
deleted file mode 100644
index dce59184d8..0000000000
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMarkup.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-package dev.inmo.tgbotapi.abstracts.types
-
-import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
-
-interface ReplyMarkup {
- val replyMarkup: KeyboardMarkup?
-}
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyMarkup.kt
new file mode 100644
index 0000000000..3429d822c8
--- /dev/null
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyMarkup.kt
@@ -0,0 +1,9 @@
+package dev.inmo.tgbotapi.abstracts.types
+
+import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
+
+interface WithReplyMarkup {
+ val replyMarkup: KeyboardMarkup?
+}
+@Deprecated("Renamed", ReplaceWith("WithReplyMarkup", "dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup"))
+typealias ReplyMarkup = WithReplyMarkup
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 1078ecf512..5705ec13e9 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
@@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.requests
import dev.inmo.tgbotapi.abstracts.types.MessageAction
-import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
+import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@@ -17,7 +17,7 @@ data class StopPoll(
override val messageId: MessageIdentifier,
@SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null
-) : MessageAction, SimpleRequest, ReplyMarkup {
+) : MessageAction, SimpleRequest, WithReplyMarkup {
override fun method(): String = "stopPoll"
override val resultDeserializer: DeserializationStrategy
get() = PollSerializer
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage.kt
index 94bc78a3ce..45090bc8b7 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage.kt
@@ -1,8 +1,8 @@
package dev.inmo.tgbotapi.requests.edit.abstracts
-import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
+import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
-interface EditReplyMessage : ReplyMarkup {
+interface EditReplyMessage : WithReplyMarkup {
override val replyMarkup: InlineKeyboardMarkup?
}
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt
index c079f297a7..a2bb4ad842 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
@@ -20,10 +20,9 @@ import kotlinx.serialization.*
const val OrderChangingDeprecationWarn = "The order of parameters in this factory will be changed soon. To avoid unexpected behaviour, swap message id and target chat id parameters"
-@Deprecated(OrderChangingDeprecationWarn)
fun CopyMessage(
- fromChatId: ChatIdentifier,
toChatId: ChatIdentifier,
+ fromChatId: ChatIdentifier,
messageId: MessageIdentifier,
text: String? = null,
parseMode: ParseMode? = null,
@@ -46,10 +45,9 @@ fun CopyMessage(
replyMarkup
)
-@Deprecated(OrderChangingDeprecationWarn)
fun CopyMessage(
- fromChatId: ChatIdentifier,
toChatId: ChatIdentifier,
+ fromChatId: ChatIdentifier,
messageId: MessageIdentifier,
entities: List,
disableNotification: Boolean = false,
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest.kt
index f152390db7..0627d8d8d3 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest.kt
@@ -1,5 +1,5 @@
package dev.inmo.tgbotapi.requests.send.abstracts
-import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
+import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
-interface ReplyingMarkupSendMessageRequest: SendMessageRequest, ReplyMarkup
+interface ReplyingMarkupSendMessageRequest: SendMessageRequest, WithReplyMarkup
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt
index 93c75b0338..086b69edbf 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt
@@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.requests.send.games
-import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
+import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
@@ -29,7 +29,7 @@ data class SendGame (
@SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest>,
- ReplyMarkup {
+ WithReplyMarkup {
override fun method(): String = "sendGame"
override val resultDeserializer: DeserializationStrategy>
get() = commonResultDeserializer
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 a482268ade..0a51fafe4c 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
@@ -72,7 +72,7 @@ data class SendInvoice(
ChatRequest,
DisableNotification,
ReplyMessageId,
- ReplyMarkup,
+ WithReplyMarkup,
SendMessageRequest> {
override fun method(): String = "sendInvoice"
override val resultDeserializer: DeserializationStrategy>
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 69044c875b..fd748e46e8 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
@@ -39,19 +39,6 @@ val UserId.userLink: String
val User.link: String
get() = id.userLink
-/**
- * https://core.telegram.org/bots/api#formatting-options
- */
-@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
-val Identifier.link: String
- get() = "tg://user?id=$this"
-/**
- * https://core.telegram.org/bots/api#formatting-options
- */
-@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
-val ChatId.link: String
- get() = chatId.link
-
typealias UserId = ChatId
fun Identifier.toChatId(): ChatId = ChatId(this)
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt
index 9443c09391..3b5ac00da7 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt
@@ -1,13 +1,15 @@
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.Serializable
@Serializable(InlineQueryResultSerializer::class)
+@ClassCastsIncluded
interface InlineQueryResult {
val type: String
val id: InlineQueryIdentifier
val replyMarkup: InlineKeyboardMarkup?
-}
\ No newline at end of file
+}
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
index e440506ec2..232580cae2 100644
--- 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
@@ -1,7 +1,9 @@
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContentSerializer
import kotlinx.serialization.Serializable
@Serializable(InputMessageContentSerializer::class)
+@ClassCastsIncluded
sealed interface InputMessageContent
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt
index 856f3d8899..2ea92aaa72 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,7 @@
package dev.inmo.tgbotapi.types.actions
import dev.inmo.micro_utils.common.Warning
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
@@ -13,6 +14,7 @@ import kotlinx.serialization.encoding.Encoder
* Use BotAction objects realisations to notify user about bot actions
*/
@Serializable(BotActionSerializer::class)
+@ClassCastsIncluded
sealed interface BotAction {
val actionName: String
}
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 5117b6dfde..cf8ad42c5e 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
@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.games.CallbackGame
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
@@ -11,6 +12,7 @@ import kotlinx.serialization.json.*
* https://core.telegram.org/bots/api#inlinekeyboardbutton for more info
*/
@Serializable(InlineKeyboardButtonSerializer::class)
+@ClassCastsIncluded
sealed interface InlineKeyboardButton {
val text: String
}
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardMarkup.kt
index 4e008eb84b..afd46e4cff 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardMarkup.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardMarkup.kt
@@ -1,6 +1,8 @@
package dev.inmo.tgbotapi.types.buttons
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import kotlinx.serialization.Serializable
@Serializable(KeyboardMarkupSerializer::class)
+@ClassCastsIncluded
sealed interface KeyboardMarkup
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
index 24a2ee2443..51368f2594 100644
--- 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
@@ -19,15 +19,6 @@ data class ReplyForce(
val Selective = Selective()
val NonSelective = NonSelective()
val Default = ReplyForce()
-
- @Deprecated("Renamed", ReplaceWith("ReplyForce.Selective"))
- inline val ReplyForceSelective
- get() = Selective
- @Deprecated("Renamed", ReplaceWith("ReplyForce.NonSelective"))
- inline val ReplyForceNonSelective
- get() = NonSelective
- @Deprecated("Renamed", ReplaceWith("ReplyForce.Default"))
- val ReplyForceDefault = ReplyForce()
}
init {
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt
index 0d6bf752e1..04c0b7da44 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt
@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.chat
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.Serializable
@@ -43,6 +44,7 @@ sealed interface AbleToAddInAttachmentMenuChat : Chat {
}
@Serializable(PreviewChatSerializer::class)
+@ClassCastsIncluded
sealed interface Chat {
val id: ChatId
}
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt
index 9f58ee3ef2..ef730c86ec 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt
@@ -38,6 +38,3 @@ data class OwnerChatMember(
@Required
private val type: String = "creator"
}
-
-@Deprecated("Renamed", ReplaceWith("OwnerChatMember", "dev.inmo.tgbotapi.types.chat.member.OwnerChatMember"))
-typealias CreatorChatMember = OwnerChatMember
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 7e34caf55f..1c194eb490 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,5 +1,6 @@
package dev.inmo.tgbotapi.types.dice
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.KSerializer
@@ -9,6 +10,7 @@ import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
@Serializable(DiceAnimationTypeSerializer::class)
+@ClassCastsIncluded
sealed interface DiceAnimationType {
val emoji: String
val valueLimits: IntRange
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/TelegramMediaFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/TelegramMediaFile.kt
index b6e04f7e06..1d1e977d76 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/TelegramMediaFile.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/TelegramMediaFile.kt
@@ -1,11 +1,13 @@
package dev.inmo.tgbotapi.types.files
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
/**
* Declare common part of media files in Telegram. Note: it is not representation of JVM `File` type
*/
+@ClassCastsIncluded
sealed interface TelegramMediaFile {
val fileId: FileId
val fileUniqueId: FileUniqueId
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 28f09c744b..21724697c6 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
@@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.location
import dev.inmo.tgbotapi.abstracts.*
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.*
@@ -18,6 +19,7 @@ import kotlinx.serialization.json.JsonObject
* @see dev.inmo.tgbotapi.extensions.utils.asLiveLocation
*/
@Serializable(LocationSerializer::class)
+@ClassCastsIncluded
sealed interface Location : Locationed, HorizontallyAccured
@Serializable
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMedia.kt
index 2ae7932ede..f8dbf682a4 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMedia.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/media/TelegramMedia.kt
@@ -1,9 +1,11 @@
package dev.inmo.tgbotapi.types.media
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import kotlinx.serialization.Serializable
@Serializable(TelegramMediaSerializer::class)
+@ClassCastsIncluded
sealed interface TelegramMedia {
val type: String
val file: InputFile
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt
index ba73e100ae..4d664fcbd0 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt
@@ -4,6 +4,9 @@ import dev.inmo.tgbotapi.abstracts.WithUser
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
-data class LeftChatMember(
+data class LeftChatMemberEvent(
override val user: User
) : PublicChatEvent, WithUser
+
+@Deprecated("Renamed", ReplaceWith("dev.inmo.tgbotapi.types.message.ChatEvents", "LeftChatMemberEvent"))
+typealias LeftChatMember = LeftChatMemberEvent
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent.kt
index a3873a9305..cb5523bb17 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent.kt
@@ -1,3 +1,6 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
+
+@ClassCastsIncluded
interface ChatEvent
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt
index 225bd1e3c1..3bdde5c8d5 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt
@@ -1,42 +1,74 @@
package dev.inmo.tgbotapi.types.message
import dev.inmo.tgbotapi.abstracts.FromUser
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.User
-sealed class ForwardInfo {
+@ClassCastsIncluded
+sealed interface ForwardInfo {
abstract val dateOfOriginal: TelegramDate
+
+ data class ByAnonymous(
+ override val dateOfOriginal: TelegramDate,
+ val senderName: String
+ ) : ForwardInfo
+
+ data class ByUser(
+ override val dateOfOriginal: TelegramDate,
+ override val from: User
+ ) : ForwardInfo, FromUser
+
+ sealed interface PublicChat : ForwardInfo {
+ val chat: dev.inmo.tgbotapi.types.chat.PublicChat
+
+ /**
+ * Represent forward info for the message sent by [channelChat] into some group
+ */
+ data class SentByChannel(
+ override val dateOfOriginal: TelegramDate,
+ val channelChat: ChannelChat,
+ val signature: String? = null
+ ) : PublicChat {
+ override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
+ get() = channelChat
+ }
+
+ /**
+ * Represent forward info for the message sent by [channelChat] into that channel
+ */
+ data class FromChannel(
+ override val dateOfOriginal: TelegramDate,
+ val messageId: MessageIdentifier,
+ val channelChat: ChannelChat,
+ val signature: String? = null
+ ) : PublicChat {
+ override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
+ get() = channelChat
+ }
+
+ data class FromSupergroup(
+ override val dateOfOriginal: TelegramDate,
+ val group: SupergroupChat
+ ) : PublicChat {
+ override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
+ get() = group
+ }
+ }
}
-data class AnonymousForwardInfo(
- override val dateOfOriginal: TelegramDate,
- val senderName: String
-) : ForwardInfo()
+@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByAnonymous", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
+typealias AnonymousForwardInfo = ForwardInfo.ByAnonymous
-data class UserForwardInfo(
- override val dateOfOriginal: TelegramDate,
- override val from: User
-) : ForwardInfo(), FromUser
+@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByUser", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
+typealias UserForwardInfo = ForwardInfo.ByUser
-sealed class ForwardFromPublicChatInfo : ForwardInfo() {
- abstract val chat: PublicChat
-}
+@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
+typealias ForwardFromPublicChatInfo = ForwardInfo.PublicChat
-data class ForwardFromChannelInfo(
- override val dateOfOriginal: TelegramDate,
- val messageId: MessageIdentifier,
- val channelChat: ChannelChat,
- val signature: String? = null
-) : ForwardFromPublicChatInfo() {
- override val chat: PublicChat
- get() = channelChat
-}
+@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromChannel", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
+typealias ForwardFromChannelInfo = ForwardInfo.PublicChat.FromChannel
-data class ForwardFromSupergroupInfo(
- override val dateOfOriginal: TelegramDate,
- val group: SupergroupChat
-) : ForwardFromPublicChatInfo() {
- override val chat: PublicChat
- get() = group
-}
+@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromSupergroup", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
+typealias ForwardFromSupergroupInfo = ForwardInfo.PublicChat.FromSupergroup
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 1262958af1..2af80360d3 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
@@ -156,26 +156,39 @@ internal data class RawMessage(
}
private val forwarded: ForwardInfo? by lazy {
- forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
+ forward_date
+ ?: return@lazy null // According to the documentation, now any forwarded message contains this field
when {
- forward_sender_name != null -> AnonymousForwardInfo(
+ forward_sender_name != null -> ForwardInfo.ByAnonymous(
forward_date,
forward_sender_name
)
- forward_from_chat is ChannelChat -> ForwardFromChannelInfo(
- forward_date,
- forward_from_message_id ?: error("Channel forwarded message must contain message id, but was not"),
- forward_from_chat,
- forward_signature
- )
- forward_from_chat is SupergroupChat -> ForwardFromSupergroupInfo(
+
+ forward_from_chat is ChannelChat -> if (forward_from_message_id == null) {
+ ForwardInfo.PublicChat.SentByChannel(
+ forward_date,
+ forward_from_chat,
+ forward_signature
+ )
+ } else {
+ ForwardInfo.PublicChat.FromChannel(
+ forward_date,
+ forward_from_message_id,
+ forward_from_chat,
+ forward_signature
+ )
+ }
+
+ forward_from_chat is SupergroupChat -> ForwardInfo.PublicChat.FromSupergroup(
forward_date,
forward_from_chat
)
- forward_from != null -> UserForwardInfo(
+
+ forward_from != null -> ForwardInfo.ByUser(
forward_date,
forward_from
)
+
else -> null
}
}
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 012164c153..39859a9289 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
@@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.message.abstracts
import com.soywiz.klock.DateTime
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.RawMessage
@@ -9,6 +10,7 @@ import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
+@ClassCastsIncluded
interface Message {
val messageId: MessageIdentifier
val chat: Chat
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt
index 857ff558d8..453bef4726 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt
@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.message.content
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageIdentifier
@@ -108,6 +109,7 @@ sealed interface MediaContent: MessageContent {
fun asTelegramMedia(): TelegramMedia
}
+@ClassCastsIncluded
sealed interface ResendableContent {
fun createResend(
chatId: ChatIdentifier,
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/TextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/TextSource.kt
index 092833fa6c..2ae9efcde4 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/TextSource.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/TextSource.kt
@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.message.textsources
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.captionLength
import dev.inmo.tgbotapi.types.textLength
import kotlinx.serialization.Serializable
@@ -10,6 +11,7 @@ typealias TextSourcesList = List
typealias MutableTextSourcesList = MutableList
@Serializable(TextSourceSerializer::class)
+@ClassCastsIncluded
sealed interface TextSource {
val markdown: String
val markdownV2: String
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/PassportElementError.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/PassportElementError.kt
index 74dfc64364..adfcd9d2f3 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/PassportElementError.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/PassportElementError.kt
@@ -5,6 +5,7 @@ package dev.inmo.tgbotapi.types.passport
import dev.inmo.micro_utils.crypto.MD5
import dev.inmo.micro_utils.crypto.md5
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
import dev.inmo.tgbotapi.types.passport.encrypted.type
@@ -18,6 +19,7 @@ import kotlinx.serialization.json.*
val ByteArray.passportFileHash: MD5
get() = md5()
+@ClassCastsIncluded
@Serializable(PassportElementErrorSerializer::class)
sealed class PassportElementError {
abstract val source: String
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue.kt
index b9bb54371c..8eaec8b628 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue.kt
@@ -1,7 +1,9 @@
package dev.inmo.tgbotapi.types.passport.decrypted.abstracts
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.passport.credentials.EndDataCredentials
+@ClassCastsIncluded
interface SecureValue {
val credentials: List
}
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement.kt
index 6bf1d843df..8ae7705fa2 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement.kt
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
import dev.inmo.micro_utils.crypto.SourceBytes
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject
@@ -9,6 +10,7 @@ import kotlinx.serialization.json.JsonObject
typealias PassportElementHash = SourceBytes
@Serializable(EncryptedElementSerializer::class)
+@ClassCastsIncluded
interface EncryptedPassportElement {
val hash: PassportElementHash
}
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 373486a3f5..03a54de345 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
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.polls
import com.soywiz.klock.DateTime
import com.soywiz.klock.TimeSpan
import dev.inmo.tgbotapi.abstracts.TextedInput
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.types.message.RawMessageEntity
@@ -16,6 +17,7 @@ import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.*
+@ClassCastsIncluded
sealed interface ScheduledCloseInfo {
val closeDateTime: DateTime
}
@@ -45,6 +47,7 @@ val LongSeconds.asExactScheduledCloseInfo
)
@Serializable(PollSerializer::class)
+@ClassCastsIncluded
sealed interface Poll {
val id: PollIdentifier
val question: String
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 a06e2be315..55c3f42fb3 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
@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.update.abstracts
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.update.RawUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
@@ -10,6 +11,7 @@ import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonElement
+@ClassCastsIncluded
interface Update {
val updateId: UpdateIdentifier
val data: Any
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 56ffef940a..54338b3a7a 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,8 +1,7 @@
package dev.inmo.tgbotapi.utils.internal
+import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.textsources.MultilevelTextSource
-import dev.inmo.tgbotapi.types.UserId
-import dev.inmo.tgbotapi.types.link
import dev.inmo.tgbotapi.utils.extensions.*
internal fun MultilevelTextSource.markdownV2Default(
@@ -61,8 +60,8 @@ internal fun MultilevelTextSource.underlineMarkdownV2(): String = markdownV2Defa
internal fun MultilevelTextSource.underlineHTML(): String = htmlDefault(htmlUnderlineControl)
-internal fun MultilevelTextSource.textMentionMarkdownV2(userId: UserId): String = linkMarkdownV2(userId.link)
-internal fun MultilevelTextSource.textMentionHTML(userId: UserId): String = linkHTML(userId.link)
+internal fun MultilevelTextSource.textMentionMarkdownV2(userId: UserId): String = linkMarkdownV2(userId.userLink)
+internal fun MultilevelTextSource.textMentionHTML(userId: UserId): String = linkHTML(userId.userLink)
internal fun MultilevelTextSource.mentionMarkdownV2(): String = optionalPrefix("@") + subsources.makeMarkdownV2String()
internal fun MultilevelTextSource.mentionHTML(): String = optionalPrefix("@") + subsources.makeHtmlString()
diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/StringFormatting.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/StringFormatting.kt
index a43471b317..b7640743e0 100644
--- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/StringFormatting.kt
+++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/StringFormatting.kt
@@ -1,7 +1,6 @@
package dev.inmo.tgbotapi.utils.internal
-import dev.inmo.tgbotapi.types.UserId
-import dev.inmo.tgbotapi.types.link
+import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.utils.extensions.*
@@ -102,7 +101,7 @@ private inline fun String.hashTag(adapt: String.() -> String): String = if (star
"#${adapt()}"
}
-internal fun String.textMentionMarkdown(userId: UserId): String = linkMarkdown(userId.link)
+internal fun String.textMentionMarkdown(userId: UserId): String = linkMarkdown(userId.userLink)
internal fun String.mentionMarkdown(): String = mention(String::toMarkdown)
diff --git a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFileFromJavaFile.kt b/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFileFromJavaFile.kt
deleted file mode 100644
index c4f2a3ac47..0000000000
--- a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFileFromJavaFile.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package dev.inmo.tgbotapi.requests.abstracts
-
-import java.io.File
-
-@Deprecated("Duplacation of asMultipartFile", ReplaceWith("asMultipartFile", "dev.inmo.tgbotapi.requests.abstracts.asMultipartFile"))
-fun File.toInputFile() = asMultipartFile()
diff --git a/tgbotapi.ksp/lib/build.gradle b/tgbotapi.ksp/lib/build.gradle
new file mode 100644
index 0000000000..3048b631e0
--- /dev/null
+++ b/tgbotapi.ksp/lib/build.gradle
@@ -0,0 +1,7 @@
+plugins {
+ id "org.jetbrains.kotlin.multiplatform"
+}
+
+project.description = "Class Casts generator KSP library to include into your library"
+
+apply from: "$mppProjectWithSerializationPresetPath"
diff --git a/tgbotapi.ksp/lib/src/commonMain/kotlin/ClassCastsIncluded.kt b/tgbotapi.ksp/lib/src/commonMain/kotlin/ClassCastsIncluded.kt
new file mode 100644
index 0000000000..c0c3a45730
--- /dev/null
+++ b/tgbotapi.ksp/lib/src/commonMain/kotlin/ClassCastsIncluded.kt
@@ -0,0 +1,5 @@
+package dev.inmo.tgbotapi.ksp.lib
+
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.SOURCE)
+annotation class ClassCastsIncluded
diff --git a/tgbotapi.ksp/processor/build.gradle b/tgbotapi.ksp/processor/build.gradle
new file mode 100644
index 0000000000..985f68a50d
--- /dev/null
+++ b/tgbotapi.ksp/processor/build.gradle
@@ -0,0 +1,13 @@
+plugins {
+ id "org.jetbrains.kotlin.jvm"
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ implementation libs.kotlin.poet
+ implementation libs.ksp
+ implementation project(":tgbotapi.ksp:lib")
+}
diff --git a/tgbotapi.ksp/processor/src/main/kotlin/ClassCastsFiller.kt b/tgbotapi.ksp/processor/src/main/kotlin/ClassCastsFiller.kt
new file mode 100644
index 0000000000..6ff48ffec5
--- /dev/null
+++ b/tgbotapi.ksp/processor/src/main/kotlin/ClassCastsFiller.kt
@@ -0,0 +1,103 @@
+package dev.inmo.tgbotapi.ksp.processor
+
+import com.google.devtools.ksp.symbol.*
+import com.squareup.kotlinpoet.*
+import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
+import com.squareup.kotlinpoet.ksp.*
+
+private fun FileSpec.Builder.addTopLevelImport(className: ClassName) {
+ className.topLevelClassName().let {
+ addImport(it.packageName, it.simpleNames)
+ }
+}
+
+private fun FileSpec.Builder.createTypeDefinition(ksClassDeclaration: KSClassDeclaration): TypeName {
+ val className = ksClassDeclaration.toClassName()
+ return if (ksClassDeclaration.typeParameters.isNotEmpty()) {
+ className.parameterizedBy(
+ ksClassDeclaration.typeParameters.map {
+ it.bounds.first().resolve().also {
+ val typeClassName = it.toClassName()
+ addTopLevelImport(typeClassName)
+ }.toTypeName()
+ }
+ )
+ } else {
+ className
+ }
+}
+
+fun FileSpec.Builder.fill(
+ sourceKSClassDeclaration: KSClassDeclaration,
+ subtypesMap: Map>,
+ targetClassDeclaration: KSClassDeclaration = sourceKSClassDeclaration
+) {
+ if (sourceKSClassDeclaration == targetClassDeclaration) {
+ subtypesMap[sourceKSClassDeclaration] ?.forEach {
+ fill(sourceKSClassDeclaration, subtypesMap, it)
+ }
+ } else {
+ val sourceClassName = sourceKSClassDeclaration.toClassName()
+ val targetClassClassName = targetClassDeclaration.toClassName()
+ val targetClassTypeDefinition = createTypeDefinition(targetClassDeclaration)
+ val simpleName = targetClassDeclaration.simpleName.asString()
+ val withFirstLowerCase = simpleName.replaceFirstChar { it.lowercase() }
+ val castedOrNullName = "${withFirstLowerCase}OrNull"
+
+ addTopLevelImport(targetClassClassName)
+ addFunction(
+ FunSpec.builder(castedOrNullName).apply {
+ receiver(sourceClassName)
+ addCode(
+ "return this as? %L",
+ targetClassTypeDefinition
+ )
+ returns(targetClassTypeDefinition.copy(nullable = true))
+ addModifiers(KModifier.INLINE)
+ }.build()
+ )
+ addFunction(
+ FunSpec.builder("${withFirstLowerCase}OrThrow").apply {
+ receiver(sourceClassName)
+ addCode(
+ "return this as %L",
+ targetClassTypeDefinition
+ )
+ returns(targetClassTypeDefinition)
+ addModifiers(KModifier.INLINE)
+ }.build()
+ )
+ addFunction(
+ FunSpec.builder("if$simpleName").apply {
+ val genericType = TypeVariableName("T", null)
+ addTypeVariable(genericType)
+ receiver(sourceClassName)
+ addParameter(
+ "block",
+ LambdaTypeName.get(
+ null,
+ targetClassTypeDefinition,
+ returnType = genericType
+ )
+ )
+ addCode(
+ "return ${castedOrNullName}() ?.let(block)",
+ targetClassTypeDefinition
+ )
+ returns(genericType.copy(nullable = true))
+ addModifiers(KModifier.INLINE)
+ }.build()
+ )
+
+ subtypesMap[targetClassDeclaration] ?.let {
+ if (it.count { it.classKind == ClassKind.CLASS } > 1) {
+ it
+ } else {
+ it.filter { it.classKind != ClassKind.CLASS }
+ }
+ } ?.forEach {
+ fill(sourceKSClassDeclaration, subtypesMap, it)
+ fill(targetClassDeclaration, subtypesMap, it)
+ }
+ }
+}
diff --git a/tgbotapi.ksp/processor/src/main/kotlin/TelegramBotAPISymbolProcessor.kt b/tgbotapi.ksp/processor/src/main/kotlin/TelegramBotAPISymbolProcessor.kt
new file mode 100644
index 0000000000..7fdf0f635c
--- /dev/null
+++ b/tgbotapi.ksp/processor/src/main/kotlin/TelegramBotAPISymbolProcessor.kt
@@ -0,0 +1,77 @@
+package dev.inmo.tgbotapi.ksp.processor
+
+import com.google.devtools.ksp.getAllSuperTypes
+import com.google.devtools.ksp.processing.*
+import com.google.devtools.ksp.symbol.KSAnnotated
+import com.google.devtools.ksp.symbol.KSClassDeclaration
+import com.squareup.kotlinpoet.AnnotationSpec
+import com.squareup.kotlinpoet.FileSpec
+import com.squareup.kotlinpoet.ksp.writeTo
+import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
+import java.io.File
+
+class TelegramBotAPISymbolProcessor(
+ private val codeGenerator: CodeGenerator,
+ private val targetPackage: String = "",
+ private val outputFile: String = "Output",
+ private val outputFolder: String? = null
+) : SymbolProcessor {
+ override fun process(resolver: Resolver): List {
+ val classes = resolver.getSymbolsWithAnnotation(ClassCastsIncluded::class.qualifiedName!!).filterIsInstance()
+ val classesSubtypes = mutableMapOf>()
+
+ resolver.getAllFiles().forEach {
+ it.declarations.forEach { potentialSubtype ->
+ if (potentialSubtype is KSClassDeclaration) {
+ val allSupertypes = potentialSubtype.getAllSuperTypes().map { it.declaration }
+ classes.forEach {
+ if (it in allSupertypes) {
+ classesSubtypes.getOrPut(it) { mutableSetOf() }.add(potentialSubtype)
+ }
+ }
+ }
+ }
+ }
+ fun fillWithSealeds(source: KSClassDeclaration, current: KSClassDeclaration = source) {
+ current.getSealedSubclasses().forEach {
+ classesSubtypes.getOrPut(source) { mutableSetOf() }.add(it)
+ fillWithSealeds(source, it)
+ }
+ }
+ classes.forEach { fillWithSealeds(it) }
+
+ val fileSpec = FileSpec.builder(
+ targetPackage,
+ outputFile
+ ).apply {
+ addAnnotation(
+ AnnotationSpec.builder(Suppress::class).apply {
+ addMember("\"unused\"")
+ addMember("\"RemoveRedundantQualifierName\"")
+ addMember("\"RedundantVisibilityModifier\"")
+ addMember("\"NOTHING_TO_INLINE\"")
+ addMember("\"UNCHECKED_CAST\"")
+ addMember("\"OPT_IN_USAGE\"")
+ useSiteTarget(AnnotationSpec.UseSiteTarget.FILE)
+ }.build()
+ )
+ classes.forEach {
+ fill(
+ it,
+ classesSubtypes.toMap()
+ )
+ }
+ }.build()
+ runCatching {
+ outputFolder ?.also {
+ File(it).apply {
+ delete()
+ runCatching { mkdirs() }
+ fileSpec.writeTo(this)
+ }
+ } ?: fileSpec.writeTo(codeGenerator, false)
+ }
+
+ return emptyList()
+ }
+}
diff --git a/tgbotapi.ksp/processor/src/main/kotlin/TelegramBotAPISymbolProcessorProvider.kt b/tgbotapi.ksp/processor/src/main/kotlin/TelegramBotAPISymbolProcessorProvider.kt
new file mode 100644
index 0000000000..a6d4c0e7a9
--- /dev/null
+++ b/tgbotapi.ksp/processor/src/main/kotlin/TelegramBotAPISymbolProcessorProvider.kt
@@ -0,0 +1,14 @@
+package dev.inmo.tgbotapi.ksp.processor
+
+import com.google.devtools.ksp.processing.*
+
+class TelegramBotAPISymbolProcessorProvider : SymbolProcessorProvider {
+ override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
+ return TelegramBotAPISymbolProcessor(
+ environment.codeGenerator,
+ environment.options["cctargetPackage"] ?: "",
+ environment.options["ccoutputFileName"] ?: "Output",
+ environment.options["ccoutputFolder"],
+ )
+ }
+}
diff --git a/tgbotapi.ksp/processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider b/tgbotapi.ksp/processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider
new file mode 100644
index 0000000000..f0b099fb8c
--- /dev/null
+++ b/tgbotapi.ksp/processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider
@@ -0,0 +1 @@
+dev.inmo.tgbotapi.ksp.processor.TelegramBotAPISymbolProcessorProvider
diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt
index 2f3194d072..0a9cfa3e83 100644
--- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt
+++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt
@@ -6,8 +6,6 @@ import dev.inmo.tgbotapi.abstracts.*
import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
import dev.inmo.tgbotapi.types.*
-import dev.inmo.tgbotapi.types.queries.callback.*
-import dev.inmo.tgbotapi.types.chat.member.*
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
@@ -20,26 +18,16 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.*
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.*
import dev.inmo.tgbotapi.types.InlineQueries.query.*
-import dev.inmo.tgbotapi.types.media.*
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
import dev.inmo.tgbotapi.types.actions.*
import dev.inmo.tgbotapi.types.buttons.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
import dev.inmo.tgbotapi.types.chat.*
-import dev.inmo.tgbotapi.types.chat.Bot
-import dev.inmo.tgbotapi.types.chat.CommonBot
-import dev.inmo.tgbotapi.types.chat.CommonUser
-import dev.inmo.tgbotapi.types.chat.ExtendedBot
-import dev.inmo.tgbotapi.types.chat.User
-import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
-import dev.inmo.tgbotapi.types.chat.member.BannedChatMember
-import dev.inmo.tgbotapi.types.chat.member.ChatMember
-import dev.inmo.tgbotapi.types.chat.member.MemberChatMember
-import dev.inmo.tgbotapi.types.chat.member.SpecialRightsChatMember
+import dev.inmo.tgbotapi.types.chat.member.*
import dev.inmo.tgbotapi.types.dice.*
import dev.inmo.tgbotapi.types.files.*
-import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.location.*
+import dev.inmo.tgbotapi.types.media.*
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.LeftChatMember
@@ -48,11 +36,6 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
-import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
-import dev.inmo.tgbotapi.types.message.content.InvoiceContent
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
import dev.inmo.tgbotapi.types.message.textsources.*
import dev.inmo.tgbotapi.types.passport.*
@@ -61,13 +44,14 @@ import dev.inmo.tgbotapi.types.passport.decrypted.abstracts.*
import dev.inmo.tgbotapi.types.passport.encrypted.*
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
import dev.inmo.tgbotapi.types.polls.*
+import dev.inmo.tgbotapi.types.queries.callback.*
import dev.inmo.tgbotapi.types.update.*
import dev.inmo.tgbotapi.types.update.abstracts.*
import dev.inmo.tgbotapi.types.update.media_group.*
import dev.inmo.tgbotapi.utils.PreviewFeature
@PreviewFeature
-inline fun Chat.whenBot(block: (Bot) -> T) = asBot() ?.let(block)
+inline fun Chat.whenBot(block: (Bot) -> T) = asBot()?.let(block)
@PreviewFeature
inline fun Chat.asBot(): Bot? = this as? Bot
@@ -76,7 +60,7 @@ inline fun Chat.asBot(): Bot? = this as? Bot
inline fun Chat.requireBot(): Bot = this as Bot
@PreviewFeature
-inline fun Chat.whenCommonBot(block: (CommonBot) -> T) = asCommonBot() ?.let(block)
+inline fun Chat.whenCommonBot(block: (CommonBot) -> T) = asCommonBot()?.let(block)
@PreviewFeature
inline fun Chat.asCommonBot(): CommonBot? = this as? CommonBot
@@ -85,7 +69,7 @@ inline fun Chat.asCommonBot(): CommonBot? = this as? CommonBot
inline fun Chat.requireCommonBot(): CommonBot = this as CommonBot
@PreviewFeature
-inline fun Chat.whenCommonUser(block: (CommonUser) -> T) = asCommonUser() ?.let(block)
+inline fun Chat.whenCommonUser(block: (CommonUser) -> T) = asCommonUser()?.let(block)
@PreviewFeature
inline fun Chat.asCommonUser(): CommonUser? = this as? CommonUser
@@ -94,7 +78,7 @@ inline fun Chat.asCommonUser(): CommonUser? = this as? CommonUser
inline fun Chat.requireCommonUser(): CommonUser = this as CommonUser
@PreviewFeature
-inline fun Chat.whenExtendedBot(block: (ExtendedBot) -> T) = asExtendedBot() ?.let(block)
+inline fun Chat.whenExtendedBot(block: (ExtendedBot) -> T) = asExtendedBot()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedBot(): ExtendedBot? = this as? ExtendedBot
@@ -103,7 +87,7 @@ inline fun Chat.asExtendedBot(): ExtendedBot? = this as? ExtendedBot
inline fun Chat.requireExtendedBot(): ExtendedBot = this as ExtendedBot
@PreviewFeature
-inline fun Chat.whenUser(block: (User) -> T) = asUser() ?.let(block)
+inline fun Chat.whenUser(block: (User) -> T) = asUser()?.let(block)
@PreviewFeature
inline fun Chat.asUser(): User? = this as? User
@@ -112,7 +96,7 @@ inline fun Chat.asUser(): User? = this as? User
inline fun Chat.requireUser(): User = this as User
@PreviewFeature
-inline fun Chat.whenChannelChat(block: (ChannelChat) -> T) = asChannelChat() ?.let(block)
+inline fun Chat.whenChannelChat(block: (ChannelChat) -> T) = asChannelChat()?.let(block)
@PreviewFeature
inline fun Chat.asChannelChat(): ChannelChat? = this as? ChannelChat
@@ -121,7 +105,7 @@ inline fun Chat.asChannelChat(): ChannelChat? = this as? ChannelChat
inline fun Chat.requireChannelChat(): ChannelChat = this as ChannelChat
@PreviewFeature
-inline fun Chat.whenGroupChat(block: (GroupChat) -> T) = asGroupChat() ?.let(block)
+inline fun Chat.whenGroupChat(block: (GroupChat) -> T) = asGroupChat()?.let(block)
@PreviewFeature
inline fun Chat.asGroupChat(): GroupChat? = this as? GroupChat
@@ -130,7 +114,7 @@ inline fun Chat.asGroupChat(): GroupChat? = this as? GroupChat
inline fun Chat.requireGroupChat(): GroupChat = this as GroupChat
@PreviewFeature
-inline fun Chat.whenPrivateChat(block: (PrivateChat) -> T) = asPrivateChat() ?.let(block)
+inline fun Chat.whenPrivateChat(block: (PrivateChat) -> T) = asPrivateChat()?.let(block)
@PreviewFeature
inline fun Chat.asPrivateChat(): PrivateChat? = this as? PrivateChat
@@ -139,7 +123,7 @@ inline fun Chat.asPrivateChat(): PrivateChat? = this as? PrivateChat
inline fun Chat.requirePrivateChat(): PrivateChat = this as PrivateChat
@PreviewFeature
-inline fun Chat.whenPublicChat(block: (PublicChat) -> T) = asPublicChat() ?.let(block)
+inline fun Chat.whenPublicChat(block: (PublicChat) -> T) = asPublicChat()?.let(block)
@PreviewFeature
inline fun Chat.asPublicChat(): PublicChat? = this as? PublicChat
@@ -148,7 +132,7 @@ inline fun Chat.asPublicChat(): PublicChat? = this as? PublicChat
inline fun Chat.requirePublicChat(): PublicChat = this as PublicChat
@PreviewFeature
-inline fun Chat.whenSuperPublicChat(block: (SuperPublicChat) -> T) = asSuperPublicChat() ?.let(block)
+inline fun Chat.whenSuperPublicChat(block: (SuperPublicChat) -> T) = asSuperPublicChat()?.let(block)
@PreviewFeature
inline fun Chat.asSuperPublicChat(): SuperPublicChat? = this as? SuperPublicChat
@@ -157,7 +141,7 @@ inline fun Chat.asSuperPublicChat(): SuperPublicChat? = this as? SuperPublicChat
inline fun Chat.requireSuperPublicChat(): SuperPublicChat = this as SuperPublicChat
@PreviewFeature
-inline fun Chat.whenSupergroupChat(block: (SupergroupChat) -> T) = asSupergroupChat() ?.let(block)
+inline fun Chat.whenSupergroupChat(block: (SupergroupChat) -> T) = asSupergroupChat()?.let(block)
@PreviewFeature
inline fun Chat.asSupergroupChat(): SupergroupChat? = this as? SupergroupChat
@@ -166,7 +150,7 @@ inline fun Chat.asSupergroupChat(): SupergroupChat? = this as? SupergroupChat
inline fun Chat.requireSupergroupChat(): SupergroupChat = this as SupergroupChat
@PreviewFeature
-inline fun Chat.whenUnknownChatType(block: (UnknownChatType) -> T) = asUnknownChatType() ?.let(block)
+inline fun Chat.whenUnknownChatType(block: (UnknownChatType) -> T) = asUnknownChatType()?.let(block)
@PreviewFeature
inline fun Chat.asUnknownChatType(): UnknownChatType? = this as? UnknownChatType
@@ -175,7 +159,7 @@ inline fun Chat.asUnknownChatType(): UnknownChatType? = this as? UnknownChatType
inline fun Chat.requireUnknownChatType(): UnknownChatType = this as UnknownChatType
@PreviewFeature
-inline fun Chat.whenUsernameChat(block: (UsernameChat) -> T) = asUsernameChat() ?.let(block)
+inline fun Chat.whenUsernameChat(block: (UsernameChat) -> T) = asUsernameChat()?.let(block)
@PreviewFeature
inline fun Chat.asUsernameChat(): UsernameChat? = this as? UsernameChat
@@ -184,7 +168,7 @@ inline fun Chat.asUsernameChat(): UsernameChat? = this as? UsernameChat
inline fun Chat.requireUsernameChat(): UsernameChat = this as UsernameChat
@PreviewFeature
-inline fun Chat.whenExtendedChannelChat(block: (ExtendedChannelChat) -> T) = asExtendedChannelChat() ?.let(block)
+inline fun Chat.whenExtendedChannelChat(block: (ExtendedChannelChat) -> T) = asExtendedChannelChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedChannelChat(): ExtendedChannelChat? = this as? ExtendedChannelChat
@@ -193,7 +177,7 @@ inline fun Chat.asExtendedChannelChat(): ExtendedChannelChat? = this as? Extende
inline fun Chat.requireExtendedChannelChat(): ExtendedChannelChat = this as ExtendedChannelChat
@PreviewFeature
-inline fun Chat.whenExtendedChat(block: (ExtendedChat) -> T) = asExtendedChat() ?.let(block)
+inline fun Chat.whenExtendedChat(block: (ExtendedChat) -> T) = asExtendedChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedChat(): ExtendedChat? = this as? ExtendedChat
@@ -202,7 +186,7 @@ inline fun Chat.asExtendedChat(): ExtendedChat? = this as? ExtendedChat
inline fun Chat.requireExtendedChat(): ExtendedChat = this as ExtendedChat
@PreviewFeature
-inline fun Chat.whenExtendedGroupChat(block: (ExtendedGroupChat) -> T) = asExtendedGroupChat() ?.let(block)
+inline fun Chat.whenExtendedGroupChat(block: (ExtendedGroupChat) -> T) = asExtendedGroupChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedGroupChat(): ExtendedGroupChat? = this as? ExtendedGroupChat
@@ -211,7 +195,7 @@ inline fun Chat.asExtendedGroupChat(): ExtendedGroupChat? = this as? ExtendedGro
inline fun Chat.requireExtendedGroupChat(): ExtendedGroupChat = this as ExtendedGroupChat
@PreviewFeature
-inline fun Chat.whenExtendedPrivateChat(block: (ExtendedPrivateChat) -> T) = asExtendedPrivateChat() ?.let(block)
+inline fun Chat.whenExtendedPrivateChat(block: (ExtendedPrivateChat) -> T) = asExtendedPrivateChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedPrivateChat(): ExtendedPrivateChat? = this as? ExtendedPrivateChat
@@ -220,7 +204,7 @@ inline fun Chat.asExtendedPrivateChat(): ExtendedPrivateChat? = this as? Extende
inline fun Chat.requireExtendedPrivateChat(): ExtendedPrivateChat = this as ExtendedPrivateChat
@PreviewFeature
-inline fun Chat.whenExtendedPublicChat(block: (ExtendedPublicChat) -> T) = asExtendedPublicChat() ?.let(block)
+inline fun Chat.whenExtendedPublicChat(block: (ExtendedPublicChat) -> T) = asExtendedPublicChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedPublicChat(): ExtendedPublicChat? = this as? ExtendedPublicChat
@@ -229,7 +213,8 @@ inline fun Chat.asExtendedPublicChat(): ExtendedPublicChat? = this as? ExtendedP
inline fun Chat.requireExtendedPublicChat(): ExtendedPublicChat = this as ExtendedPublicChat
@PreviewFeature
-inline fun Chat.whenExtendedSupergroupChat(block: (ExtendedSupergroupChat) -> T) = asExtendedSupergroupChat() ?.let(block)
+inline fun Chat.whenExtendedSupergroupChat(block: (ExtendedSupergroupChat) -> T) =
+ asExtendedSupergroupChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? ExtendedSupergroupChat
@@ -238,7 +223,7 @@ inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? E
inline fun Chat.requireExtendedSupergroupChat(): ExtendedSupergroupChat = this as ExtendedSupergroupChat
@PreviewFeature
-inline fun Chat.whenPossiblyPremiumChat(block: (PossiblyPremiumChat) -> T) = asPossiblyPremiumChat() ?.let(block)
+inline fun Chat.whenPossiblyPremiumChat(block: (PossiblyPremiumChat) -> T) = asPossiblyPremiumChat()?.let(block)
@PreviewFeature
inline fun Chat.asPossiblyPremiumChat(): PossiblyPremiumChat? = this as? PossiblyPremiumChat
@@ -247,16 +232,19 @@ inline fun Chat.asPossiblyPremiumChat(): PossiblyPremiumChat? = this as? Possibl
inline fun Chat.requirePossiblyPremiumChat(): PossiblyPremiumChat = this as PossiblyPremiumChat
@PreviewFeature
-inline fun Chat.whenAbleToAddInAttachmentMenuChat(block: (AbleToAddInAttachmentMenuChat) -> T) = asAbleToAddInAttachmentMenuChat() ?.let(block)
+inline fun Chat.whenAbleToAddInAttachmentMenuChat(block: (AbleToAddInAttachmentMenuChat) -> T) =
+ asAbleToAddInAttachmentMenuChat()?.let(block)
@PreviewFeature
-inline fun Chat.asAbleToAddInAttachmentMenuChat(): AbleToAddInAttachmentMenuChat? = this as? AbleToAddInAttachmentMenuChat
+inline fun Chat.asAbleToAddInAttachmentMenuChat(): AbleToAddInAttachmentMenuChat? =
+ this as? AbleToAddInAttachmentMenuChat
@PreviewFeature
-inline fun Chat.requireAbleToAddInAttachmentMenuChat(): AbleToAddInAttachmentMenuChat = this as AbleToAddInAttachmentMenuChat
+inline fun Chat.requireAbleToAddInAttachmentMenuChat(): AbleToAddInAttachmentMenuChat =
+ this as AbleToAddInAttachmentMenuChat
@PreviewFeature
-inline fun CallbackQuery.whenDataCallbackQuery(block: (DataCallbackQuery) -> T) = asDataCallbackQuery() ?.let(block)
+inline fun CallbackQuery.whenDataCallbackQuery(block: (DataCallbackQuery) -> T) = asDataCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asDataCallbackQuery(): DataCallbackQuery? = this as? DataCallbackQuery
@@ -265,7 +253,8 @@ inline fun CallbackQuery.asDataCallbackQuery(): DataCallbackQuery? = this as? Da
inline fun CallbackQuery.requireDataCallbackQuery(): DataCallbackQuery = this as DataCallbackQuery
@PreviewFeature
-inline fun CallbackQuery.whenGameShortNameCallbackQuery(block: (GameShortNameCallbackQuery) -> T) = asGameShortNameCallbackQuery() ?.let(block)
+inline fun CallbackQuery.whenGameShortNameCallbackQuery(block: (GameShortNameCallbackQuery) -> T) =
+ asGameShortNameCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asGameShortNameCallbackQuery(): GameShortNameCallbackQuery? =
@@ -276,7 +265,8 @@ inline fun CallbackQuery.requireGameShortNameCallbackQuery(): GameShortNameCallb
this as GameShortNameCallbackQuery
@PreviewFeature
-inline fun CallbackQuery.whenInlineMessageIdCallbackQuery(block: (InlineMessageIdCallbackQuery) -> T) = asInlineMessageIdCallbackQuery() ?.let(block)
+inline fun CallbackQuery.whenInlineMessageIdCallbackQuery(block: (InlineMessageIdCallbackQuery) -> T) =
+ asInlineMessageIdCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery? =
@@ -287,7 +277,8 @@ inline fun CallbackQuery.requireInlineMessageIdCallbackQuery(): InlineMessageIdC
this as InlineMessageIdCallbackQuery
@PreviewFeature
-inline fun CallbackQuery.whenInlineMessageIdDataCallbackQuery(block: (InlineMessageIdDataCallbackQuery) -> T) = asInlineMessageIdDataCallbackQuery() ?.let(block)
+inline fun CallbackQuery.whenInlineMessageIdDataCallbackQuery(block: (InlineMessageIdDataCallbackQuery) -> T) =
+ asInlineMessageIdDataCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery? =
@@ -298,7 +289,8 @@ inline fun CallbackQuery.requireInlineMessageIdDataCallbackQuery(): InlineMessag
this as InlineMessageIdDataCallbackQuery
@PreviewFeature
-inline fun CallbackQuery.whenInlineMessageIdGameShortNameCallbackQuery(block: (InlineMessageIdGameShortNameCallbackQuery) -> T) = asInlineMessageIdGameShortNameCallbackQuery() ?.let(block)
+inline fun CallbackQuery.whenInlineMessageIdGameShortNameCallbackQuery(block: (InlineMessageIdGameShortNameCallbackQuery) -> T) =
+ asInlineMessageIdGameShortNameCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery? =
@@ -309,7 +301,8 @@ inline fun CallbackQuery.requireInlineMessageIdGameShortNameCallbackQuery(): Inl
this as InlineMessageIdGameShortNameCallbackQuery
@PreviewFeature
-inline fun CallbackQuery.whenMessageCallbackQuery(block: (MessageCallbackQuery) -> T) = asMessageCallbackQuery() ?.let(block)
+inline fun CallbackQuery.whenMessageCallbackQuery(block: (MessageCallbackQuery) -> T) =
+ asMessageCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asMessageCallbackQuery(): MessageCallbackQuery? = this as? MessageCallbackQuery
@@ -318,7 +311,8 @@ inline fun CallbackQuery.asMessageCallbackQuery(): MessageCallbackQuery? = this
inline fun CallbackQuery.requireMessageCallbackQuery(): MessageCallbackQuery = this as MessageCallbackQuery
@PreviewFeature
-inline fun CallbackQuery.whenMessageDataCallbackQuery(block: (MessageDataCallbackQuery) -> T) = asMessageDataCallbackQuery() ?.let(block)
+inline fun CallbackQuery.whenMessageDataCallbackQuery(block: (MessageDataCallbackQuery) -> T) =
+ asMessageDataCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asMessageDataCallbackQuery(): MessageDataCallbackQuery? = this as? MessageDataCallbackQuery
@@ -327,7 +321,8 @@ inline fun CallbackQuery.asMessageDataCallbackQuery(): MessageDataCallbackQuery?
inline fun CallbackQuery.requireMessageDataCallbackQuery(): MessageDataCallbackQuery = this as MessageDataCallbackQuery
@PreviewFeature
-inline fun CallbackQuery.whenMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T) = asMessageGameShortNameCallbackQuery() ?.let(block)
+inline fun CallbackQuery.whenMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T) =
+ asMessageGameShortNameCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery? =
@@ -338,7 +333,8 @@ inline fun CallbackQuery.requireMessageGameShortNameCallbackQuery(): MessageGame
this as MessageGameShortNameCallbackQuery
@PreviewFeature
-inline fun CallbackQuery.whenUnknownCallbackQueryType(block: (UnknownCallbackQueryType) -> T) = asUnknownCallbackQueryType() ?.let(block)
+inline fun CallbackQuery.whenUnknownCallbackQueryType(block: (UnknownCallbackQueryType) -> T) =
+ asUnknownCallbackQueryType()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asUnknownCallbackQueryType(): UnknownCallbackQueryType? = this as? UnknownCallbackQueryType
@@ -347,7 +343,8 @@ inline fun CallbackQuery.asUnknownCallbackQueryType(): UnknownCallbackQueryType?
inline fun CallbackQuery.requireUnknownCallbackQueryType(): UnknownCallbackQueryType = this as UnknownCallbackQueryType
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorDataField(block: (PassportElementErrorDataField) -> T) = asPassportElementErrorDataField() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorDataField(block: (PassportElementErrorDataField) -> T) =
+ asPassportElementErrorDataField()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorDataField(): PassportElementErrorDataField? =
@@ -358,7 +355,8 @@ inline fun PassportElementError.requirePassportElementErrorDataField(): Passport
this as PassportElementErrorDataField
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorFile(block: (PassportElementErrorFile) -> T) = asPassportElementErrorFile() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorFile(block: (PassportElementErrorFile) -> T) =
+ asPassportElementErrorFile()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorFile(): PassportElementErrorFile? =
@@ -369,7 +367,8 @@ inline fun PassportElementError.requirePassportElementErrorFile(): PassportEleme
this as PassportElementErrorFile
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorFiles(block: (PassportElementErrorFiles) -> T) = asPassportElementErrorFiles() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorFiles(block: (PassportElementErrorFiles) -> T) =
+ asPassportElementErrorFiles()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorFiles(): PassportElementErrorFiles? =
@@ -380,7 +379,8 @@ inline fun PassportElementError.requirePassportElementErrorFiles(): PassportElem
this as PassportElementErrorFiles
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorFrontSide(block: (PassportElementErrorFrontSide) -> T) = asPassportElementErrorFrontSide() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorFrontSide(block: (PassportElementErrorFrontSide) -> T) =
+ asPassportElementErrorFrontSide()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorFrontSide(): PassportElementErrorFrontSide? =
@@ -391,7 +391,8 @@ inline fun PassportElementError.requirePassportElementErrorFrontSide(): Passport
this as PassportElementErrorFrontSide
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorReverseSide(block: (PassportElementErrorReverseSide) -> T) = asPassportElementErrorReverseSide() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorReverseSide(block: (PassportElementErrorReverseSide) -> T) =
+ asPassportElementErrorReverseSide()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorReverseSide(): PassportElementErrorReverseSide? =
@@ -402,7 +403,8 @@ inline fun PassportElementError.requirePassportElementErrorReverseSide(): Passpo
this as PassportElementErrorReverseSide
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorSelfie(block: (PassportElementErrorSelfie) -> T) = asPassportElementErrorSelfie() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorSelfie(block: (PassportElementErrorSelfie) -> T) =
+ asPassportElementErrorSelfie()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorSelfie(): PassportElementErrorSelfie? =
@@ -413,7 +415,8 @@ inline fun PassportElementError.requirePassportElementErrorSelfie(): PassportEle
this as PassportElementErrorSelfie
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorTranslationFile(block: (PassportElementErrorTranslationFile) -> T) = asPassportElementErrorTranslationFile() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorTranslationFile(block: (PassportElementErrorTranslationFile) -> T) =
+ asPassportElementErrorTranslationFile()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorTranslationFile(): PassportElementErrorTranslationFile? =
@@ -424,7 +427,8 @@ inline fun PassportElementError.requirePassportElementErrorTranslationFile(): Pa
this as PassportElementErrorTranslationFile
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorTranslationFiles(block: (PassportElementErrorTranslationFiles) -> T) = asPassportElementErrorTranslationFiles() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorTranslationFiles(block: (PassportElementErrorTranslationFiles) -> T) =
+ asPassportElementErrorTranslationFiles()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorTranslationFiles(): PassportElementErrorTranslationFiles? =
@@ -435,7 +439,8 @@ inline fun PassportElementError.requirePassportElementErrorTranslationFiles(): P
this as PassportElementErrorTranslationFiles
@PreviewFeature
-inline fun PassportElementError.whenPassportElementErrorUnspecified(block: (PassportElementErrorUnspecified) -> T) = asPassportElementErrorUnspecified() ?.let(block)
+inline fun PassportElementError.whenPassportElementErrorUnspecified(block: (PassportElementErrorUnspecified) -> T) =
+ asPassportElementErrorUnspecified()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorUnspecified(): PassportElementErrorUnspecified? =
@@ -446,7 +451,8 @@ inline fun PassportElementError.requirePassportElementErrorUnspecified(): Passpo
this as PassportElementErrorUnspecified
@PreviewFeature
-inline fun PassportElementError.whenPassportElementFileError(block: (PassportElementFileError) -> T) = asPassportElementFileError() ?.let(block)
+inline fun PassportElementError.whenPassportElementFileError(block: (PassportElementFileError) -> T) =
+ asPassportElementFileError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementFileError(): PassportElementFileError? =
@@ -457,7 +463,8 @@ inline fun PassportElementError.requirePassportElementFileError(): PassportEleme
this as PassportElementFileError
@PreviewFeature
-inline fun PassportElementError.whenPassportElementFilesError(block: (PassportElementFilesError) -> T) = asPassportElementFilesError() ?.let(block)
+inline fun PassportElementError.whenPassportElementFilesError(block: (PassportElementFilesError) -> T) =
+ asPassportElementFilesError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementFilesError(): PassportElementFilesError? =
@@ -468,7 +475,8 @@ inline fun PassportElementError.requirePassportElementFilesError(): PassportElem
this as PassportElementFilesError
@PreviewFeature
-inline fun PassportElementError.whenPassportMultipleElementsError(block: (PassportMultipleElementsError) -> T) = asPassportMultipleElementsError() ?.let(block)
+inline fun PassportElementError.whenPassportMultipleElementsError(block: (PassportMultipleElementsError) -> T) =
+ asPassportMultipleElementsError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportMultipleElementsError(): PassportMultipleElementsError? =
@@ -479,7 +487,8 @@ inline fun PassportElementError.requirePassportMultipleElementsError(): Passport
this as PassportMultipleElementsError
@PreviewFeature
-inline fun PassportElementError.whenPassportSingleElementError(block: (PassportSingleElementError) -> T) = asPassportSingleElementError() ?.let(block)
+inline fun PassportElementError.whenPassportSingleElementError(block: (PassportSingleElementError) -> T) =
+ asPassportSingleElementError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportSingleElementError(): PassportSingleElementError? =
@@ -490,7 +499,8 @@ inline fun PassportElementError.requirePassportSingleElementError(): PassportSin
this as PassportSingleElementError
@PreviewFeature
-inline fun PassportElementError.whenUnknownPassportElementError(block: (UnknownPassportElementError) -> T) = asUnknownPassportElementError() ?.let(block)
+inline fun PassportElementError.whenUnknownPassportElementError(block: (UnknownPassportElementError) -> T) =
+ asUnknownPassportElementError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asUnknownPassportElementError(): UnknownPassportElementError? =
@@ -501,7 +511,7 @@ inline fun PassportElementError.requireUnknownPassportElementError(): UnknownPas
this as UnknownPassportElementError
@PreviewFeature
-inline fun EncryptedPassportElement.whenBankStatement(block: (BankStatement) -> T) = asBankStatement() ?.let(block)
+inline fun EncryptedPassportElement.whenBankStatement(block: (BankStatement) -> T) = asBankStatement()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asBankStatement(): BankStatement? = this as? BankStatement
@@ -510,7 +520,8 @@ inline fun EncryptedPassportElement.asBankStatement(): BankStatement? = this as?
inline fun EncryptedPassportElement.requireBankStatement(): BankStatement = this as BankStatement
@PreviewFeature
-inline fun EncryptedPassportElement.whenCommonPassport(block: (CommonPassport) -> T) = asCommonPassport() ?.let(block)
+inline fun EncryptedPassportElement.whenCommonPassport(block: (CommonPassport) -> T) =
+ asCommonPassport()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asCommonPassport(): CommonPassport? = this as? CommonPassport
@@ -519,7 +530,7 @@ inline fun EncryptedPassportElement.asCommonPassport(): CommonPassport? = this a
inline fun EncryptedPassportElement.requireCommonPassport(): CommonPassport = this as CommonPassport
@PreviewFeature
-inline fun EncryptedPassportElement.whenDriverLicense(block: (DriverLicense) -> T) = asDriverLicense() ?.let(block)
+inline fun EncryptedPassportElement.whenDriverLicense(block: (DriverLicense) -> T) = asDriverLicense()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asDriverLicense(): DriverLicense? = this as? DriverLicense
@@ -528,7 +539,7 @@ inline fun EncryptedPassportElement.asDriverLicense(): DriverLicense? = this as?
inline fun EncryptedPassportElement.requireDriverLicense(): DriverLicense = this as DriverLicense
@PreviewFeature
-inline fun EncryptedPassportElement.whenEmail(block: (Email) -> T) = asEmail() ?.let(block)
+inline fun EncryptedPassportElement.whenEmail(block: (Email) -> T) = asEmail()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEmail(): Email? = this as? Email
@@ -537,7 +548,8 @@ inline fun EncryptedPassportElement.asEmail(): Email? = this as? Email
inline fun EncryptedPassportElement.requireEmail(): Email = this as Email
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedAddress(block: (EncryptedAddress) -> T) = asEncryptedAddress() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedAddress(block: (EncryptedAddress) -> T) =
+ asEncryptedAddress()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedAddress(): EncryptedAddress? = this as? EncryptedAddress
@@ -546,7 +558,8 @@ inline fun EncryptedPassportElement.asEncryptedAddress(): EncryptedAddress? = th
inline fun EncryptedPassportElement.requireEncryptedAddress(): EncryptedAddress = this as EncryptedAddress
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPersonalDetails(block: (EncryptedPersonalDetails) -> T) = asEncryptedPersonalDetails() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPersonalDetails(block: (EncryptedPersonalDetails) -> T) =
+ asEncryptedPersonalDetails()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPersonalDetails(): EncryptedPersonalDetails? =
@@ -557,7 +570,7 @@ inline fun EncryptedPassportElement.requireEncryptedPersonalDetails(): Encrypted
this as EncryptedPersonalDetails
@PreviewFeature
-inline fun EncryptedPassportElement.whenIdentityCard(block: (IdentityCard) -> T) = asIdentityCard() ?.let(block)
+inline fun EncryptedPassportElement.whenIdentityCard(block: (IdentityCard) -> T) = asIdentityCard()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asIdentityCard(): IdentityCard? = this as? IdentityCard
@@ -566,7 +579,8 @@ inline fun EncryptedPassportElement.asIdentityCard(): IdentityCard? = this as? I
inline fun EncryptedPassportElement.requireIdentityCard(): IdentityCard = this as IdentityCard
@PreviewFeature
-inline fun EncryptedPassportElement.whenInternalPassport(block: (InternalPassport) -> T) = asInternalPassport() ?.let(block)
+inline fun EncryptedPassportElement.whenInternalPassport(block: (InternalPassport) -> T) =
+ asInternalPassport()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asInternalPassport(): InternalPassport? = this as? InternalPassport
@@ -575,7 +589,7 @@ inline fun EncryptedPassportElement.asInternalPassport(): InternalPassport? = th
inline fun EncryptedPassportElement.requireInternalPassport(): InternalPassport = this as InternalPassport
@PreviewFeature
-inline fun EncryptedPassportElement.whenPassport(block: (Passport) -> T) = asPassport() ?.let(block)
+inline fun EncryptedPassportElement.whenPassport(block: (Passport) -> T) = asPassport()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asPassport(): Passport? = this as? Passport
@@ -584,7 +598,8 @@ inline fun EncryptedPassportElement.asPassport(): Passport? = this as? Passport
inline fun EncryptedPassportElement.requirePassport(): Passport = this as Passport
@PreviewFeature
-inline fun EncryptedPassportElement.whenPassportRegistration(block: (PassportRegistration) -> T) = asPassportRegistration() ?.let(block)
+inline fun EncryptedPassportElement.whenPassportRegistration(block: (PassportRegistration) -> T) =
+ asPassportRegistration()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asPassportRegistration(): PassportRegistration? = this as? PassportRegistration
@@ -593,7 +608,7 @@ inline fun EncryptedPassportElement.asPassportRegistration(): PassportRegistrati
inline fun EncryptedPassportElement.requirePassportRegistration(): PassportRegistration = this as PassportRegistration
@PreviewFeature
-inline fun EncryptedPassportElement.whenPhoneNumber(block: (PhoneNumber) -> T) = asPhoneNumber() ?.let(block)
+inline fun EncryptedPassportElement.whenPhoneNumber(block: (PhoneNumber) -> T) = asPhoneNumber()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asPhoneNumber(): PhoneNumber? = this as? PhoneNumber
@@ -602,7 +617,8 @@ inline fun EncryptedPassportElement.asPhoneNumber(): PhoneNumber? = this as? Pho
inline fun EncryptedPassportElement.requirePhoneNumber(): PhoneNumber = this as PhoneNumber
@PreviewFeature
-inline fun EncryptedPassportElement.whenRentalAgreement(block: (RentalAgreement) -> T) = asRentalAgreement() ?.let(block)
+inline fun EncryptedPassportElement.whenRentalAgreement(block: (RentalAgreement) -> T) =
+ asRentalAgreement()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asRentalAgreement(): RentalAgreement? = this as? RentalAgreement
@@ -611,7 +627,8 @@ inline fun EncryptedPassportElement.asRentalAgreement(): RentalAgreement? = this
inline fun EncryptedPassportElement.requireRentalAgreement(): RentalAgreement = this as RentalAgreement
@PreviewFeature
-inline fun EncryptedPassportElement.whenTemporaryRegistration(block: (TemporaryRegistration) -> T) = asTemporaryRegistration() ?.let(block)
+inline fun EncryptedPassportElement.whenTemporaryRegistration(block: (TemporaryRegistration) -> T) =
+ asTemporaryRegistration()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asTemporaryRegistration(): TemporaryRegistration? = this as? TemporaryRegistration
@@ -621,7 +638,8 @@ inline fun EncryptedPassportElement.requireTemporaryRegistration(): TemporaryReg
this as TemporaryRegistration
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithTranslatableFilesCollection(block: (EncryptedPassportElementWithTranslatableFilesCollection) -> T) = asEncryptedPassportElementWithTranslatableFilesCollection() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithTranslatableFilesCollection(block: (EncryptedPassportElementWithTranslatableFilesCollection) -> T) =
+ asEncryptedPassportElementWithTranslatableFilesCollection()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithTranslatableFilesCollection(): EncryptedPassportElementWithTranslatableFilesCollection? =
@@ -632,7 +650,8 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithTranslata
this as EncryptedPassportElementWithTranslatableFilesCollection
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithTranslatableIDDocument(block: (EncryptedPassportElementWithTranslatableIDDocument) -> T) = asEncryptedPassportElementWithTranslatableIDDocument() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithTranslatableIDDocument(block: (EncryptedPassportElementWithTranslatableIDDocument) -> T) =
+ asEncryptedPassportElementWithTranslatableIDDocument()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithTranslatableIDDocument(): EncryptedPassportElementWithTranslatableIDDocument? =
@@ -643,7 +662,7 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithTranslata
this as EncryptedPassportElementWithTranslatableIDDocument
@PreviewFeature
-inline fun EncryptedPassportElement.whenUtilityBill(block: (UtilityBill) -> T) = asUtilityBill() ?.let(block)
+inline fun EncryptedPassportElement.whenUtilityBill(block: (UtilityBill) -> T) = asUtilityBill()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asUtilityBill(): UtilityBill? = this as? UtilityBill
@@ -652,7 +671,8 @@ inline fun EncryptedPassportElement.asUtilityBill(): UtilityBill? = this as? Uti
inline fun EncryptedPassportElement.requireUtilityBill(): UtilityBill = this as UtilityBill
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithFilesCollection(block: (EncryptedPassportElementWithFilesCollection) -> T) = asEncryptedPassportElementWithFilesCollection() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithFilesCollection(block: (EncryptedPassportElementWithFilesCollection) -> T) =
+ asEncryptedPassportElementWithFilesCollection()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithFilesCollection(): EncryptedPassportElementWithFilesCollection? =
@@ -663,7 +683,8 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithFilesColl
this as EncryptedPassportElementWithFilesCollection
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementTranslatable(block: (EncryptedPassportElementTranslatable) -> T) = asEncryptedPassportElementTranslatable() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementTranslatable(block: (EncryptedPassportElementTranslatable) -> T) =
+ asEncryptedPassportElementTranslatable()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementTranslatable(): EncryptedPassportElementTranslatable? =
@@ -674,7 +695,8 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementTranslatable(
this as EncryptedPassportElementTranslatable
@PreviewFeature
-inline fun EncryptedPassportElement.whenUnknownEncryptedPassportElement(block: (UnknownEncryptedPassportElement) -> T) = asUnknownEncryptedPassportElement() ?.let(block)
+inline fun EncryptedPassportElement.whenUnknownEncryptedPassportElement(block: (UnknownEncryptedPassportElement) -> T) =
+ asUnknownEncryptedPassportElement()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asUnknownEncryptedPassportElement(): UnknownEncryptedPassportElement? =
@@ -685,7 +707,8 @@ inline fun EncryptedPassportElement.requireUnknownEncryptedPassportElement(): Un
this as UnknownEncryptedPassportElement
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithData(block: (EncryptedPassportElementWithData) -> T) = asEncryptedPassportElementWithData() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithData(block: (EncryptedPassportElementWithData) -> T) =
+ asEncryptedPassportElementWithData()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithData(): EncryptedPassportElementWithData? =
@@ -696,7 +719,8 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithData(): E
this as EncryptedPassportElementWithData
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithEmail(block: (EncryptedPassportElementWithEmail) -> T) = asEncryptedPassportElementWithEmail() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithEmail(block: (EncryptedPassportElementWithEmail) -> T) =
+ asEncryptedPassportElementWithEmail()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithEmail(): EncryptedPassportElementWithEmail? =
@@ -707,7 +731,8 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithEmail():
this as EncryptedPassportElementWithEmail
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithFrontSide(block: (EncryptedPassportElementWithFrontSide) -> T) = asEncryptedPassportElementWithFrontSide() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithFrontSide(block: (EncryptedPassportElementWithFrontSide) -> T) =
+ asEncryptedPassportElementWithFrontSide()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithFrontSide(): EncryptedPassportElementWithFrontSide? =
@@ -718,7 +743,8 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithFrontSide
this as EncryptedPassportElementWithFrontSide
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithPhoneNumber(block: (EncryptedPassportElementWithPhoneNumber) -> T) = asEncryptedPassportElementWithPhoneNumber() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithPhoneNumber(block: (EncryptedPassportElementWithPhoneNumber) -> T) =
+ asEncryptedPassportElementWithPhoneNumber()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithPhoneNumber(): EncryptedPassportElementWithPhoneNumber? =
@@ -729,7 +755,8 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithPhoneNumb
this as EncryptedPassportElementWithPhoneNumber
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithReverseSide(block: (EncryptedPassportElementWithReverseSide) -> T) = asEncryptedPassportElementWithReverseSide() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithReverseSide(block: (EncryptedPassportElementWithReverseSide) -> T) =
+ asEncryptedPassportElementWithReverseSide()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithReverseSide(): EncryptedPassportElementWithReverseSide? =
@@ -740,7 +767,8 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithReverseSi
this as EncryptedPassportElementWithReverseSide
@PreviewFeature
-inline fun EncryptedPassportElement.whenEncryptedPassportElementWithSelfie(block: (EncryptedPassportElementWithSelfie) -> T) = asEncryptedPassportElementWithSelfie() ?.let(block)
+inline fun EncryptedPassportElement.whenEncryptedPassportElementWithSelfie(block: (EncryptedPassportElementWithSelfie) -> T) =
+ asEncryptedPassportElementWithSelfie()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithSelfie(): EncryptedPassportElementWithSelfie? =
@@ -751,7 +779,7 @@ inline fun EncryptedPassportElement.requireEncryptedPassportElementWithSelfie():
this as EncryptedPassportElementWithSelfie
@PreviewFeature
-inline fun SecureValue.whenAddressSecureValue(block: (AddressSecureValue) -> T) = asAddressSecureValue() ?.let(block)
+inline fun SecureValue.whenAddressSecureValue(block: (AddressSecureValue) -> T) = asAddressSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asAddressSecureValue(): AddressSecureValue? = this as? AddressSecureValue
@@ -760,7 +788,8 @@ inline fun SecureValue.asAddressSecureValue(): AddressSecureValue? = this as? Ad
inline fun SecureValue.requireAddressSecureValue(): AddressSecureValue = this as AddressSecureValue
@PreviewFeature
-inline fun SecureValue.whenBankStatementSecureValue(block: (BankStatementSecureValue) -> T) = asBankStatementSecureValue() ?.let(block)
+inline fun SecureValue.whenBankStatementSecureValue(block: (BankStatementSecureValue) -> T) =
+ asBankStatementSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asBankStatementSecureValue(): BankStatementSecureValue? = this as? BankStatementSecureValue
@@ -769,7 +798,8 @@ inline fun SecureValue.asBankStatementSecureValue(): BankStatementSecureValue? =
inline fun SecureValue.requireBankStatementSecureValue(): BankStatementSecureValue = this as BankStatementSecureValue
@PreviewFeature
-inline fun SecureValue.whenCommonPassportSecureValue(block: (CommonPassportSecureValue) -> T) = asCommonPassportSecureValue() ?.let(block)
+inline fun SecureValue.whenCommonPassportSecureValue(block: (CommonPassportSecureValue) -> T) =
+ asCommonPassportSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asCommonPassportSecureValue(): CommonPassportSecureValue? = this as? CommonPassportSecureValue
@@ -778,7 +808,8 @@ inline fun SecureValue.asCommonPassportSecureValue(): CommonPassportSecureValue?
inline fun SecureValue.requireCommonPassportSecureValue(): CommonPassportSecureValue = this as CommonPassportSecureValue
@PreviewFeature
-inline fun