diff --git a/CHANGELOG.md b/CHANGELOG.md index b87ca5c368..2a667251bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # TelegramBotAPI changelog +## 0.31.0 + +**THIS UPDATE CONTAINS BREAKING CHANGES** + +* `Common`: + * **ALL DEPRECATIONS CREATED SINCE 0.30.0 WERE REMOVED** +* `Behaviour Builder`: + * Extension `TelegramBot#buildBehaviour` have changed its return value: now it is `Job` instead of + `FlowsUpdatesFilter` +* `Utils` + * New extensions `TelegramBot#longPolling` were added as new recommended way to start getting updates via long + polling + * Old extensions `RequestsExecutor#startGettingFlowsUpdatesByLongPolling` has been deprecated + ## 0.30.13 * `Common`: diff --git a/gradle.properties b/gradle.properties index ff14f86b2c..ff09a58916 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.16 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.30.13 +library_version=0.31.0 github_release_plugin_version=2.2.12 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 19869d6658..ca8c529fce 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt index 139ae89e82..7cee50ae0b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Captioned.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.CommonAbstracts import dev.inmo.tgbotapi.types.ParseMode.ParseMode -import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource interface Captioned { val caption: String? @@ -13,8 +12,7 @@ interface CaptionedOutput : Captioned { interface CaptionedInput : Captioned { /** - * Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - * @see [CaptionedInput.fullEntitiesList] + * Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] */ val captionEntities: List } @@ -25,10 +23,3 @@ interface CaptionedInput : Captioned { */ val CaptionedInput.textSources get() = captionEntities.justTextSources() - -/** - * Convert its [CaptionedInput.captionEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource] - * with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - */ -@Deprecated("Currently list of entities already full. This method is redundant") -fun CaptionedInput.fullEntitiesList(): TextSourcesList = caption ?.fullListOfSubSource(captionEntities) ?.map { it.source } ?: emptyList() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt index fb837163fd..05e7cd1c63 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Explained.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.CommonAbstracts import dev.inmo.tgbotapi.types.ParseMode.ParseMode -import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource interface Explained { val explanation: String? @@ -19,8 +18,7 @@ interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput interface ExplainedInput : Explained { /** - * Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - * @see [ExplainedInput.fullEntitiesList] + * Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] */ val explanationEntities: List } @@ -31,10 +29,3 @@ interface ExplainedInput : Explained { */ val ExplainedInput.textSources get() = explanationEntities.justTextSources() - -/** - * Convert its [ExplainedInput.explanationEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource] - * with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - */ -@Deprecated("Currently list of entities already full. This method is redundant") -fun ExplainedInput.fullEntitiesList(): TextSourcesList = explanation ?.fullListOfSubSource(explanationEntities) ?.map { it.source } ?: emptyList() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt index 08f70a5041..06481a6ebe 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt @@ -8,10 +8,6 @@ import dev.inmo.tgbotapi.types.textLength const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods" typealias TextSourcesList = List -@Deprecated("All lists of TextSource in public API now are full. So, this typealias is redundant") -typealias FullTextSourcesList = List -@Deprecated("All lists of TextPart in public API now are full. So, this typealias is redundant") -typealias FullTextPartsList = List interface TextSource { val markdown: String @@ -21,16 +17,6 @@ interface TextSource { val asText: String get() = source - - @Deprecated("Rename", ReplaceWith("markdown")) - val asMarkdownSource: String - get() = markdown - @Deprecated("Rename", ReplaceWith("markdownV2")) - val asMarkdownV2Source: String - get() = markdownV2 - @Deprecated("Rename", ReplaceWith("html")) - val asHtmlSource: String - get() = html } @Suppress("NOTHING_TO_INLINE") @@ -43,13 +29,7 @@ inline operator fun TextSource.plus(text: String) = listOf(this, regular(text)) inline operator fun List.plus(text: String) = this + regular(text) interface MultilevelTextSource : TextSource { - @Deprecated("Will be removed in near major release") - val textParts: List - get() = textParts(0) val subsources: List - @Deprecated("Will be removed in near major release", ReplaceWith("subsources")) - val textSources: List - get() = subsources } data class TextPart( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt index afd4ac6dec..0b556444e5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.CommonAbstracts import dev.inmo.tgbotapi.types.ParseMode.ParseMode -import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource interface Texted { val text: String? @@ -22,7 +21,6 @@ interface TextedInput : Texted { * Here must be full list of entities. This list must contains [TextPart]s with * [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of * regular text - * @see [CaptionedInput.fullEntitiesList] */ val textEntities: List } @@ -35,10 +33,3 @@ interface TextedInput : Texted { */ val TextedInput.textSources get() = textEntities.justTextSources() - -/** - * Convert its [TextedInput.textEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource] - * with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - */ -@Deprecated("Currently list of entities already full. This method is redundant") -fun TextedInput.fullEntitiesList(): TextSourcesList = text ?.fullListOfSubSource(textEntities) ?.map { it.source } ?: emptyList() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt index db18339ec3..97225fce01 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt @@ -5,7 +5,8 @@ import dev.inmo.tgbotapi.bot.BaseRequestsExecutor import dev.inmo.tgbotapi.bot.Ktor.base.* import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.exceptions.newRequestException -import dev.inmo.tgbotapi.bot.settings.limiters.* +import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter +import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.Response import dev.inmo.tgbotapi.utils.* @@ -67,7 +68,7 @@ class KtorRequestsExecutor( return safely( { e -> throw if (e is ClientRequestException) { - val content = e.response ?.readText() ?: throw e + val content = e.response.readText() val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content) newRequestException( responseObject, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/AbstractRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/AbstractRequestCallFactory.kt index 11a25ddfac..bedbc96283 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/AbstractRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/AbstractRequestCallFactory.kt @@ -6,7 +6,6 @@ import dev.inmo.tgbotapi.bot.exceptions.newRequestException import dev.inmo.tgbotapi.requests.GetUpdates import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.Response -import dev.inmo.tgbotapi.types.RetryAfterError import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import io.ktor.client.HttpClient import io.ktor.client.call.receive @@ -14,7 +13,6 @@ import io.ktor.client.features.timeout import io.ktor.client.request.* import io.ktor.client.statement.HttpResponse import io.ktor.http.ContentType -import kotlinx.coroutines.delay import kotlinx.serialization.json.Json import kotlin.collections.set diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt index ed440617ad..87cae741b3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt @@ -25,10 +25,9 @@ object MultipartRequestCallFactory : AbstractRequestCallFactory() { Headers.build { append(HttpHeaders.ContentType, value.mimeType) append(HttpHeaders.ContentDisposition, "filename=${value.fileId}") - } - ) { - value.file.asInput() - } + }, + block = value.file::input + ) is FileId -> append(key, value.fileId) else -> append(key, value.toString()) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/exceptions/RequestException.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/exceptions/RequestException.kt index f792616fc2..687392c696 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/exceptions/RequestException.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/exceptions/RequestException.kt @@ -1,7 +1,8 @@ package dev.inmo.tgbotapi.bot.exceptions import com.soywiz.klock.DateTime -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.Response +import dev.inmo.tgbotapi.types.RetryAfterError import io.ktor.utils.io.errors.IOException fun newRequestException( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/CommonLimiter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/CommonLimiter.kt index d87b007544..a38d5a60fd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/CommonLimiter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/CommonLimiter.kt @@ -1,15 +1,11 @@ package dev.inmo.tgbotapi.bot.settings.limiters import com.soywiz.klock.DateTime -import dev.inmo.micro_utils.coroutines.* import dev.inmo.tgbotapi.types.MilliSeconds import kotlinx.coroutines.* -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.flow.filter import kotlinx.coroutines.sync.Semaphore import kotlinx.serialization.Serializable import kotlinx.serialization.Transient -import kotlin.coroutines.Continuation import kotlin.math.roundToLong private fun now(): Long = DateTime.nowUnixLong() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/ExceptionsOnlyLimiter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/ExceptionsOnlyLimiter.kt index 477b4a48f8..643d302bbd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/ExceptionsOnlyLimiter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/ExceptionsOnlyLimiter.kt @@ -2,11 +2,13 @@ package dev.inmo.tgbotapi.bot.settings.limiters import dev.inmo.micro_utils.coroutines.safely import dev.inmo.tgbotapi.bot.exceptions.TooMuchRequestsException -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.MilliSeconds +import dev.inmo.tgbotapi.types.RetryAfterError import io.ktor.client.features.ClientRequestException import io.ktor.http.HttpStatusCode import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.first /** * This limiter will limit requests only after getting a [RetryAfterError] or [ClientRequestException] with @@ -60,6 +62,3 @@ class ExceptionsOnlyLimiter( } } } - -@Deprecated("Renamed", ReplaceWith("ExceptionsOnlyLimiter", "dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter")) -typealias EmptyLimiter = ExceptionsOnlyLimiter diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/PowLimiter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/PowLimiter.kt index 2eb0a87fa9..bb20345101 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/PowLimiter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/settings/limiters/PowLimiter.kt @@ -1,9 +1,9 @@ package dev.inmo.tgbotapi.bot.settings.limiters -import dev.inmo.micro_utils.coroutines.* +import dev.inmo.micro_utils.coroutines.actor +import dev.inmo.micro_utils.coroutines.safely import dev.inmo.tgbotapi.types.MilliSeconds import kotlinx.coroutines.* -import kotlinx.coroutines.channels.Channel import kotlinx.serialization.Serializable import kotlinx.serialization.Transient import kotlin.coroutines.* diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/modify/UnpinChatMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/modify/UnpinChatMessage.kt index 868559b16d..8439853634 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/modify/UnpinChatMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/modify/UnpinChatMessage.kt @@ -2,10 +2,7 @@ package dev.inmo.tgbotapi.requests.chat.modify import dev.inmo.tgbotapi.CommonAbstracts.types.ChatRequest import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageIdentifier -import dev.inmo.tgbotapi.types.chatIdField -import dev.inmo.tgbotapi.types.messageIdField +import dev.inmo.tgbotapi.types.* import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt index 817ff9ba0c..4ddbf8e68f 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 @@ -9,8 +9,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup -import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import kotlinx.serialization.* fun CopyMessage( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt index 5c2784e85d..0115d80198 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt @@ -87,7 +87,7 @@ fun Poll.createRequest( correctOptionId, isAnonymous, isClosed, - fullEntitiesList(), + textSources, scheduledCloseInfo, disableNotification, replyToMessageId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt index 3e54a9c6ad..087ec7723b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt @@ -1,7 +1,8 @@ package dev.inmo.tgbotapi.requests.webhook import dev.inmo.tgbotapi.requests.abstracts.* -import dev.inmo.tgbotapi.requests.send.media.base.* +import dev.inmo.tgbotapi.requests.send.media.base.DataRequest +import dev.inmo.tgbotapi.requests.send.media.base.MultipartRequestImpl import dev.inmo.tgbotapi.types.* import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 34538eedf0..c66d9d81a2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -62,12 +62,6 @@ val inlineQueryAnswerResultsLimit = 0 .. 50 val customTitleLength = 0 .. 16 val dartsCubeAndBowlingDiceResultLimit = 1 .. 6 -@Deprecated("Renamed", ReplaceWith("dartsCubeAndBowlingDiceResultLimit", "dev.inmo.tgbotapi.types.dartsCubeAndBowlingDiceResultLimit")) -val dartsAndCubeDiceResultLimit - get() = dartsCubeAndBowlingDiceResultLimit -@Deprecated("Renamed", ReplaceWith("dartsCubeAndBowlingDiceResultLimit", "dev.inmo.tgbotapi.types.dartsCubeAndBowlingDiceResultLimit")) -val diceResultLimit - get() = dartsCubeAndBowlingDiceResultLimit val basketballAndFootballDiceResultLimit = 1 .. 5 val slotMachineDiceResultLimit = 1 .. 64 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt index b27d04396d..b56f188204 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult @@ -8,10 +7,5 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInp const val inlineQueryResultAudioType = "audio" interface InlineQueryResultAudioCommon : InlineQueryResult, - CaptionedOutput, TextedOutput, - WithInputMessageContentInlineQueryResult { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text -} + WithInputMessageContentInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/document/InlineQueryResultDocumentCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/document/InlineQueryResultDocumentCommon.kt index fa51b3e0e0..44ce297be0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/document/InlineQueryResultDocumentCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/document/InlineQueryResultDocumentCommon.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* @@ -9,10 +8,5 @@ const val inlineQueryResultDocumentType = "document" interface InlineQueryResultDocumentCommon : InlineQueryResult, TitledInlineQueryResult, DescribedInlineQueryResult, - CaptionedOutput, TextedOutput, - WithInputMessageContentInlineQueryResult { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text -} + WithInputMessageContentInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt index 95e5f14480..a99ba9c91c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/gif/InlineQueryResultGifCommon.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* @@ -8,10 +7,5 @@ const val inlineQueryResultGifType = "gif" interface InlineQueryResultGifCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, - CaptionedOutput, TextedOutput, - WithInputMessageContentInlineQueryResult { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text -} + WithInputMessageContentInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt index 69b4e5b88c..cdf1e72963 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/mpeg4gif/InlineQueryResultMpeg4GifCommon.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* @@ -8,10 +7,5 @@ const val inlineQueryResultMpeg4GifType = "mpeg4_gif" interface InlineQueryResultMpeg4GifCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, - CaptionedOutput, TextedOutput, - WithInputMessageContentInlineQueryResult { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text -} + WithInputMessageContentInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt index 1f33a3a9b9..85a05c23a9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/photo/InlineQueryResultPhotoCommon.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* @@ -9,10 +8,5 @@ const val inlineQueryResultPhotoType = "photo" interface InlineQueryResultPhotoCommon : InlineQueryResult, OptionallyTitledInlineQueryResult, DescribedInlineQueryResult, - CaptionedOutput, TextedOutput, - WithInputMessageContentInlineQueryResult { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text -} + WithInputMessageContentInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt index a015faac61..1543537e76 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/video/InlineQueryResultVideoCommon.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* @@ -9,10 +8,5 @@ const val inlineQueryResultVideoType = "video" interface InlineQueryResultVideoCommon : InlineQueryResult, TitledInlineQueryResult, DescribedInlineQueryResult, - CaptionedOutput, TextedOutput, - WithInputMessageContentInlineQueryResult { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text -} + WithInputMessageContentInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt index 0bb3dee55b..5c1ffb868c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/voice/InlineQueryResultVoiceCommon.kt @@ -1,17 +1,11 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* const val inlineQueryResultVoiceType = "voice" interface InlineQueryResultVoiceCommon : InlineQueryResult, - CaptionedOutput, TextedOutput, WithInputMessageContentInlineQueryResult, - TitledInlineQueryResult { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text -} + TitledInlineQueryResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt index 9a2d74746b..5871b5a144 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt @@ -37,10 +37,7 @@ data class InputTextMessageContent internal constructor( private val rawEntities: List? = null, @SerialName(disableWebPagePreviewField) override val disableWebPagePreview: Boolean? = null -) : CaptionedOutput, TextedOutput, DisableWebPagePreview, InputMessageContent { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text +) : TextedOutput, DisableWebPagePreview, InputMessageContent { override val entities: List? by lazy { rawEntities ?.asTextParts(text) ?.justTextSources() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMedia.kt index 48e99180ca..81f0d88c33 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMedia.kt @@ -3,9 +3,6 @@ package dev.inmo.tgbotapi.types.InputMedia import dev.inmo.tgbotapi.requests.abstracts.InputFile import kotlinx.serialization.Serializable -@Deprecated("Will be removed due to redundancy for end-side users") -fun String.toInputMediaFileAttachmentName() = "attach://$this" - @Serializable(InputMediaSerializer::class) interface InputMedia { val type: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt index 5eb5e61c8e..77eaec8b68 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt @@ -42,16 +42,12 @@ data class InputMediaAnimation internal constructor( override val height: Int? = null, override val duration: Long? = null, override val thumb: InputFile? = null -) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput, CaptionedOutput { +) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput { override val type: String = "animation" override val entities: List? by lazy { rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources() } - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text - @SerialName(mediaField) override val media: String init { media = file.fileIdToSend } // crutch until js compiling will be fixed diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt index 7e63cc915b..77fa02d59b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/MediaGroupMemberInputMedia.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput import kotlinx.serialization.* import kotlinx.serialization.json.Json @@ -16,10 +15,7 @@ internal fun T.buildArguments(withSerializer: SerializationStrategy) = ar ) @Serializable(MediaGroupMemberInputMediaSerializer::class) -interface MediaGroupMemberInputMedia : InputMedia, CaptionedOutput, TextedOutput { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text +interface MediaGroupMemberInputMedia : InputMedia, TextedOutput { fun serialize(format: StringFormat): String } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/ThumbedInputMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/ThumbedInputMedia.kt index d2b51c84b1..e44851ad94 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/ThumbedInputMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/ThumbedInputMedia.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.types.InputMedia -import dev.inmo.tgbotapi.requests.abstracts.* +import dev.inmo.tgbotapi.requests.abstracts.InputFile interface ThumbedInputMedia : InputMedia { val thumb: InputFile? diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt index d4a05a7bc4..83223e01cb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.boldMarkdown -import dev.inmo.tgbotapi.utils.internal.boldMarkdownV2 /** * @see bold diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt index 1923aa88bc..83d00409a0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt @@ -1,10 +1,9 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.commandMarkdown -import dev.inmo.tgbotapi.utils.internal.commandMarkdownV2 private val commandRegex = Regex("[/!][^@\\s]*") diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt index 4fa504f5ce..eb80cbf655 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.cashTagMarkdown -import dev.inmo.tgbotapi.utils.internal.cashTagMarkdownV2 /** * @see cashTag diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt index 7935f01fc3..e71c556e9e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt @@ -2,10 +2,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor import dev.inmo.tgbotapi.CommonAbstracts.TextSource -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.codeMarkdown -import dev.inmo.tgbotapi.utils.internal.codeMarkdownV2 /** * @see code diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt index 6de5d3ddce..83311b871e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.emailMarkdown -import dev.inmo.tgbotapi.utils.internal.emailMarkdownV2 /** * @see email diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt index 109ef54cbc..3b33b8faf0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.hashTagMarkdown -import dev.inmo.tgbotapi.utils.internal.hashTagMarkdownV2 /** * @see hashtag diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt index 92e71013c6..e72ed0b357 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.italicMarkdown -import dev.inmo.tgbotapi.utils.internal.italicMarkdownV2 /** * @see italic diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt index 421c89c7a3..288a191773 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.mentionMarkdown -import dev.inmo.tgbotapi.utils.internal.mentionMarkdownV2 private val String.withoutCommercialAt get() = if (startsWith("@")) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt index ea3bb8feae..e17c1ec716 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.phoneMarkdown -import dev.inmo.tgbotapi.utils.internal.phoneMarkdownV2 /** * @see phone diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt index 4c001f5387..e22910e0f1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt @@ -1,10 +1,9 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.preMarkdown -import dev.inmo.tgbotapi.utils.internal.preMarkdownV2 /** * @see pre diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt index 1d78129ca6..e880d6e2ba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt @@ -1,10 +1,9 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.regularMarkdown -import dev.inmo.tgbotapi.utils.internal.regularMarkdownV2 /** * @see regular diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt index a1557d1b88..524f3ca1a1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.strikethroughMarkdown -import dev.inmo.tgbotapi.utils.internal.strikethroughMarkdownV2 /** * @see strikethrough diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt index 482fb7dcbc..c6170764fd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt @@ -1,10 +1,9 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.linkMarkdown -import dev.inmo.tgbotapi.utils.internal.linkMarkdownV2 /** * @see link diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt index 8fd7a50521..4166e4b489 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt @@ -2,10 +2,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.User -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.textMentionMarkdown -import dev.inmo.tgbotapi.utils.internal.textMentionMarkdownV2 /** * @see mention diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt index c2cad771c6..cf84858378 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt @@ -1,10 +1,9 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor +import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.linkMarkdown -import dev.inmo.tgbotapi.utils.internal.linkMarkdownV2 /** * @see link diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt index 4a7a799fdb..febc609a9d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt @@ -1,10 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.CommonAbstracts.* -import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.underlineMarkdown -import dev.inmo.tgbotapi.utils.internal.underlineMarkdownV2 /** * @see underline diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/PrivateChat.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/PrivateChat.kt index d87404fdad..83dfb87afc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/PrivateChat.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/PrivateChat.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.chat.abstracts -import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PreviewChatSerializer import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelEventMessage.kt index 009dd19ef7..65bcc348cc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelEventMessage.kt @@ -4,7 +4,6 @@ import com.soywiz.klock.DateTime import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage data class ChannelEventMessage( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMessageImpl.kt index ba28d6c5ba..73cdf10cb9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMessageImpl.kt @@ -20,6 +20,3 @@ data class ChannelMessageImpl( override val senderBot: CommonBot?, override val authorSignature: AuthorSignature? ) : ChannelMessage - -@Deprecated("Renamed", ReplaceWith("ChannelMessageImpl", "dev.inmo.tgbotapi.types.message.ChannelMessageImpl")) -typealias ChannelMessage = ChannelMessageImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt index d3c2edb7a4..03e228f693 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt @@ -7,9 +7,6 @@ import dev.inmo.tgbotapi.types.chat.abstracts.GroupChat import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage -@Deprecated("Renamed", ReplaceWith("CommonGroupEventMessage")) -typealias GroupEventMessage = CommonGroupEventMessage<*> - data class CommonGroupEventMessage( override val messageId: MessageIdentifier, override val user: User, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt index d79212f169..b63a7dbf1b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt @@ -4,13 +4,9 @@ import com.soywiz.klock.DateTime import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage -@Deprecated("Renamed", ReplaceWith("CommonSupergroupEventMessage")) -typealias SupergroupEventMessage = CommonSupergroupEventMessage<*> - data class CommonSupergroupEventMessage( override val messageId: MessageIdentifier, override val user: User, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt index 232fb6a88a..e627f034e3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt @@ -22,6 +22,3 @@ data class PrivateMessageImpl( override val senderBot: CommonBot?, val paymentInfo: SuccessfulPaymentInfo? ) : PrivateMessage - -@Deprecated("Renamed", ReplaceWith("PrivateMessageImpl", "dev.inmo.tgbotapi.types.message.PrivateMessageImpl")) -typealias CommonMessageImpl = PrivateMessageImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index 304ace106a..83a5488e46 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.message.content -import dev.inmo.tgbotapi.CommonAbstracts.* +import dev.inmo.tgbotapi.CommonAbstracts.TextPart +import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.types.ChatIdentifier @@ -10,17 +11,11 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent import dev.inmo.tgbotapi.utils.internal.* -import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource -import dev.inmo.tgbotapi.utils.internal.toMarkdownTexts data class TextContent( override val text: String, override val textEntities: List = emptyList() ) : MessageContent, TextedInput { - @Deprecated("Has been renamed", ReplaceWith("textEntities")) - val entities: List - get() = textEntities - override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, @@ -77,10 +72,3 @@ data class TextContent( ) } } - -/** - * Convert its [TextContent.entities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource] - * with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - */ -@Deprecated("Useless due to the fact that currently every message contains full list of sources") -fun TextContent.fullEntitiesList(): TextSourcesList = text.fullListOfSubSource(entities).map { it.source } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt index f89e623676..2d516c712a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt @@ -18,6 +18,7 @@ package dev.inmo.tgbotapi.utils ) annotation class PreviewFeature +const val lowLevelRiskFeatureMessage = "This method is low-level and not recommended to direct use" @RequiresOptIn( "This feature can work unstable and may have some restrictions in Telegram System", RequiresOptIn.Level.WARNING diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/HandleSafely.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/HandleSafely.kt deleted file mode 100644 index 6f93f28984..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/HandleSafely.kt +++ /dev/null @@ -1,21 +0,0 @@ -package dev.inmo.tgbotapi.utils - -import dev.inmo.micro_utils.coroutines.ExceptionHandler -import dev.inmo.micro_utils.coroutines.safely -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.supervisorScope - - -@Deprecated("In future will be used typealias from micro_utils", ReplaceWith("ExceptionHandler", "dev.inmo.micro_utils.coroutines.ExceptionHandler")) -typealias ExceptionHandler = ExceptionHandler -/** - * It will run [block] inside of [supervisorScope] to avoid problems with catching of exceptions - * - * @param [onException] Will be called when happen exception inside of [block]. By default will throw exception - this - * exception will be available for catching - */ -@Deprecated("In future will be used typealias from micro_utils", ReplaceWith("safely", "dev.inmo.micro_utils.coroutines.safely")) -suspend inline fun handleSafely( - noinline onException: ExceptionHandler = { throw it }, - noinline block: suspend CoroutineScope.() -> T -): T = safely(onException, block) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt index a5beeeb0ca..167f6b80b8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt @@ -5,19 +5,40 @@ import io.ktor.utils.io.core.ByteReadPacket import io.ktor.utils.io.core.Input import kotlinx.serialization.Serializable +/** + * Information about file for [StorageFile] + * + * @param contentType Raw type like "application/json" + * @param fileName This filename will be used in telegram system as name of file + */ @Serializable data class StorageFileInfo( val contentType: String, val fileName: String ) { + /** + * This methods is required for random generation of name for keeping warranties about unique file name + */ fun generateCustomName() = "${uuid4()}.${fileName.fileExtension}" } +/** + * Contains info about file, which potentially can be sent to telegram system. + * + * @param storageFileInfo Information about this file + * @param inputSource Lambda which able to allocate [Input] for uploading/manipulating data + * + * @see StorageFileInfo + * @see asStorageFile + */ data class StorageFile( val storageFileInfo: StorageFileInfo, private val inputSource: () -> Input ) { - fun asInput() = inputSource() + val input: Input + get() = inputSource() + @Deprecated("This method will be fully replaced with input property", ReplaceWith("input")) + fun asInput() = input } @Suppress("NOTHING_TO_INLINE") @@ -31,5 +52,8 @@ inline fun StorageFile( ByteReadPacket(bytes) } -@Suppress("NOTHING_TO_INLINE") +/** + * + */ +@Suppress("NOTHING_TO_INLINE", "unused") inline fun ByteArray.asStorageFile(fileName: String, mimeType: MimeType) = StorageFile(fileName, this, mimeType) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/BaseMessageUpdateToMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/BaseMessageUpdateToMediaGroupUpdate.kt deleted file mode 100644 index 5e4cc86d4f..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/BaseMessageUpdateToMediaGroupUpdate.kt +++ /dev/null @@ -1,55 +0,0 @@ -package dev.inmo.tgbotapi.utils.internal - -import dev.inmo.tgbotapi.types.MediaGroupIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.update.* -import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.* -import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate -import dev.inmo.tgbotapi.types.update.abstracts.Update - -private inline val Pair.message - get() = first - -internal fun List.convertWithMediaGroupUpdates(): List { - val resultUpdates = mutableListOf() - val mediaGroups = mutableMapOf>() - for (update in this) { - val asEditMediaGroupMessage = update.toEditMediaGroupUpdate() - if (asEditMediaGroupMessage != null) { - resultUpdates.add(asEditMediaGroupMessage) - } else { - val data = update.data - if (data is MediaGroupMessage) { - (mediaGroups[data.mediaGroupId] ?: mutableListOf().also { mediaGroups[data.mediaGroupId] = it }).add(update) - } else { - resultUpdates.add(update) - } - } - } - mediaGroups.values.map { - it.toSentMediaGroupUpdate() ?.let { mediaGroupUpdate -> - resultUpdates.add(mediaGroupUpdate) - } - } - return resultUpdates.sortedBy { it.updateId } -} - -internal fun List.toSentMediaGroupUpdate(): SentMediaGroupUpdate? = (this as? SentMediaGroupUpdate) ?: let { - if (isEmpty()) { - return@let null - } - val resultList = sortedBy { it.updateId } - when (first()) { - is MessageUpdate -> MessageMediaGroupUpdate(resultList) - is ChannelPostUpdate -> ChannelPostMediaGroupUpdate(resultList) - else -> null - } -} - -internal fun BaseMessageUpdate.toEditMediaGroupUpdate(): EditMediaGroupUpdate? = (this as? EditMediaGroupUpdate) ?: let { - when (this) { - is EditMessageUpdate -> EditMessageMediaGroupUpdate(this) - is EditChannelPostUpdate -> EditChannelPostMediaGroupUpdate(this) - else -> null - } -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/CaptionAndTextSourcesToText.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/CaptionAndTextSourcesToText.kt index 5502e2e29a..143dd51d53 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/CaptionAndTextSourcesToText.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/CaptionAndTextSourcesToText.kt @@ -4,7 +4,6 @@ import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.ParseMode.* import dev.inmo.tgbotapi.types.message.content.TextContent -import dev.inmo.tgbotapi.types.message.content.fullEntitiesList internal fun createFormattedText( entities: TextSourcesList, @@ -56,13 +55,7 @@ internal fun TextSourcesList.toMarkdownTexts(): List = createMarkdownTex this, textLength.last ) -internal fun TextContent.toMarkdownTexts(): List = fullEntitiesList().toMarkdownTexts() - -internal fun TextSourcesList.toMarkdownExplanations(): List = createMarkdownText( - this, - explanationLimit.last -) -internal fun ExplainedInput.toMarkdownExplanations(): List = fullEntitiesList().toMarkdownTexts() +internal fun TextContent.toMarkdownTexts(): List = textSources.toMarkdownTexts() internal fun createMarkdownV2Text( @@ -74,19 +67,13 @@ internal fun TextSourcesList.toMarkdownV2Captions(): List = createMarkdo this, captionLength.last ) -internal fun CaptionedInput.toMarkdownV2Captions(): List = fullEntitiesList().toMarkdownV2Captions() +internal fun CaptionedInput.toMarkdownV2Captions(): List = textSources.toMarkdownV2Captions() internal fun TextSourcesList.toMarkdownV2Texts(): List = createMarkdownV2Text( this, textLength.last ) -internal fun TextContent.toMarkdownV2Texts(): List = fullEntitiesList().toMarkdownV2Texts() - -internal fun TextSourcesList.toMarkdownV2Explanations(): List = createMarkdownV2Text( - this, - explanationLimit.last -) -internal fun ExplainedInput.toMarkdownV2Explanations(): List = fullEntitiesList().toMarkdownV2Texts() +internal fun TextContent.toMarkdownV2Texts(): List = textSources.toMarkdownV2Texts() internal fun createHtmlText( @@ -98,12 +85,12 @@ internal fun TextSourcesList.toHtmlCaptions(): List = createHtmlText( this, captionLength.last ) -internal fun CaptionedInput.toHtmlCaptions(): List = fullEntitiesList().toHtmlCaptions() +internal fun CaptionedInput.toHtmlCaptions(): List = textSources.toHtmlCaptions() internal fun TextSourcesList.toHtmlTexts(): List = createHtmlText( this, textLength.last ) -internal fun TextContent.toHtmlTexts(): List = fullEntitiesList().toHtmlTexts() +internal fun TextContent.toHtmlTexts(): List = textSources.toHtmlTexts() 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 ec8cf5ab7c..bac1e06c41 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 @@ -148,8 +148,3 @@ internal fun MultilevelTextSource.hashTagHTML(): String = optionalPrefix("#") + internal fun MultilevelTextSource.phoneMarkdownV2(): String = subsources.joinSubSourcesMarkdownV2() internal fun MultilevelTextSource.phoneHTML(): String = subsources.joinSubSourcesHtml() - - -internal fun MultilevelTextSource.commandMarkdownV2(): String = optionalPrefix("/") + subsources.joinSubSourcesMarkdownV2() -internal fun MultilevelTextSource.commandHTML(): String = optionalPrefix("/") + subsources.joinSubSourcesHtml() - 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 2c3b8e8076..dce43d2d63 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 @@ -99,12 +99,10 @@ private inline fun String.hashTag(adapt: String.() -> String): String = if (star } internal fun String.textMentionMarkdown(userId: UserId): String = linkMarkdown(userId.link) -internal fun String.textMentionMarkdownV2(userId: UserId): String = linkMarkdownV2(userId.link) internal fun String.mentionMarkdown(): String = mention(String::toMarkdown) internal fun String.hashTagMarkdown(): String = hashTag(String::toMarkdown) -internal fun String.hashTagHTML(): String = hashTag(String::toHtml) internal fun String.phoneMarkdown(): String = toMarkdown() @@ -136,14 +134,6 @@ internal infix fun Pair.link(parseMode: ParseMode): String = whe is MarkdownV2 -> first.linkMarkdownV2(second) } - -internal infix fun String.command(parseMode: ParseMode): String = when (parseMode) { - is HTML -> commandHTML() - is Markdown -> commandMarkdown() - is MarkdownV2 -> commandMarkdownV2() -} - - internal infix fun String.underline(parseMode: ParseMode): String = when (parseMode) { is HTML -> underlineHTML() is Markdown -> underlineMarkdown() diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt index 34a7e66975..459bcdf648 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types.MessageEntity import dev.inmo.tgbotapi.CommonAbstracts.TextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.CommonAbstracts.plus +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.utils.internal.* import kotlin.test.Test import kotlin.test.assertEquals diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/TextPartsCreatingTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/TextPartsCreatingTests.kt index a4150e0d3d..ee3941f1ff 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/TextPartsCreatingTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/TextPartsCreatingTests.kt @@ -3,7 +3,8 @@ package dev.inmo.tgbotapi.types.MessageEntity import dev.inmo.tgbotapi.CommonAbstracts.justTextSources import dev.inmo.tgbotapi.utils.internal.toHtmlTexts import dev.inmo.tgbotapi.utils.internal.toMarkdownV2Texts -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals class TextPartsCreatingTests { @Test 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 index 7492cc3d98..34350831f3 100644 --- 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 @@ -1,9 +1,7 @@ package dev.inmo.tgbotapi.requests.abstracts -import dev.inmo.tgbotapi.utils.MimeType import dev.inmo.tgbotapi.utils.StorageFile import java.io.File -import java.io.InputStream fun File.toInputFile() = if (exists()) { MultipartFile( diff --git a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/StorageFileFactory.kt b/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/StorageFileFactory.kt index 4aab4c57b6..8d7ebe5c53 100644 --- a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/StorageFileFactory.kt +++ b/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/StorageFileFactory.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.utils import io.ktor.utils.io.streams.asInput import java.io.File -import java.io.InputStream import java.nio.file.Files fun StorageFile( diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt index 9e3c3dd8f5..ba33c8425f 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt @@ -45,17 +45,3 @@ fun buildBot( TelegramAPIUrlsKeeper(token, apiUrl), BotBuilder().apply(block).createHttpClient() ) - -/** - * @return Created by [telegramBotWithCustomClientConfig] function [TelegramBot]. This executor will be preconfigured using [token] and - * [block] - */ -@Deprecated("Renamed", ReplaceWith("buildBot", "dev.inmo.tgbotapi.extensions.api.buildBot")) -fun telegramBot( - token: String, - block: BotBuilder.() -> Unit -): TelegramBot = buildBot( - token, - telegramBotAPIDefaultUrl, - block -) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt index 18c1c2bcfb..c704fc94b2 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.extensions.api -import dev.inmo.tgbotapi.bot.Ktor.KtorRequestsExecutorBuilder +import dev.inmo.tgbotapi.bot.Ktor.telegramBot import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl @@ -8,23 +8,13 @@ import io.ktor.client.HttpClient import io.ktor.client.HttpClientConfig import io.ktor.client.engine.* -/** - * Allows to create bot using bot [urlsKeeper] - */ -@Deprecated("Replaced in core", ReplaceWith("telegramBot", "dev.inmo.tgbotapi.bot.Ktor.telegramBot")) -fun telegramBot( - urlsKeeper: TelegramAPIUrlsKeeper -): TelegramBot = dev.inmo.tgbotapi.bot.Ktor.telegramBot( - urlsKeeper -) - /** * Allows to create bot using bot [urlsKeeper] and already prepared [client] */ fun telegramBot( urlsKeeper: TelegramAPIUrlsKeeper, client: HttpClient -): TelegramBot = dev.inmo.tgbotapi.bot.Ktor.telegramBot(urlsKeeper) { +): TelegramBot = telegramBot(urlsKeeper) { this.client = client } @@ -69,16 +59,6 @@ inline fun telegramBot( HttpClient(clientConfig) ) -/** - * Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client] - */ -@Deprecated("Replaced in core", ReplaceWith("telegramBot", "dev.inmo.tgbotapi.bot.Ktor.telegramBot")) -@Suppress("NOTHING_TO_INLINE") -inline fun telegramBot( - token: String, - apiUrl: String = telegramBotAPIDefaultUrl -): TelegramBot = dev.inmo.tgbotapi.bot.Ktor.telegramBot(token, apiUrl) - /** * Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client] */ @@ -130,37 +110,3 @@ inline fun telegramBot( TelegramAPIUrlsKeeper(token, apiUrl), clientConfig ) - -/** - * Allows to create bot using bot [urlsKeeper] and specify [HttpClientEngine] by passing [clientEngine] param and optionally - * configure [HttpClient] using [clientConfig] - */ -@Deprecated("Will be removed in next releases", ReplaceWith("telegramBot", "dev.inmo.tgbotapi.extensions.api.telegramBot")) -fun telegramBotWithCustomClientConfig( - urlsKeeper: TelegramAPIUrlsKeeper, - clientEngine: HttpClientEngine, - clientConfig: HttpClientConfig<*>.() -> Unit -): TelegramBot = telegramBot( - urlsKeeper, - HttpClient(clientEngine, clientConfig) -) - -/** - * Allows to create bot using bot [urlsKeeper] and optionally configure [HttpClient] using [clientConfig] - */ -@Deprecated("Will be removed in next releases", ReplaceWith("telegramBot", "dev.inmo.tgbotapi.extensions.api.telegramBot")) -fun telegramBotWithCustomClientConfig( - urlsKeeper: TelegramAPIUrlsKeeper, - clientConfig: HttpClientConfig<*>.() -> Unit -): TelegramBot = telegramBot( - urlsKeeper, - HttpClient(clientConfig) -) - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Renamed", ReplaceWith("telegramBot", "dev.inmo.tgbotapi.extensions.api.telegramBot")) -inline fun telegramBotWithCustomClientConfig( - token: String, - apiUrl: String = telegramBotAPIDefaultUrl, - noinline clientConfig: HttpClientConfig<*>.() -> Unit -) = telegramBot(token, apiUrl = apiUrl, clientConfig = clientConfig) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt index ada3cc7b95..41b26fafa9 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt @@ -5,7 +5,6 @@ import dev.inmo.tgbotapi.requests.chat.modify.UnpinChatMessage import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.Chat -import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat import dev.inmo.tgbotapi.types.message.abstracts.Message suspend fun TelegramBot.unpinChatMessage( diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt index 31cabb0734..1f444aa8c0 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt @@ -2,12 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.SendVenue -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.FoursquareId -import dev.inmo.tgbotapi.types.FoursquareType -import dev.inmo.tgbotapi.types.GooglePlaceId -import dev.inmo.tgbotapi.types.GooglePlaceType -import dev.inmo.tgbotapi.types.MessageIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.location.StaticLocation diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt index 8138d6db72..cd14764a51 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt @@ -1,10 +1,22 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder 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.CoroutineScope +/** + * Use this method in case you wish to make some additional actions with [flowUpdatesFilter]. + * + * **WARNING** This method WILL NOT launch any listening of updates. Use something like + * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks + * + * @see [BehaviourContext] + * @see startGettingOfUpdatesByLongPolling + */ +@PreviewFeature suspend fun TelegramBot.buildBehaviour( scope: CoroutineScope, flowUpdatesFilter: FlowsUpdatesFilter, @@ -17,17 +29,26 @@ suspend fun TelegramBot.buildBehaviour( ).block() } +/** + * Use this method to build bot behaviour and run it via long polling. In case you wish to get [FlowsUpdatesFilter] for + * additional manipulations, you must provide external [FlowsUpdatesFilter] in other [buildBehaviour] function. + * + * @see buildBehaviour + * @see BehaviourContext + * @see startGettingOfUpdatesByLongPolling + */ +@PreviewFeature suspend fun TelegramBot.buildBehaviour( scope: CoroutineScope, block: BehaviourContextReceiver -) = FlowsUpdatesFilter().also { +) = FlowsUpdatesFilter().let { buildBehaviour( scope, it, block ) - startGettingOfUpdatesByLongPolling( - updatesFilter = it, + longPolling( + it, scope = scope ) } diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index 093148c19c..5d3afb72a1 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -8,6 +8,13 @@ import kotlinx.coroutines.CoroutineScope typealias BehaviourContextReceiver = suspend BehaviourContext.() -> T typealias BehaviourContextAndTypeReceiver = suspend BehaviourContext.(I) -> T +/** + * This class contains all necessary tools for work with bots and especially for [buildBehaviour] + * + * @param scope This param will be used for creating of some subscriptions inside of methods, updates listening and + * different other things in context of working with [CoroutineScope] and coroutines. + * @param flowsUpdatesFilter This parameter will be used to subscribe on different types of update + */ data class BehaviourContext( val bot: TelegramBot, val scope: CoroutineScope, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt index d1cc0925c3..2e95e776fb 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.flow.* @@ -26,7 +27,7 @@ typealias NullableRequestBuilder = suspend (Update) -> Request? * as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory] * will be called too), [errorFactory] and then will be returned null */ -@RiskFeature("This method is not very comfortable to use and too low-level. It is recommended to use methods which already included into library") +@RiskFeature(lowLevelRiskFeatureMessage) suspend fun FlowsUpdatesFilter.expectFlow( bot: TelegramBot, initRequest: Request<*>? = null, @@ -92,7 +93,7 @@ suspend fun BehaviourContext.expectFlow( * as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory] * will be called too), [errorFactory] and then will be returned null */ -@RiskFeature("This method is not very comfortable to use and too low-level. It is recommended to use methods which already included into library") +@RiskFeature(lowLevelRiskFeatureMessage) suspend fun FlowsUpdatesFilter.expectOne( bot: TelegramBot, initRequest: Request<*>? = null, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index 6e55a5c484..26a55849df 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -7,7 +7,6 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import dev.inmo.tgbotapi.extensions.utils.* 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.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.* diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt index f3ac40ad09..f94531487a 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.utils.* +import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.abstracts.* diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt index 419aac3b6a..e273335bf8 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt @@ -10,9 +10,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat -import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.ContactContent import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.media.PhotoContent import dev.inmo.tgbotapi.types.message.content.media.VideoContent diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 86ce5a165c..a6956c3282 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -1,6 +1,8 @@ @file:Suppress("NOTHING_TO_INLINE", "unused", "UNCHECKED_CAST") package dev.inmo.tgbotapi.extensions.utils +import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource +import dev.inmo.tgbotapi.CommonAbstracts.TextSource import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.CallbackQuery.* import dev.inmo.tgbotapi.types.ChatMember.* @@ -20,6 +22,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery import dev.inmo.tgbotapi.types.InputMedia.* +import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.actions.* import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* @@ -30,58 +33,15 @@ import dev.inmo.tgbotapi.types.files.abstracts.* import dev.inmo.tgbotapi.types.message.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.message.abstracts.ChannelMessage -import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage -import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage -import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent -import dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage +import dev.inmo.tgbotapi.types.message.content.* +import dev.inmo.tgbotapi.types.message.content.abstracts.* +import dev.inmo.tgbotapi.types.message.content.media.* +import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.* import dev.inmo.tgbotapi.types.update.abstracts.* import dev.inmo.tgbotapi.utils.PreviewFeature -import dev.inmo.tgbotapi.types.message.content.abstracts.ResendableContent -import dev.inmo.tgbotapi.types.message.content.ContactContent -import dev.inmo.tgbotapi.types.message.content.DiceContent -import dev.inmo.tgbotapi.types.message.content.GameContent -import dev.inmo.tgbotapi.types.message.content.LocationContent -import dev.inmo.tgbotapi.types.message.content.PollContent -import dev.inmo.tgbotapi.types.message.content.TextContent -import dev.inmo.tgbotapi.types.message.content.VenueContent -import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent -import dev.inmo.tgbotapi.types.message.content.abstracts.DocumentMediaGroupContent -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaCollectionContent -import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent -import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent -import dev.inmo.tgbotapi.types.message.content.media.AnimationContent -import dev.inmo.tgbotapi.types.message.content.media.AudioContent -import dev.inmo.tgbotapi.types.message.content.media.DocumentContent -import dev.inmo.tgbotapi.types.message.content.media.PhotoContent -import dev.inmo.tgbotapi.types.message.content.media.StickerContent -import dev.inmo.tgbotapi.types.message.content.media.VideoContent -import dev.inmo.tgbotapi.types.message.content.media.VideoNoteContent -import dev.inmo.tgbotapi.types.message.content.media.VoiceContent -import dev.inmo.tgbotapi.types.message.payments.InvoiceContent -import dev.inmo.tgbotapi.CommonAbstracts.TextSource -import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.BoldTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.CashTagTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.CodeTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.EMailTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.HashTagTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.ItalicTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.MentionTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.PhoneNumberTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.PreTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.StrikethroughTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextLinkTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextMentionTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.URLTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.UnderlineTextSource @PreviewFeature inline fun Chat.asBot(): Bot? = this as? Bot diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt index bf4c4b8f74..6f6bee5cc5 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.extensions.utils +import dev.inmo.micro_utils.coroutines.safely import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.flow.* diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SafelyShortcut.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SafelyShortcut.kt deleted file mode 100644 index 9aa29a53d2..0000000000 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SafelyShortcut.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.extensions.utils - -import dev.inmo.micro_utils.coroutines.ExceptionHandler -import dev.inmo.tgbotapi.utils.* -import kotlinx.coroutines.CoroutineScope - -/** - * Shortcut for [dev.inmo.micro_utils.coroutines.safely]. It was created for more comfortable way of handling different things - */ -@Deprecated("In future will be used typealias from micro_utils", ReplaceWith("safely", "dev.inmo.micro_utils.coroutines.safely")) -suspend inline fun safely( - noinline onException: ExceptionHandler = { throw it }, - noinline block: suspend CoroutineScope.() -> T -): T = dev.inmo.micro_utils.coroutines.safely( - onException, - block -) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt deleted file mode 100644 index 43504fef31..0000000000 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt +++ /dev/null @@ -1,24 +0,0 @@ -package dev.inmo.tgbotapi.extensions.utils.chat_events - -import dev.inmo.tgbotapi.extensions.utils.shortcuts.* -import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.mapNotNull -import kotlin.reflect.KClass - -@Deprecated("Refactored, replaced and renamed", ReplaceWith("filterByChatEvent", "dev.inmo.tgbotapi.extensions.utils.shortcuts.filterByChatEvent")) -fun > Flow>.divideBySource(contentType: KClass) = mapNotNull { - if (contentType.isInstance(it)) { - @Suppress("UNCHECKED_CAST") - it as T - } else { - null - } -} - -@Deprecated("Replaced and renamed", ReplaceWith("channelEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.channelEvents")) -fun Flow>.onlyChannelEvents() = channelEvents() -@Deprecated("Replaced and renamed", ReplaceWith("groupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.groupEvents")) -fun Flow>.onlyGroupEvents() = groupEvents() -@Deprecated("Replaced and renamed", ReplaceWith("supergroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.supergroupEvents")) -fun Flow>.onlySupergroupEvents() = supergroupEvents() diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt index d18f6986c6..8d7e2687d6 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.extensions.utils.formatting import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.link -import dev.inmo.tgbotapi.types.ParseMode.* import dev.inmo.tgbotapi.types.chat.abstracts.* import dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPublicChat import dev.inmo.tgbotapi.types.message.abstracts.Message @@ -84,38 +83,3 @@ private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addsticke val StickerSetName.stickerSetLink get() = link(this, "$stickerSetAddingLinkPrefix/$this") - -/** - * @return Link for adding of sticker set with name [stickerSetName] with formatting for [MarkdownV2] - */ -@Deprecated("Use extension `stickerSetLink` + getting of `asMarkdownV2Source` property") -fun makeLinkToAddStickerSetInMarkdownV2( - stickerSetName: StickerSetName -) = stickerSetName.stickerSetLink.markdownV2 -/** - * @return Link for adding of sticker set with name [stickerSetName] with formatting for [Markdown] - */ -@Deprecated("Use extension `stickerSetLink` + getting of `asMarkdownSource` property") -fun makeLinkToAddStickerSetInMarkdown(stickerSetName: StickerSetName) = stickerSetName.stickerSetLink.markdown -/** - * @return Link for adding of sticker set with name [stickerSetName] with formatting for [HTML] - */ -@Deprecated("Use extension `stickerSetLink` + getting of `asHtmlSource` property") -fun makeLinkToAddStickerSetInHtml(stickerSetName: StickerSetName) = stickerSetName.stickerSetLink.html -/** - * Create a link for adding of sticker set with name [stickerSetName]. Was added thanks to user Djaler and based on - * https://github.com/Djaler/evil-bot/blob/master/src/main/kotlin/com/github/djaler/evilbot/utils/StickerUtils.kt#L6-L8 - * - * @see [makeLinkToAddStickerSetInMarkdownV2] - * @see [makeLinkToAddStickerSetInMarkdown] - * @see [makeLinkToAddStickerSetInHtml] - */ -@Deprecated("Use extension `stickerSetLink` + getting of required property") -fun makeLinkToAddStickerSet( - stickerSetName: StickerSetName, - parseMode: ParseMode -) = when (parseMode) { - MarkdownParseMode -> makeLinkToAddStickerSetInMarkdown(stickerSetName) - MarkdownV2ParseMode -> makeLinkToAddStickerSetInMarkdownV2(stickerSetName) - HTMLParseMode -> makeLinkToAddStickerSetInHtml(stickerSetName) -} diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt index ab62b4f1aa..9d28d5215e 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt @@ -4,7 +4,6 @@ import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.ParseMode.* import dev.inmo.tgbotapi.types.message.content.TextContent -import dev.inmo.tgbotapi.types.message.content.fullEntitiesList fun createFormattedText( entities: TextSourcesList, @@ -56,19 +55,19 @@ fun TextSourcesList.toMarkdownCaptions(): List = createMarkdownText( this, captionLength.last ) -fun CaptionedInput.toMarkdownCaptions(): List = fullEntitiesList().toMarkdownCaptions() +fun CaptionedInput.toMarkdownCaptions(): List = textSources.toMarkdownCaptions() fun TextSourcesList.toMarkdownTexts(): List = createMarkdownText( this, textLength.last ) -fun TextContent.toMarkdownTexts(): List = fullEntitiesList().toMarkdownTexts() +fun TextContent.toMarkdownTexts(): List = textSources.toMarkdownTexts() fun TextSourcesList.toMarkdownExplanations(): List = createMarkdownText( this, explanationLimit.last ) -fun ExplainedInput.toMarkdownExplanations(): List = fullEntitiesList().toMarkdownTexts() +fun ExplainedInput.toMarkdownExplanations(): List = textSources.toMarkdownTexts() fun createMarkdownV2Text( @@ -80,19 +79,19 @@ fun TextSourcesList.toMarkdownV2Captions(): List = createMarkdownV2Text( this, captionLength.last ) -fun CaptionedInput.toMarkdownV2Captions(): List = fullEntitiesList().toMarkdownV2Captions() +fun CaptionedInput.toMarkdownV2Captions(): List = textSources.toMarkdownV2Captions() fun TextSourcesList.toMarkdownV2Texts(): List = createMarkdownV2Text( this, textLength.last ) -fun TextContent.toMarkdownV2Texts(): List = fullEntitiesList().toMarkdownV2Texts() +fun TextContent.toMarkdownV2Texts(): List = textSources.toMarkdownV2Texts() fun TextSourcesList.toMarkdownV2Explanations(): List = createMarkdownV2Text( this, explanationLimit.last ) -fun ExplainedInput.toMarkdownV2Explanations(): List = fullEntitiesList().toMarkdownV2Texts() +fun ExplainedInput.toMarkdownV2Explanations(): List = textSources.toMarkdownV2Texts() fun createHtmlText( @@ -104,18 +103,18 @@ fun TextSourcesList.toHtmlCaptions(): List = createHtmlText( this, captionLength.last ) -fun CaptionedInput.toHtmlCaptions(): List = fullEntitiesList().toHtmlCaptions() +fun CaptionedInput.toHtmlCaptions(): List = textSources.toHtmlCaptions() fun TextSourcesList.toHtmlTexts(): List = createHtmlText( this, textLength.last ) -fun TextContent.toHtmlTexts(): List = fullEntitiesList().toHtmlTexts() +fun TextContent.toHtmlTexts(): List = textSources.toHtmlTexts() fun TextSourcesList.toHtmlExplanations(): List = createHtmlText( this, explanationLimit.last ) -fun ExplainedInput.toHtmlExplanations(): List = fullEntitiesList().toHtmlTexts() +fun ExplainedInput.toHtmlExplanations(): List = textSources.toHtmlTexts() diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt index f23f1aae33..6df7887dea 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt @@ -8,7 +8,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.TextContent -import dev.inmo.tgbotapi.types.message.content.fullEntitiesList import kotlinx.coroutines.flow.* /** diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt index c9f0831301..54df4bdd03 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -9,7 +9,8 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.mapNotNull @RiskFeature("Use with caution") inline fun FlowsUpdatesFilter.events(): Flow> { diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt index 3c5fe89a8a..05b2fc0233 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt @@ -12,9 +12,12 @@ import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.* +@RiskFeature(lowLevelRiskFeatureMessage) inline fun filterForContentMessage(): suspend (ContentMessage<*>) -> ContentMessage? = { if (it.content is T) { @Suppress("UNCHECKED_CAST") @@ -25,9 +28,11 @@ inline fun filterForContentMessage(): suspend (Cont } @Suppress("UNCHECKED_CAST") +@RiskFeature(lowLevelRiskFeatureMessage) inline fun Flow.filterContentMessages( ): Flow> = asContentMessagesFlow().mapNotNull(filterForContentMessage()) +@RiskFeature("This method is low-level") inline fun Flow.filterMediaGroupMessages( ): Flow>> = map { it.data.mapNotNull { message -> @@ -46,6 +51,7 @@ inline fun Flow.filterMedi * [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping */ @Suppress("UNCHECKED_CAST") +@RiskFeature(lowLevelRiskFeatureMessage) inline fun FlowsUpdatesFilter.filterContentMessages( scopeToIncludeChannels: CoroutineScope? = null ): Flow> { @@ -64,6 +70,7 @@ inline fun FlowsUpdatesFilter.filterContentMessages( * [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping */ @Suppress("UNCHECKED_CAST") +@RiskFeature(lowLevelRiskFeatureMessage) inline fun FlowsUpdatesFilter.filterMediaGroupMessages( scopeToIncludeChannels: CoroutineScope? = null ): Flow>> { diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt index 6d553cf32e..192b612055 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt @@ -7,7 +7,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.TextContent -import dev.inmo.tgbotapi.types.message.content.fullEntitiesList import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import kotlinx.coroutines.flow.Flow diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt index 4ee4c8fc40..533488ed3e 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt @@ -1,3 +1,5 @@ +@file:Suppress("unused") + package dev.inmo.tgbotapi.extensions.utils.updates import dev.inmo.tgbotapi.types.message.abstracts.* @@ -23,11 +25,6 @@ fun Flow.asCommonMessagesFlow() = mapNotNull { inline fun Flow.chatEvents() = mapNotNull { it.data as? ChatEventMessage<*> } -/** - * Will map incoming [BaseSentMessageUpdate]s to [ChatEventMessage] from [BaseSentMessageUpdate.data] - */ -@Deprecated("Renamed", ReplaceWith("chatEvents", "dev.inmo.tgbotapi.extensions.utils.updates.chatEvents")) -fun Flow.asChatEventsFlow() = chatEvents() /** * Will map incoming [BaseSentMessageUpdate]s to [UnknownMessageType] from [BaseSentMessageUpdate.data] diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt index b22778975d..7519638811 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.utils.updates.retrieving import dev.inmo.micro_utils.coroutines.ExceptionHandler import dev.inmo.micro_utils.coroutines.safely import dev.inmo.tgbotapi.bot.RequestsExecutor +import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.exceptions.RequestException import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates import dev.inmo.tgbotapi.extensions.utils.updates.lastUpdateIdentifier @@ -15,7 +16,7 @@ import dev.inmo.tgbotapi.updateshandlers.* import dev.inmo.tgbotapi.utils.* import kotlinx.coroutines.* -fun RequestsExecutor.startGettingOfUpdatesByLongPolling( +fun TelegramBot.startGettingOfUpdatesByLongPolling( timeoutSeconds: Seconds = 30, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: (ExceptionHandler)? = null, @@ -65,6 +66,33 @@ fun RequestsExecutor.startGettingOfUpdatesByLongPolling( } } +/** + * Will [startGettingOfUpdatesByLongPolling] using incoming [flowsUpdatesFilter]. It is assumed that you ALREADY CONFIGURE + * all updates receivers, because this method will trigger getting of updates and. + */ +fun TelegramBot.longPolling( + flowsUpdatesFilter: FlowsUpdatesFilter, + timeoutSeconds: Seconds = 30, + scope: CoroutineScope = CoroutineScope(Dispatchers.Default), + exceptionsHandler: ExceptionHandler? = null +): Job = flowsUpdatesFilter.run { + startGettingOfUpdatesByLongPolling(timeoutSeconds, scope, exceptionsHandler, allowedUpdates, asUpdateReceiver) +} + +/** + * Will enable [longPolling] by creating [FlowsUpdatesFilter] with [flowsUpdatesFilterUpdatesKeeperCount] as an argument + * and applied [flowUpdatesPreset]. It is assumed that you WILL CONFIGURE all updates receivers in [flowUpdatesPreset], + * because of after [flowUpdatesPreset] method calling will be triggered getting of updates. + */ +@Suppress("unused") +fun TelegramBot.longPolling( + timeoutSeconds: Seconds = 30, + scope: CoroutineScope = CoroutineScope(Dispatchers.Default), + exceptionsHandler: ExceptionHandler? = null, + flowsUpdatesFilterUpdatesKeeperCount: Int = 100, + flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit +): Job = longPolling(FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply(flowUpdatesPreset), timeoutSeconds, scope, exceptionsHandler) + /** * This method will create a new one [FlowsUpdatesFilter]. This method could be unsafe due to the fact that it will start * getting updates IMMEDIATELY. That means that your bot will be able to skip some of them until you will call @@ -72,6 +100,7 @@ fun RequestsExecutor.startGettingOfUpdatesByLongPolling( * [flowUpdatesPreset] lambda - it will be called BEFORE starting updates getting */ @FlowPreview +@Deprecated("Will be removed soon", ReplaceWith("longPolling", "dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling")) @Suppress("unused") fun RequestsExecutor.startGettingFlowsUpdatesByLongPolling( timeoutSeconds: Seconds = 30, @@ -97,6 +126,7 @@ fun RequestsExecutor.startGettingOfUpdatesByLongPolling( updatesFilter.asUpdateReceiver ) +@Deprecated("Will be removed soon", ReplaceWith("longPolling", "dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling")) fun RequestsExecutor.startGettingOfUpdatesByLongPolling( messageCallback: UpdateReceiver? = null, messageMediaGroupCallback: UpdateReceiver? = null, @@ -141,6 +171,7 @@ fun RequestsExecutor.startGettingOfUpdatesByLongPolling( ) } +@Deprecated("Will be removed soon", ReplaceWith("longPolling", "dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling")) @Suppress("unused") fun RequestsExecutor.startGettingOfUpdatesByLongPolling( messageCallback: UpdateReceiver? = null,