From be027efc43bba8581dfdaff7fcae8559814b79e4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 21 May 2022 17:27:04 +0600 Subject: [PATCH 1/9] start 1.1.4 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc972d9f1..ae526cf718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 1.1.4 + ## 1.1.3 * `Behaviour Builder with FSM`: diff --git a/gradle.properties b/gradle.properties index 0331f00f0f..23f23ab167 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,6 +20,6 @@ javax_activation_version=1.1.1 dokka_version=1.6.21 library_group=dev.inmo -library_version=1.1.3 +library_version=1.1.4 github_release_plugin_version=2.3.7 From 562e8c7429d49c8bbdf25bbff1280cd21ad6f9be Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 21 May 2022 17:33:44 +0600 Subject: [PATCH 2/9] improvements in Beheviour Context --- CHANGELOG.md | 3 +++ .../extensions/behaviour_builder/BehaviourContext.kt | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae526cf718..f6f06b926e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 1.1.4 +* `Behaviour Builder`: + * Improvements in updates passing inside of subcontexts + ## 1.1.3 * `Behaviour Builder with FSM`: diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index b1c6d837b2..4621e6e242 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -73,7 +73,10 @@ class DefaultBehaviourContext( private val additionalUpdatesSharedFlow = MutableSharedFlow(0, broadcastChannelsSize, onBufferOverflow) override val allUpdatesFlow: Flow = (additionalUpdatesSharedFlow.asSharedFlow()).let { if (upstreamUpdatesFlow != null) { - (it + upstreamUpdatesFlow).distinctUntilChanged { old, new -> old.updateId == new.updateId } + var lastHandledUpdate = -1L + (it + upstreamUpdatesFlow).filter { + (it.updateId > lastHandledUpdate).also { passed -> if (passed) { lastHandledUpdate = it.updateId } } + } } else { it } From 27a24a18a689792f0f9b0f5d5df7b178ba1fb8f0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 21 May 2022 21:44:27 +0600 Subject: [PATCH 3/9] fix of updates funnel in subsequent behaviour contexts --- .../behaviour_builder/BehaviourContext.kt | 79 +++++++++++++------ .../expectations/WaitCallbackQuery.kt | 4 +- .../triggers_handling/MainTrigger.kt | 11 +-- 3 files changed, 65 insertions(+), 29 deletions(-) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index 4621e6e242..a1c5173def 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -49,6 +49,19 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope { val triggersHolder: TriggersHolder + fun copy( + bot: TelegramBot = this.bot, + scope: CoroutineScope = this.scope, + broadcastChannelsSize: Int = 100, + onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, + upstreamUpdatesFlow: Flow? = null, + triggersHolder: TriggersHolder = TriggersHolder() + ): BehaviourContext + + /** + * @param updatesFilter unused + */ + @Deprecated("Do not use this method") fun copy( bot: TelegramBot = this.bot, scope: CoroutineScope = this.scope, @@ -57,7 +70,7 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope { upstreamUpdatesFlow: Flow? = null, triggersHolder: TriggersHolder = TriggersHolder(), updatesFilter: BehaviourContextAndTypeReceiver? = null - ): BehaviourContext + ): BehaviourContext = copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder) } class DefaultBehaviourContext( @@ -67,6 +80,7 @@ class DefaultBehaviourContext( onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, private val upstreamUpdatesFlow: Flow? = null, override val triggersHolder: TriggersHolder = TriggersHolder(), + @Deprecated("This method is not used anymore") private val updatesFilter: BehaviourContextAndTypeReceiver? = null ) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext { @@ -80,13 +94,6 @@ class DefaultBehaviourContext( } else { it } - }.let { - val updatesFilter = updatesFilter - if (updatesFilter != null) { - it.filter { updatesFilter(it) } - } else { - it - } }.accumulatorFlow(scope) override val asUpdateReceiver: UpdateReceiver = additionalUpdatesSharedFlow::emit @@ -96,9 +103,8 @@ class DefaultBehaviourContext( broadcastChannelsSize: Int, onBufferOverflow: BufferOverflow, upstreamUpdatesFlow: Flow?, - triggersHolder: TriggersHolder, - updatesFilter: BehaviourContextAndTypeReceiver? - ): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder, updatesFilter) + triggersHolder: TriggersHolder + ): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder) } fun BehaviourContext( @@ -116,24 +122,34 @@ inline fun BehaviourContext( crossinline block: BehaviourContext.() -> T ) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow, triggersHolder = triggersHolder).run(block) +/** + * Creates new [BehaviourContext] using its [BehaviourContext.copy] method + * + * @param updatesFilter This param will not be used anymore + */ fun BC.createSubContext( scope: CoroutineScope = LinkedSupervisorScope(), triggersHolder: TriggersHolder = this.triggersHolder, updatesUpstreamFlow: Flow = allUpdatesFlow, - updatesFilter: CustomBehaviourContextAndTypeReceiver? = null, ) = copy( scope = scope, - updatesFilter = updatesFilter ?.let { _ -> - { - (this as? BC) ?.run { - updatesFilter(it) - } ?: true - } - }, upstreamUpdatesFlow = updatesUpstreamFlow, triggersHolder = triggersHolder ) as BC +/** + * Creates new [BehaviourContext] using its [BehaviourContext.copy] method + * + * @param updatesFilter This param will not be used anymore + */ +@Deprecated("It is not recommended to use updates filter anymore") +fun BC.createSubContext( + scope: CoroutineScope = LinkedSupervisorScope(), + triggersHolder: TriggersHolder = this.triggersHolder, + updatesUpstreamFlow: Flow = allUpdatesFlow, + updatesFilter: CustomBehaviourContextAndTypeReceiver?, +) = createSubContext(scope, triggersHolder, updatesUpstreamFlow) + /** * Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext] * @@ -158,21 +174,40 @@ suspend fun BC.createSubContextAndDoWithUpdatesFilter scope: CoroutineScope = LinkedSupervisorScope(), triggersHolder: TriggersHolder = this.triggersHolder, updatesUpstreamFlow: Flow = allUpdatesFlow, - updatesFilter: CustomBehaviourContextAndTypeReceiver? = null, stopOnCompletion: Boolean = true, behaviourContextReceiver: CustomBehaviourContextReceiver ): T { return createSubContext( scope, triggersHolder, - updatesUpstreamFlow, - updatesFilter + updatesUpstreamFlow ).doInContext( stopOnCompletion, behaviourContextReceiver ) } +/** + * Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context + * using [doInContext] + * + * @param stopOnCompletion ___TRUE BY DEFAULT___ + * @param updatesFilter Is not used anymore + */ +@Deprecated("It is not recommended to use updates filter anymore") +suspend fun BC.createSubContextAndDoWithUpdatesFilter( + scope: CoroutineScope = LinkedSupervisorScope(), + triggersHolder: TriggersHolder = this.triggersHolder, + updatesUpstreamFlow: Flow = allUpdatesFlow, + updatesFilter: CustomBehaviourContextAndTypeReceiver?, + stopOnCompletion: Boolean = true, + behaviourContextReceiver: CustomBehaviourContextReceiver +): T { + return createSubContextAndDoWithUpdatesFilter( + scope, triggersHolder, updatesUpstreamFlow, stopOnCompletion, behaviourContextReceiver + ) +} + /** * Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context * using [doInContext] diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt index 2c51e9ef2f..eaa15da352 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt @@ -22,8 +22,8 @@ private suspend fun BehaviourContext.waitCallbackQueries( count, errorFactory ) { - val data = it.asCallbackQueryUpdate() ?.data - if (data != null && (filter == null || filter(data))) { + val data = it.asCallbackQueryUpdate() ?.data ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { data.mapper().let(::listOfNotNull) } else { emptyList() diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt index 766972a57b..108465b116 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt @@ -15,16 +15,17 @@ internal suspend inline fun BC.on( noinline updateToData: (Update) -> List? ) = flowsUpdatesFilter.expectFlow(bot) { updateToData(it) ?.mapNotNull { data -> - if (initialFilter ?.invoke(data) != false) data else null + if (initialFilter ?.invoke(data) != false) it to data else null } ?: emptyList() }.subscribeSafelyWithoutExceptionsAsync( scope, - markerFactory::invoke -) { triggerData -> + { markerFactory(it.second) } +) { (update, triggerData) -> createSubContextAndDoWithUpdatesFilter( - updatesFilter = subcontextUpdatesFilter ?.toOneType(triggerData), stopOnCompletion = false ) { - scenarioReceiver(triggerData) + if (subcontextUpdatesFilter ?.invoke(this, triggerData, update) != false) { + scenarioReceiver(triggerData) + } } } From 126a07cdc7107c77cb421bde22dc8c5dc2c460ae Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 21 May 2022 23:32:36 +0600 Subject: [PATCH 4/9] start 1.2.0 --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6f06b926e..20aa61ce9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # TelegramBotAPI changelog -## 1.1.4 +## 1.2.0 * `Behaviour Builder`: * Improvements in updates passing inside of subcontexts diff --git a/gradle.properties b/gradle.properties index 23f23ab167..b1f684c783 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,6 +20,6 @@ javax_activation_version=1.1.1 dokka_version=1.6.21 library_group=dev.inmo -library_version=1.1.4 +library_version=1.2.0 github_release_plugin_version=2.3.7 From 507cb2af2699c9ee99c166a2c9196d8284b09a52 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 21 May 2022 23:38:42 +0600 Subject: [PATCH 5/9] cleanup waiters in behaviour builder and add withEvent --- CHANGELOG.md | 5 +- .../expectations/WaitCallbackQuery.kt | 84 +++----- .../expectations/WaitChatJoinRequest.kt | 26 +-- .../expectations/WaitChatMemberUpdated.kt | 41 +--- .../expectations/WaitChosenInlineResult.kt | 56 ++--- .../expectations/WaitContent.kt | 174 +++++----------- .../expectations/WaitContentMessage.kt | 157 +++++--------- .../expectations/WaitEditedContent.kt | 153 +++++--------- .../expectations/WaitEventAction.kt | 191 ++++++------------ .../expectations/WaitInlineQuery.kt | 56 ++--- .../expectations/WaitMediaGroup.kt | 22 +- .../expectations/WaitPassportData.kt | 39 +--- .../expectations/WaitPollAnswers.kt | 42 +--- .../expectations/WaitPollUpdates.kt | 56 ++--- .../expectations/WaitPreCheckoutQuery.kt | 24 +-- .../expectations/WaitShippingQuery.kt | 24 +-- .../EditedContentTriggers.kt | 1 - .../tgbotapi/extensions/utils/WithEvent.kt | 31 +++ 18 files changed, 385 insertions(+), 797 deletions(-) create mode 100644 tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithEvent.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 20aa61ce9b..cf50b52fb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,10 @@ ## 1.2.0 * `Behaviour Builder`: - * Improvements in updates passing inside of subcontexts + * Mappers have been removed from waiters extensions + * Triggers extensions now will use filtering inside of context receiver instead of passing the filters into `BehaviourContext`. That means that in the subcontext will not be used preinstalled filters for their `BehaviourContext` and filter of trigger will not be used in subcontext +* `Utils`: + * Add opportunity to get event messages with specific `ChatEvent` type using `withEvent`/`requireWithEvent` (by analog with `withEvent` and `requireWithEvent`) ## 1.1.3 diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt index eaa15da352..10f0b3888b 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt @@ -11,114 +11,76 @@ import kotlinx.coroutines.flow.toList typealias CallbackQueryMapper = suspend T.() -> T? -private suspend fun BehaviourContext.waitCallbackQueries( +private suspend inline fun BehaviourContext.waitCallbackQueries( count: Int = 1, initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - mapper: suspend CallbackQuery.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, errorFactory ) { val data = it.asCallbackQueryUpdate() ?.data ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - data.mapper().let(::listOfNotNull) + if (data is O && (filter == null || filter(data))) { + listOf(data) } else { emptyList() } }.toList().toList() -private suspend inline fun BehaviourContext.waitCallbacks( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - noinline mapper: CallbackQueryMapper? = null -) : List = waitCallbackQueries( - count, - initRequest, - errorFactory, - filter ?.let { - { - (it as? T) ?.let { filter(it) } == true - } - } -) { - if (this is T) { - if (mapper == null) { - this - } else { - mapper(this) - } - } else { - null - } -} - - suspend fun BehaviourContext.waitDataCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitGameShortNameCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitInlineMessageIdCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitInlineMessageIdDataCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitInlineMessageIdGameShortNameCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitMessageCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitMessageDataCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitMessageGameShortNameCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitUnknownCallbackQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: CallbackQueryMapper? = null -) = waitCallbacks(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitCallbackQueries(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt index 9481c118c5..2c81debe2c 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt @@ -9,20 +9,19 @@ import kotlinx.coroutines.flow.toList typealias ChatJoinRequestsMapper = suspend ChatJoinRequest.() -> ChatJoinRequest? -private suspend fun BehaviourContext.waitChatJoinRequests( +private suspend inline fun BehaviourContext.internalWaitChatJoinRequests( count: Int = 1, initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - mapper: suspend ChatJoinRequest.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, errorFactory ) { - val data = it.asChatJoinRequestUpdate() ?.data - if (data != null && (filter == null || filter(data))) { - data.mapper().let(::listOfNotNull) + val data = it.asChatJoinRequestUpdate() ?.data as? O ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { + listOf(data) } else { emptyList() } @@ -33,17 +32,10 @@ suspend fun BehaviourContext.waitChatJoinRequests( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: ChatJoinRequestsMapper? = null -) : List = waitChatJoinRequests( + filter: SimpleFilter? = null +) : List = internalWaitChatJoinRequests( count, initRequest, errorFactory, filter -) { - if (mapper == null) { - this - } else { - mapper(this) - } -} +) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt index fe6ef75b2f..67ab6a2615 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt @@ -11,12 +11,11 @@ import kotlinx.coroutines.flow.toList typealias ChatMemberUpdatedMapper = suspend T.() -> T? -private suspend inline fun BehaviourContext.waitChatMemberUpdated( +private suspend inline fun BehaviourContext.waitChatMemberUpdatedWithFilter( count: Int = 1, initRequest: Request<*>? = null, noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - noinline mapper: ChatMemberUpdatedMapper + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, @@ -24,51 +23,29 @@ private suspend inline fun BehaviourContex ) { val casted = (it as? T) ?: return@expectFlow emptyList() if (filter == null || filter(casted)) { - casted.data.mapper().let(::listOfNotNull) + listOf(casted.data) } else { emptyList() } }.toList().toList() -private suspend inline fun BehaviourContext.waitChatMemberUpdatedWithFilter( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - noinline mapper: ChatMemberUpdatedMapper? = null -) : List = waitChatMemberUpdated( - count, - initRequest, - errorFactory, - filter, -) { - if (mapper == null) { - this - } else { - mapper(this) - } -} - suspend fun BehaviourContext.waitChatMemberUpdated( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: ChatMemberUpdatedMapper? = null -) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitCommonChatMemberUpdated( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: ChatMemberUpdatedMapper? = null -) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitMyChatMemberUpdated( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: ChatMemberUpdatedMapper? = null -) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt index a21fe35eb8..ea08427204 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt @@ -9,73 +9,41 @@ import kotlinx.coroutines.flow.toList typealias ChosenInlineResultMapper = suspend T.() -> T? -private suspend fun BehaviourContext.waitChosenInlineResultsUpdates( +private suspend inline fun BehaviourContext.waitChosenInlineResults( count: Int = 1, initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - mapper: suspend ChosenInlineResult.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, errorFactory ) { - val data = it.asChosenInlineResultUpdate() ?.data - if (data != null && (filter == null || filter(data))) { - data.mapper().let(::listOfNotNull) + val data = it.asChosenInlineResultUpdate() ?.data as? O ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { + listOf(data) } else { emptyList() } }.toList().toList() - -private suspend inline fun BehaviourContext.waitChosenInlineResults( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - noinline mapper: ChosenInlineResultMapper? = null -) : List = this@waitChosenInlineResults.waitChosenInlineResultsUpdates( - count, - initRequest, - errorFactory, - filter ?.let { - { - (it as? T) ?.let { filter(it) } == true - } - } -) { - if (this is T) { - if (mapper == null) { - this - } else { - mapper(this) - } - } else { - null - } -} - suspend fun BehaviourContext.waitChosenInlineResult( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: ChosenInlineResultMapper? = null -) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitChosenInlineResults(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitLocationChosenInlineResult( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: PollMapper? = null -) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitChosenInlineResults(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitBaseChosenInlineResult( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: PollMapper? = null -) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitChosenInlineResults(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index 61038ec5b7..8698cdecbf 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations -import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.withContent @@ -17,17 +16,15 @@ import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.toList typealias CommonMessageToContentMapper = suspend CommonMessage.() -> T? -private suspend fun BehaviourContext.waitCommonContent( +private suspend inline fun BehaviourContext.waitContent( count: Int = 1, initRequest: Request<*>? = null, includeMediaGroups: Boolean = true, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null, - mapper: suspend CommonMessage.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter>? = null ): Flow = expectFlow( initRequest, count, @@ -36,7 +33,7 @@ private suspend fun BehaviourContext.waitCommonContent( val messages = when (it) { is SentMediaGroupUpdate -> { if (includeMediaGroups) { - it.data.map { it as CommonMessage } + it.data } else { emptyList() } @@ -45,233 +42,174 @@ private suspend fun BehaviourContext.waitCommonContent( else -> return@expectFlow emptyList() } messages.mapNotNull { message -> - val asCommonMessage = message as CommonMessage + val asCommonMessage = (message as CommonMessage<*>).withContent() ?: return@mapNotNull null if (filter == null || filter(asCommonMessage)) { - asCommonMessage.mapper() + asCommonMessage.content } else { null } } } -internal inline fun contentConverter( - noinline mapper: CommonMessageToContentMapper? = null -): suspend CommonMessage.() -> T? = mapper ?.let { - { - if (content is T) { - @Suppress("UNCHECKED_CAST") - val message = (this as CommonMessage) - safelyWithoutExceptions { mapper(message) } - } else { - null - } - } -} ?: { content as? T } - -private suspend inline fun BehaviourContext.waitContent( - count: Int = 1, - initRequest: Request<*>? = null, - includeMediaGroups: Boolean = true, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null, - noinline mapper: CommonMessageToContentMapper? = null -) : List = waitCommonContent( - count, - initRequest, - includeMediaGroups, - errorFactory, - filter ?.let { - { - it.withContent() ?.let { filter(it) } == true - } - }, - contentConverter(mapper) -).toList() - suspend fun BehaviourContext.waitContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitContact( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitDice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitGame( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitLiveLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitStaticLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitPoll( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitText( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitVenue( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitAnimation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitAudio( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitDocument( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitPhoto( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitSticker( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitVideo( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitVideoNote( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitVoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitInvoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContent(count, initRequest, false, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt index 0c51884379..e4e18a9eb6 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt @@ -17,17 +17,15 @@ import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.toList typealias CommonMessageToCommonMessageMapper = suspend CommonMessage.() -> CommonMessage? -internal suspend fun BehaviourContext.waitCommonMessage( +internal suspend inline fun BehaviourContext.waitContentMessage( count: Int = 1, initRequest: Request<*>? = null, includeMediaGroups: Boolean = true, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null, - mapper: suspend CommonMessage.() -> CommonMessage? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter>? = null ): Flow> = expectFlow( initRequest, count, @@ -46,9 +44,9 @@ internal suspend fun BehaviourContext.waitCommonMessage( } messages.mapNotNull { message -> @Suppress("UNCHECKED_CAST") - val asCommonMessage = message as? CommonMessage ?: return@mapNotNull null + val asCommonMessage = (message as? CommonMessage<*>) ?.withContent() ?: return@mapNotNull null if (filter == null || filter(asCommonMessage)) { - asCommonMessage.mapper() + asCommonMessage } else { null } @@ -72,209 +70,164 @@ internal inline fun contentMessageConverter( if (content is T) this as CommonMessage else null } -private suspend inline fun BehaviourContext.waitContentMessage( - count: Int = 1, - initRequest: Request<*>? = null, - includeMediaGroups: Boolean = true, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null, - noinline mapper: CommonMessageToCommonMessageMapper? = null -) : List> = waitCommonMessage( - count, - initRequest, - includeMediaGroups, - errorFactory, - filter ?.let { - { - it.withContent() ?.let { filter(it) } == true - } - }, - contentMessageConverter(mapper) -).toList() - suspend fun BehaviourContext.waitContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitContactMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitDiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitGameMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitLiveLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitStaticLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitPollMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitTextMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitVenueMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitMediaMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitTextedMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitAnimationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitAudioMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitDocumentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitPhotoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitStickerMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitVideoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitVideoNoteMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitVoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitInvoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToCommonMessageMapper? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitContentMessage(count, initRequest, false, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index f3ae19daaf..ca7bebab37 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -18,13 +18,12 @@ import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate import kotlinx.coroutines.flow.toList -private suspend fun BehaviourContext.waitEditedCommonMessage( +private suspend inline fun BehaviourContext.waitEditedContent( count: Int = 1, initRequest: Request<*>? = null, includeMediaGroups: Boolean = true, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null, - mapper: suspend CommonMessage.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter>? = null ): List = expectFlow( initRequest, count, @@ -32,7 +31,7 @@ private suspend fun BehaviourContext.waitEditedCommonMessage( ) { val messages = when (it) { is BaseEditMessageUpdate -> { - val commonMessage = it.data.asCommonMessage() + val commonMessage = it.data.asCommonMessage() ?: return@expectFlow emptyList() if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) { listOf(commonMessage) } else { @@ -42,211 +41,167 @@ private suspend fun BehaviourContext.waitEditedCommonMessage( else -> return@expectFlow emptyList() } messages.mapNotNull { message -> - val asCommonMessage = message as CommonMessage + val asCommonMessage = (message as CommonMessage<*>).withContent() ?: return@mapNotNull null if (filter == null || filter(asCommonMessage)) { - asCommonMessage.mapper() + asCommonMessage.content } else { null } } }.toList().toList() -private suspend inline fun BehaviourContext.waitEditedContent( - count: Int = 1, - initRequest: Request<*>? = null, - includeMediaGroups: Boolean = true, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null, - noinline mapper: CommonMessageToContentMapper? = null -) : List = waitEditedCommonMessage( - count, - initRequest, - includeMediaGroups, - errorFactory, - filter ?.let { - { - it.withContent() ?.let { filter(it) } == true - } - }, - contentConverter(mapper) -) - suspend fun BehaviourContext.waitEditedContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedContact( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedDice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedGame( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedLiveLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedStaticLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedText( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedVenue( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedAnimation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedAudio( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedDocument( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedPhoto( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedSticker( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedVideo( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) suspend fun BehaviourContext.waitEditedVideoNote( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedVoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) suspend fun BehaviourContext.waitEditedInvoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: CommonMessageToContentMapper? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEditedContent(count, initRequest, false, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 717b4b876e..dea7200e22 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -4,8 +4,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter -import dev.inmo.tgbotapi.extensions.utils.asBaseSentMessageUpdate -import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage +import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -17,268 +16,208 @@ import kotlinx.coroutines.flow.toList typealias EventMessageToEventMapper = suspend ChatEventMessage.() -> T? -private suspend fun BehaviourContext.waitEventMessages( +private suspend inline fun BehaviourContext.waitEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, + noinline errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: suspend ChatEventMessage.() -> O? + filter: SimpleFilter>? = null ): List = expectFlow( initRequest, count, errorFactory ) { - val data = it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() - if (data != null && (filter == null || filter(data))) { - data.mapper().let(::listOfNotNull) + val data = it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.withEvent() ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { + listOf(data.chatEvent) } else { emptyList() } }.toList().toList() - -private suspend inline fun BehaviourContext.waitEvents( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null, - noinline mapper: EventMessageToEventMapper? = null -) : List = waitEventMessages( - initRequest, - errorFactory, - count, - filter ?.let { - { - (it.chatEvent as? T) ?.let { filter(it as ChatEventMessage) } == true - } - } -) { - if (chatEvent is T) { - @Suppress("UNCHECKED_CAST") - val message = (this as ChatEventMessage) - if (mapper == null) { - message.chatEvent - } else { - mapper(message) - } - } else { - null - } -} - suspend fun BehaviourContext.waitChannelEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitPrivateEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitChatEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) @Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) @Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatStartedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) @Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatEndedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) @Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitVideoChatEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitVideoChatStartedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitVideoChatEndedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitVideoChatParticipantsInvitedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitPublicChatEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitCommonEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitGroupEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitSupergroupEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitChannelChatCreatedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitDeleteChatPhotoEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitGroupChatCreatedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitLeftChatMemberEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitNewChatPhotoEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitNewChatMembersEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitNewChatTitleEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitPinnedMessageEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitProximityAlertTriggeredEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitSupergroupChatCreatedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitSuccessfulPaymentEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitUserLoggedInEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter) suspend fun BehaviourContext.waitWebAppDataEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null -) = waitEvents(count, initRequest, errorFactory, filter ?.let { { it is PrivateEventMessage && filter(it) } }, mapper) + filter: SimpleFilter>? = null +) = waitEvents(initRequest, errorFactory, count, filter ?.let { SimpleFilter> { it is PrivateEventMessage && filter(it) } }) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt index 6523f126e0..b99bc9b76d 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt @@ -9,72 +9,40 @@ import kotlinx.coroutines.flow.toList typealias InlineQueryMapper = suspend T.() -> T? -private suspend fun BehaviourContext.waitInlineQueries( +private suspend inline fun BehaviourContext.waitInlineQueries( count: Int = 1, initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - mapper: suspend InlineQuery.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, errorFactory ) { - val data = it.asInlineQueryUpdate() ?.data - if (data != null && (filter == null || filter(data))) { - data.mapper().let(::listOfNotNull) + val data = (it.asInlineQueryUpdate() ?.data as? O) ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { + listOf(data) } else { emptyList() } }.toList().toList() - -private suspend inline fun BehaviourContext.waitInlines( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - noinline mapper: InlineQueryMapper? = null -) : List = waitInlineQueries( - count, - initRequest, - errorFactory, - filter ?.let { - { - (it as? T) ?.let { casted -> filter(casted) } == true - } - } -) { - if (this is T) { - if (mapper == null) { - this - } else { - mapper(this) - } - } else { - null - } -} - suspend fun BehaviourContext.waitAnyInlineQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: InlineQueryMapper? = null -) = waitInlines(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitInlineQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitBaseInlineQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: InlineQueryMapper? = null -) = waitInlines(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitInlineQueries(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitLocationInlineQuery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: InlineQueryMapper? = null -) = waitInlines(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitInlineQueries(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt index 5f8852fdbc..444c6f0ce8 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt @@ -1,7 +1,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate +import dev.inmo.tgbotapi.extensions.utils.withContent import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.* @@ -9,20 +11,20 @@ import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent import dev.inmo.tgbotapi.types.message.content.MediaGroupContent import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent -import dev.inmo.tgbotapi.utils.PreviewFeature import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.toList -typealias MediaGroupFilter = suspend List>.() -> Boolean +typealias MediaGroupFilter = SimpleFilter>> internal suspend inline fun BehaviourContext.buildMediaGroupWaiter( count: Int = 1, initRequest: Request<*>? = null, noinline errorFactory: NullableRequestBuilder<*> = { null }, - noinline filter: MediaGroupFilter? = null + filter: SimpleFilter>>? = null ) = flowsUpdatesFilter.expectFlow(bot, initRequest, count, errorFactory) { update -> update.asSentMediaGroupUpdate() ?.data ?.let { mediaGroup -> - if (mediaGroup.all { message -> message.content is T } && (filter == null || filter(mediaGroup as List>))) { + val mapped = mediaGroup.mapNotNull { it.withContent() } + if (mediaGroup.all { message -> message.content is T } && (filter == null || filter(mapped))) { listOf( mediaGroup.map { it.content as T } ) @@ -36,35 +38,35 @@ suspend fun BehaviourContext.waitMediaGroup( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: MediaGroupFilter? = null + filter: SimpleFilter>>? = null ) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitPlaylist( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: MediaGroupFilter? = null + filter: SimpleFilter>>? = null ) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitDocumentsGroup( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: MediaGroupFilter? = null + filter: SimpleFilter>>? = null ) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitVisualGallery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: MediaGroupFilter? = null + filter: SimpleFilter>>? = null ) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitPhotoGallery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: MediaGroupFilter? = null + filter: SimpleFilter>>? = null ) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) suspend fun BehaviourContext.waitVideoGallery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: MediaGroupFilter? = null + filter: SimpleFilter>>? = null ) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt index 6a858c5aea..4529b0a2b7 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt @@ -14,12 +14,11 @@ import kotlinx.coroutines.flow.toList typealias PassportMessageMapper = suspend PassportMessage.() -> PassportData @RiskFeature("Do not use this message directly, use waitPassportMessagesWith or waitAnyPassportMessages instead") -suspend fun BehaviourContext.waitPassportMessages( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, +suspend inline fun BehaviourContext.waitPassportMessagesWith( count: Int = 1, - filter: SimpleFilter? = null, - mapper: suspend PassportMessage.() -> O? + initRequest: Request<*>? = null, + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, @@ -27,39 +26,15 @@ suspend fun BehaviourContext.waitPassportMessages( ) { val data = it.asMessageUpdate() ?.data ?.asPassportMessage() ?: return@expectFlow emptyList() if (filter == null || filter(data)) { - data.mapper().let(::listOfNotNull) + data.passportData.data.filterIsInstance() } else { emptyList() } }.toList().toList() -suspend inline fun BehaviourContext.waitPassportMessagesWith( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - noinline mapper: PassportMessageMapper? = null -) : List = waitPassportMessages( - initRequest, - errorFactory, - count, - filter -) { - if (passportData.data.any { it is T }) { - if (mapper == null) { - passportData - } else { - mapper(this) - } - } else { - null - } -} - suspend fun BehaviourContext.waitAnyPassportMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: PassportMessageMapper? = null -) = waitPassportMessagesWith(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitPassportMessagesWith(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt index 6ef6baf180..ec50dba0cd 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt @@ -9,49 +9,24 @@ import kotlinx.coroutines.flow.toList typealias PollAnswerMapper = suspend PollAnswer.() -> PollAnswer? -private suspend fun BehaviourContext.waitPollsAnswers( +private suspend inline fun BehaviourContext.waitPollAnswers( count: Int = 1, initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - mapper: suspend PollAnswer.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, errorFactory ) { - val data = it.asPollAnswerUpdate() ?.data - if (data != null && (filter == null || filter(data))) { - data.mapper().let(::listOfNotNull) + val data = it.asPollAnswerUpdate() ?.data as? O ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { + listOf(data) } else { emptyList() } }.toList().toList() - -private suspend inline fun BehaviourContext.waitPollAnswers( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - noinline mapper: PollAnswerMapper? = null -) : List = this@waitPollAnswers.waitPollsAnswers( - count, - initRequest, - errorFactory, - filter ?.let { - { - (it as? PollAnswer) ?.let { filter(it) } == true - } - } -) { - if (mapper == null) { - this - } else { - mapper(this) - } -} - /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot */ @@ -59,6 +34,5 @@ suspend fun BehaviourContext.waitPollAnswers( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: PollAnswerMapper? = null -) = waitPollAnswers(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitPollAnswers(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt index 6e9ad291b0..f5f4c2e700 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt @@ -9,53 +9,24 @@ import kotlinx.coroutines.flow.toList typealias PollMapper = suspend T.() -> T? -private suspend fun BehaviourContext.waitPollsUpdates( +private suspend inline fun BehaviourContext.waitPolls( count: Int = 1, initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - mapper: suspend Poll.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, errorFactory ) { - val data = it.asPollUpdate() ?.data - if (data != null && (filter == null || filter(data))) { - data.mapper().let(::listOfNotNull) + val data = it.asPollUpdate() ?.data as? O ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { + listOf(data) } else { emptyList() } }.toList().toList() - -private suspend inline fun BehaviourContext.waitPolls( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - noinline mapper: PollMapper? = null -) : List = this@waitPolls.waitPollsUpdates( - count, - initRequest, - errorFactory, - filter ?.let { - { - (it as? T) ?.let { filter(it) } == true - } - } -) { - if (this is T) { - if (mapper == null) { - this - } else { - mapper(this) - } - } else { - null - } -} - /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot */ @@ -63,9 +34,8 @@ suspend fun BehaviourContext.waitPollUpdates( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: PollMapper? = null -) = waitPolls(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitPolls(count, initRequest, errorFactory, filter) /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot @@ -74,9 +44,8 @@ suspend fun BehaviourContext.waitQuizPollUpdates( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: PollMapper? = null -) = waitPolls(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitPolls(count, initRequest, errorFactory, filter) /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot @@ -85,6 +54,5 @@ suspend fun BehaviourContext.waitRegularPollUpdates( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: PollMapper? = null -) = waitPolls(count, initRequest, errorFactory, filter, mapper) + filter: SimpleFilter? = null +) = waitPolls(count, initRequest, errorFactory, filter) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt index 81ea5b23a2..5a072a1653 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt @@ -9,20 +9,19 @@ import kotlinx.coroutines.flow.toList typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery? -private suspend fun BehaviourContext.waitPreCheckoutQueries( +private suspend inline fun BehaviourContext.waitPreCheckoutQueries( count: Int = 1, initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - mapper: suspend PreCheckoutQuery.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, errorFactory ) { - val data = it.asPreCheckoutQueryUpdate() ?.data - if (data != null && (filter == null || filter(data))) { - data.mapper().let(::listOfNotNull) + val data = it.asPreCheckoutQueryUpdate() ?.data as? O ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { + listOf(data) } else { emptyList() } @@ -33,17 +32,10 @@ suspend fun BehaviourContext.waitPreCheckoutQueries( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: PreCheckoutQueryMapper? = null + filter: SimpleFilter? = null ) : List = waitPreCheckoutQueries( count, initRequest, errorFactory, filter -) { - if (mapper == null) { - this - } else { - mapper(this) - } -} +) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt index 3ec4382a00..0788867926 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt @@ -9,20 +9,19 @@ import kotlinx.coroutines.flow.toList typealias ShippingQueryMapper = suspend ShippingQuery.() -> ShippingQuery? -private suspend fun BehaviourContext.waitShippingQueries( +private suspend inline fun BehaviourContext.waitShippingQueries( count: Int = 1, initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null, - mapper: suspend ShippingQuery.() -> O? + noinline errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null ): List = expectFlow( initRequest, count, errorFactory ) { - val data = it.asShippingQueryUpdate() ?.data - if (data != null && (filter == null || filter(data))) { - data.mapper().let(::listOfNotNull) + val data = it.asShippingQueryUpdate() ?.data as? O ?: return@expectFlow emptyList() + if (filter == null || filter(data)) { + listOf(data) } else { emptyList() } @@ -33,17 +32,10 @@ suspend fun BehaviourContext.waitShippingQueries( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter? = null, - mapper: ShippingQueryMapper? = null + filter: SimpleFilter? = null ) : List = waitShippingQueries( count, initRequest, errorFactory, filter -) { - if (mapper == null) { - this - } else { - mapper(this) - } -} +) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt index 3dc45ebdca..34b7b5c27d 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt @@ -34,7 +34,6 @@ import dev.inmo.tgbotapi.types.message.content.MediaContent import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.utils.PreviewFeature internal suspend inline fun BC.onEditedContent( initialFilter: CommonMessageFilter? = null, diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithEvent.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithEvent.kt new file mode 100644 index 0000000000..d9221c82a4 --- /dev/null +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithEvent.kt @@ -0,0 +1,31 @@ +@file:Suppress("UNCHECKED_CAST") + +package dev.inmo.tgbotapi.extensions.utils + +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.content.MessageContent +import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage +import dev.inmo.tgbotapi.types.message.content.MediaGroupContent + +inline fun ChatEventMessage<*>.withEvent() = if (chatEvent is T) { this as ChatEventMessage } else { null } +inline fun ChatEventMessage<*>.requireWithEvent() = withEvent()!! + +inline fun GroupEventMessage<*>.withEvent() = if (chatEvent is T) { this as GroupEventMessage } else { null } +inline fun GroupEventMessage<*>.requireWithEvent() = withEvent()!! + +inline fun SupergroupEventMessage<*>.withEvent() = if (chatEvent is T) { this as SupergroupEventMessage } else { null } +inline fun SupergroupEventMessage<*>.requireWithEvent() = withEvent()!! + +inline fun PrivateEventMessage<*>.withEvent() = if (chatEvent is T) { this as PrivateEventMessage } else { null } +inline fun PrivateEventMessage<*>.requireWithEvent() = withEvent()!! + +inline fun ChannelEventMessage<*>.withEvent() = if (chatEvent is T) { this as ChannelEventMessage } else { null } +inline fun ChannelEventMessage<*>.requireWithEvent() = withEvent()!! + +inline fun CommonGroupEventMessage<*>.withEvent() = if (chatEvent is T) { this as CommonGroupEventMessage } else { null } +inline fun CommonGroupEventMessage<*>.requireWithEvent() = withEvent()!! + +inline fun CommonSupergroupEventMessage<*>.withEvent() = if (chatEvent is T) { this as CommonSupergroupEventMessage } else { null } +inline fun CommonSupergroupEventMessage<*>.requireWithEvent() = withEvent()!! From 95a466a08b404444954701db4f2986535389e7a7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 21 May 2022 23:53:45 +0600 Subject: [PATCH 6/9] start 2.0.0 --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf50b52fb2..5579dd09c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # TelegramBotAPI changelog -## 1.2.0 +## 2.0.0 * `Behaviour Builder`: * Mappers have been removed from waiters extensions diff --git a/gradle.properties b/gradle.properties index b1f684c783..5ab121910a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,6 +20,6 @@ javax_activation_version=1.1.1 dokka_version=1.6.21 library_group=dev.inmo -library_version=1.2.0 +library_version=2.0.0 github_release_plugin_version=2.3.7 From e7aec75acafa1a3500c901c037af5411b8c9bcb0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 22 May 2022 01:27:52 +0600 Subject: [PATCH 7/9] removing of filters for the wait triggers --- CHANGELOG.md | 2 + .../BehaviourContextWithFSM.kt | 32 ++- .../behaviour_builder/expectations/Base.kt | 21 +- .../expectations/WaitCallbackQuery.kt | 76 +++---- .../expectations/WaitChatJoinRequest.kt | 32 ++- .../expectations/WaitChatMemberUpdated.kt | 36 ++-- .../expectations/WaitChosenInlineResult.kt | 40 ++-- .../expectations/WaitContent.kt | 186 +++++------------ .../expectations/WaitContentMessage.kt | 168 +++++---------- .../expectations/WaitEditedContent.kt | 187 ++++++----------- .../expectations/WaitEditedContentMessage.kt | 156 ++++++++++++++ .../expectations/WaitEventAction.kt | 196 ++++++------------ .../expectations/WaitEventActionMessages.kt | 159 ++++++++++++++ .../expectations/WaitInlineQuery.kt | 40 ++-- .../expectations/WaitMediaGroup.kt | 63 ++---- .../expectations/WaitMediaGroupMessages.kt | 54 +++++ .../expectations/WaitPassportData.kt | 26 +-- .../expectations/WaitPollAnswers.kt | 35 +--- .../expectations/WaitPollUpdates.kt | 40 ++-- .../expectations/WaitPreCheckoutQuery.kt | 36 +--- .../expectations/WaitShippingQuery.kt | 34 +-- .../behaviour_builder/utils/LiveLocation.kt | 9 +- .../extensions/utils/FlowsAggregation.kt | 5 +- .../utils/shortcuts/FlowsUpdatesFilter.kt | 9 +- 24 files changed, 808 insertions(+), 834 deletions(-) create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 5579dd09c4..2ebb719f54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * `Behaviour Builder`: * Mappers have been removed from waiters extensions * Triggers extensions now will use filtering inside of context receiver instead of passing the filters into `BehaviourContext`. That means that in the subcontext will not be used preinstalled filters for their `BehaviourContext` and filter of trigger will not be used in subcontext + * Waiters do not take count parameter anymore + * Waiters do not take filter parameter anymore. Use flows filters * `Utils`: * Add opportunity to get event messages with specific `ChatEvent` type using `withEvent`/`requireWithEvent` (by analog with `withEvent` and `requireWithEvent`) diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt index 92810ef175..a96676a42f 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt @@ -47,10 +47,26 @@ interface BehaviourContextWithFSM : BehaviourContext, StatesMachine?, - triggersHolder: TriggersHolder, - updatesFilter: BehaviourContextAndTypeReceiver? + triggersHolder: TriggersHolder ): BehaviourContextWithFSM + fun copy( + bot: TelegramBot = this.bot, + scope: CoroutineScope = this.scope, + broadcastChannelsSize: Int = 100, + onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, + upstreamUpdatesFlow: Flow? = null, + triggersHolder: TriggersHolder = this.triggersHolder, + onStateHandlingErrorHandler: StateHandlingErrorHandler = defaultStateHandlingErrorHandler() + ): BehaviourContextWithFSM = copy( + bot, + scope, + broadcastChannelsSize, + onBufferOverflow, + upstreamUpdatesFlow, + triggersHolder + ) + fun copy( bot: TelegramBot = this.bot, scope: CoroutineScope = this.scope, @@ -67,7 +83,7 @@ interface BehaviourContextWithFSM : BehaviourContext, StatesMachine( broadcastChannelsSize: Int, onBufferOverflow: BufferOverflow, upstreamUpdatesFlow: Flow?, - triggersHolder: TriggersHolder, - updatesFilter: BehaviourContextAndTypeReceiver? + triggersHolder: TriggersHolder ): DefaultBehaviourContextWithFSM = BehaviourContextWithFSM( - behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder, updatesFilter), + behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder), handlers, statesManager, onStateHandlingErrorHandler @@ -212,10 +227,9 @@ class DefaultBehaviourContextWithFSM( onBufferOverflow: BufferOverflow, upstreamUpdatesFlow: Flow?, triggersHolder: TriggersHolder, - onStateHandlingErrorHandler: StateHandlingErrorHandler, - updatesFilter: BehaviourContextAndTypeReceiver? + onStateHandlingErrorHandler: StateHandlingErrorHandler ): DefaultBehaviourContextWithFSM = BehaviourContextWithFSM( - behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder, updatesFilter), + behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder), handlers, statesManager, onStateHandlingErrorHandler diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt index c5f1364cbf..0b0eb2c008 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt @@ -4,7 +4,7 @@ import dev.inmo.micro_utils.coroutines.safelyWithResult import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.utils.flatMap +import dev.inmo.tgbotapi.extensions.utils.flatten import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter @@ -20,7 +20,6 @@ typealias NullableRequestBuilder = suspend (Update) -> Request? /** * @param initRequest If not null, this request will be sent by [bot] before returning value - * @param count If set, result [Flow] will return [count] elements on each [Flow.collect] * @param errorFactory If set, this factory will be used to produce requests in case when user have sent incorrect data * @param cancelRequestFactory If set, this factory will be used to produce requests in case when it is required to say * user that chain of scenario has been cancelled @@ -33,7 +32,6 @@ typealias NullableRequestBuilder = suspend (Update) -> Request? suspend fun FlowsUpdatesFilter.expectFlow( bot: TelegramBot, initRequest: Request<*>? = null, - count: Int? = null, errorFactory: NullableRequestBuilder<*> = { null }, cancelRequestFactory: NullableRequestBuilder<*> = { null }, cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null }, @@ -55,19 +53,13 @@ suspend fun FlowsUpdatesFilter.expectFlow( } else { result.getOrThrow() } - }.flatMap() - val result = if (count == null) { - flow - } else { - flow.take(count) - } + }.flatten() initRequest ?.also { safelyWithoutExceptions { bot.execute(initRequest) } } - return result + return flow } /** * @param initRequest If not null, this request will be sent by [bot] before returning value - * @param count If set, result [Flow] will return [count] elements on each [Flow.collect] * @param errorFactory If set, this factory will be used to produce requests in case when user have sent incorrect data * @param cancelRequestFactory If set, this factory will be used to produce requests in case when it is required to say * user that chain of scenario has been cancelled @@ -76,14 +68,14 @@ suspend fun FlowsUpdatesFilter.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(lowLevelRiskFeatureMessage) suspend fun BehaviourContext.expectFlow( initRequest: Request<*>? = null, - count: Int? = null, errorFactory: NullableRequestBuilder<*> = { null }, cancelRequestFactory: NullableRequestBuilder<*> = { null }, cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null }, filter: suspend (Update) -> List -) = flowsUpdatesFilter.expectFlow(bot, initRequest, count, errorFactory, cancelRequestFactory, cancelTrigger, filter) +) = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory, cancelRequestFactory, cancelTrigger, filter) /** * @param initRequest If not null, this request will be sent by [bot] before returning value @@ -103,7 +95,7 @@ suspend fun FlowsUpdatesFilter.expectOne( cancelRequestFactory: NullableRequestBuilder<*> = { null }, cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null }, filter: suspend (Update) -> T? -): T = expectFlow(bot, initRequest, 1, errorFactory, cancelRequestFactory, cancelTrigger) { +): T = expectFlow(bot, initRequest, errorFactory, cancelRequestFactory, cancelTrigger) { listOfNotNull(filter.invoke(it)) }.first() @@ -117,6 +109,7 @@ suspend fun FlowsUpdatesFilter.expectOne( * 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(lowLevelRiskFeatureMessage) suspend fun BehaviourContext.expectOne( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt index 10f0b3888b..9266cab99a 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt @@ -7,80 +7,58 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.queries.callback.* +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias CallbackQueryMapper = suspend T.() -> T? -private suspend inline fun BehaviourContext.waitCallbackQueries( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitCallbackQueries( initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - count, errorFactory ) { - val data = it.asCallbackQueryUpdate() ?.data ?: return@expectFlow emptyList() - if (data is O && (filter == null || filter(data))) { - listOf(data) - } else { - emptyList() - } -}.toList().toList() + (it.asCallbackQueryUpdate() ?.data as O).let(::listOfNotNull) +} suspend fun BehaviourContext.waitDataCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitGameShortNameCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitInlineMessageIdCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitInlineMessageIdDataCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitInlineMessageIdGameShortNameCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitMessageCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitMessageDataCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitMessageGameShortNameCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitUnknownCallbackQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitCallbackQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitCallbackQueries(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt index 2c81debe2c..ef253dd339 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatJoinRequest.kt @@ -5,37 +5,29 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.chat.ChatJoinRequest +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias ChatJoinRequestsMapper = suspend ChatJoinRequest.() -> ChatJoinRequest? -private suspend inline fun BehaviourContext.internalWaitChatJoinRequests( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.internalWaitChatJoinRequests( initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - count, errorFactory ) { - val data = it.asChatJoinRequestUpdate() ?.data as? O ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - listOf(data) - } else { - emptyList() - } -}.toList().toList() + (it.asChatJoinRequestUpdate() ?.data as? O).let(::listOfNotNull) +} suspend fun BehaviourContext.waitChatJoinRequests( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) : List = internalWaitChatJoinRequests( - count, + errorFactory: NullableRequestBuilder<*> = { null } +) : Flow = internalWaitChatJoinRequests( initRequest, - errorFactory, - filter + errorFactory ) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt index 67ab6a2615..4f75e36f59 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt @@ -7,45 +7,35 @@ import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.MyChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias ChatMemberUpdatedMapper = suspend T.() -> T? -private suspend inline fun BehaviourContext.waitChatMemberUpdatedWithFilter( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitChatMemberUpdatedWithFilter( initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - count, errorFactory ) { - val casted = (it as? T) ?: return@expectFlow emptyList() - if (filter == null || filter(casted)) { - listOf(casted.data) - } else { - emptyList() - } -}.toList().toList() + (it as? O) ?.data.let(::listOfNotNull) +} suspend fun BehaviourContext.waitChatMemberUpdated( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter) +) = waitChatMemberUpdatedWithFilter(initRequest, errorFactory) suspend fun BehaviourContext.waitCommonChatMemberUpdated( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter) +) = waitChatMemberUpdatedWithFilter(initRequest, errorFactory) suspend fun BehaviourContext.waitMyChatMemberUpdated( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitChatMemberUpdatedWithFilter(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitChatMemberUpdatedWithFilter(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt index ea08427204..2b5744c174 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt @@ -5,45 +5,35 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.* +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias ChosenInlineResultMapper = suspend T.() -> T? -private suspend inline fun BehaviourContext.waitChosenInlineResults( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitChosenInlineResults( initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - count, errorFactory ) { - val data = it.asChosenInlineResultUpdate() ?.data as? O ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - listOf(data) - } else { - emptyList() - } -}.toList().toList() + (it.asChosenInlineResultUpdate() ?.data as? O).let(::listOfNotNull) +} suspend fun BehaviourContext.waitChosenInlineResult( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitChosenInlineResults(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitChosenInlineResults(initRequest, errorFactory) suspend fun BehaviourContext.waitLocationChosenInlineResult( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitChosenInlineResults(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitChosenInlineResults(initRequest, errorFactory) suspend fun BehaviourContext.waitBaseChosenInlineResult( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitChosenInlineResults(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitChosenInlineResults(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index 8698cdecbf..01f9ce1acd 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -15,201 +15,129 @@ import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map typealias CommonMessageToContentMapper = suspend CommonMessage.() -> T? -private suspend inline fun BehaviourContext.waitContent( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitContent( initRequest: Request<*>? = null, includeMediaGroups: Boolean = true, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null -): Flow = expectFlow( - initRequest, - count, - errorFactory -) { - val messages = when (it) { - is SentMediaGroupUpdate -> { - if (includeMediaGroups) { - it.data - } else { - emptyList() - } - } - is BaseSentMessageUpdate -> listOf(it.data) - else -> return@expectFlow emptyList() - } - messages.mapNotNull { message -> - val asCommonMessage = (message as CommonMessage<*>).withContent() ?: return@mapNotNull null - if (filter == null || filter(asCommonMessage)) { - asCommonMessage.content - } else { - null - } - } -} + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = waitContentMessage(initRequest, includeMediaGroups, errorFactory).map { it.content } suspend fun BehaviourContext.waitContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitContact( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitDice( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitGame( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitLocation( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitLiveLocation( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitStaticLocation( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitPoll( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitText( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitVenue( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitAnimation( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitAudio( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitDocument( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitPhoto( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitSticker( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitVideo( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitVideoNote( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitVoice( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitInvoice( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, false, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt index e4e18a9eb6..2f67610c3f 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt @@ -16,19 +16,19 @@ import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow typealias CommonMessageToCommonMessageMapper = suspend CommonMessage.() -> CommonMessage? -internal suspend inline fun BehaviourContext.waitContentMessage( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitContentMessage( initRequest: Request<*>? = null, includeMediaGroups: Boolean = true, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null + noinline errorFactory: NullableRequestBuilder<*> = { null } ): Flow> = expectFlow( initRequest, - count, errorFactory ) { val messages = when (it) { @@ -43,13 +43,7 @@ internal suspend inline fun BehaviourContext.waitCo else -> return@expectFlow emptyList() } messages.mapNotNull { message -> - @Suppress("UNCHECKED_CAST") - val asCommonMessage = (message as? CommonMessage<*>) ?.withContent() ?: return@mapNotNull null - if (filter == null || filter(asCommonMessage)) { - asCommonMessage - } else { - null - } + (message as? CommonMessage<*>) ?.withContent() } } @@ -73,161 +67,111 @@ internal inline fun contentMessageConverter( suspend fun BehaviourContext.waitContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitContactMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitDiceMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitGameMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitLocationMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitLiveLocationMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitStaticLocationMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitPollMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitTextMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitVenueMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitMediaMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitTextedMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitAnimationMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitAudioMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitDocumentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitPhotoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitStickerMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitVideoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitVideoNoteMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitVoiceMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) suspend fun BehaviourContext.waitInvoiceMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitContentMessage(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, false, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index ca7bebab37..2ca4af7fbb 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -16,192 +16,127 @@ import dev.inmo.tgbotapi.types.message.content.MediaGroupContent import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate -import kotlinx.coroutines.flow.toList +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.* -private suspend inline fun BehaviourContext.waitEditedContent( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitEditedContent( initRequest: Request<*>? = null, includeMediaGroups: Boolean = true, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>? = null -): List = expectFlow( - initRequest, - count, - errorFactory -) { - val messages = when (it) { - is BaseEditMessageUpdate -> { - val commonMessage = it.data.asCommonMessage() ?: return@expectFlow emptyList() - if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) { - listOf(commonMessage) - } else { - emptyList() - } - } - else -> return@expectFlow emptyList() - } - messages.mapNotNull { message -> - val asCommonMessage = (message as CommonMessage<*>).withContent() ?: return@mapNotNull null - if (filter == null || filter(asCommonMessage)) { - asCommonMessage.content - } else { - null - } - } -}.toList().toList() + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory).map { it.content } + +suspend fun BehaviourContext.waitEditedMessageContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = true +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedContact( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedDice( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedGame( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedLocation( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedLiveLocation( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedStaticLocation( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedText( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedVenue( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = true, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = true +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedAnimation( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedAudio( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedDocument( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedPhoto( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedSticker( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedVideo( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - includeMediaGroups: Boolean = false, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter) + includeMediaGroups: Boolean = false +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedVideoNote( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedVoice( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedInvoice( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEditedContent(count, initRequest, false, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt new file mode 100644 index 0000000000..69d9b1b16f --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt @@ -0,0 +1,156 @@ +@file:Suppress("unused") + +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.asCommonMessage +import dev.inmo.tgbotapi.extensions.utils.withContent +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage +import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +import dev.inmo.tgbotapi.types.message.content.* +import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.InvoiceContent +import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.toList + +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitEditedContentMessage( + initRequest: Request<*>? = null, + includeMediaGroups: Boolean = true, + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow> = expectFlow( + initRequest, + errorFactory +) { + val messages = when (it) { + is BaseEditMessageUpdate -> { + val commonMessage = it.data.asCommonMessage() ?: return@expectFlow emptyList() + if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) { + listOf(commonMessage) + } else { + emptyList() + } + } + else -> return@expectFlow emptyList() + } + messages.mapNotNull { message -> + (message as CommonMessage<*>).withContent() + } +} + +suspend fun BehaviourContext.waitEditedMessageContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = true +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) + +suspend fun BehaviourContext.waitEditedContactMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedDiceMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedGameMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedLocationMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedLiveLocationMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedStaticLocationMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedTextMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedVenueMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedAudioMediaGroupContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = true +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedDocumentMediaGroupContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = true +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedMediaMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = false +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedAnyMediaGroupContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = true +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedVisualMediaGroupContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = true +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedTextedMediaContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = true +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedAnimationMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedAudioMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = false +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedDocumentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = false +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedPhotoMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = false +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedStickerMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedVideoMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + includeMediaGroups: Boolean = false +) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +suspend fun BehaviourContext.waitEditedVideoNoteMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedVoiceMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) +suspend fun BehaviourContext.waitEditedInvoiceMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, false, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index dea7200e22..6a23a0952a 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -12,212 +12,150 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.PrivateEventMessage import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias EventMessageToEventMapper = suspend ChatEventMessage.() -> T? -private suspend inline fun BehaviourContext.waitEvents( +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitEvents( initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -): List = expectFlow( + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - count, errorFactory ) { - val data = it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.withEvent() ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - listOf(data.chatEvent) - } else { - emptyList() - } -}.toList().toList() + it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.withEvent() ?.chatEvent.let(::listOfNotNull) +} suspend fun BehaviourContext.waitChannelEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitPrivateEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitChatEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) @Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) @Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatStartedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) @Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatEndedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) @Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoChatEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoChatStartedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoChatEndedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoChatParticipantsInvitedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitPublicChatEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitCommonEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitGroupEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitSupergroupEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitChannelChatCreatedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitDeleteChatPhotoEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitGroupChatCreatedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitLeftChatMemberEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitNewChatPhotoEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitNewChatMembersEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitNewChatTitleEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitPinnedMessageEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitProximityAlertTriggeredEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitSupergroupChatCreatedEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitSuccessfulPaymentEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitUserLoggedInEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitWebAppDataEvents( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>? = null -) = waitEvents(initRequest, errorFactory, count, filter ?.let { SimpleFilter> { it is PrivateEventMessage && filter(it) } }) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt new file mode 100644 index 0000000000..2df1b701d9 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt @@ -0,0 +1,159 @@ +@file:Suppress("unused") + +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.* +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.message.ChannelEventMessage +import dev.inmo.tgbotapi.types.message.ChatEvents.* +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* +import dev.inmo.tgbotapi.types.message.PrivateEventMessage +import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage +import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.* + +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitEventsMessages( + initRequest: Request<*>? = null, + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow> = expectFlow( + initRequest, + errorFactory +) { + it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.withEvent().let(::listOfNotNull) +} + +suspend fun BehaviourContext.waitChannelEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + +suspend fun BehaviourContext.waitPrivateEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + +suspend fun BehaviourContext.waitChatEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + +@Deprecated("Renamed as Video instead of Voice") +suspend fun BehaviourContext.waitVoiceChatEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +@Deprecated("Renamed as Video instead of Voice") +suspend fun BehaviourContext.waitVoiceChatStartedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +@Deprecated("Renamed as Video instead of Voice") +suspend fun BehaviourContext.waitVoiceChatEndedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +@Deprecated("Renamed as Video instead of Voice") +suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + +suspend fun BehaviourContext.waitVideoChatEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitVideoChatStartedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitVideoChatEndedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitVideoChatParticipantsInvitedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + +suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + + +suspend fun BehaviourContext.waitPublicChatEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitCommonEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + +suspend fun BehaviourContext.waitGroupEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitSupergroupEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + +suspend fun BehaviourContext.waitChannelChatCreatedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitDeleteChatPhotoEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitGroupChatCreatedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitLeftChatMemberEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitNewChatPhotoEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitNewChatMembersEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitNewChatTitleEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitPinnedMessageEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitProximityAlertTriggeredEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitSupergroupChatCreatedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitSuccessfulPaymentEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitUserLoggedInEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitWebAppDataEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt index b99bc9b76d..8c6c5bc393 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt @@ -5,44 +5,34 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.InlineQueries.query.* +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias InlineQueryMapper = suspend T.() -> T? -private suspend inline fun BehaviourContext.waitInlineQueries( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitInlineQueries( initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - count, errorFactory ) { - val data = (it.asInlineQueryUpdate() ?.data as? O) ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - listOf(data) - } else { - emptyList() - } -}.toList().toList() + (it.asInlineQueryUpdate() ?.data as? O).let(::listOfNotNull) +} suspend fun BehaviourContext.waitAnyInlineQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitInlineQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitInlineQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitBaseInlineQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitInlineQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitInlineQueries(initRequest, errorFactory) suspend fun BehaviourContext.waitLocationInlineQuery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitInlineQueries(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitInlineQueries(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt index 444c6f0ce8..542f7a7d46 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt @@ -11,62 +11,41 @@ import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent import dev.inmo.tgbotapi.types.message.content.MediaGroupContent import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent -import kotlinx.coroutines.flow.take -import kotlinx.coroutines.flow.toList +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map typealias MediaGroupFilter = SimpleFilter>> -internal suspend inline fun BehaviourContext.buildMediaGroupWaiter( - count: Int = 1, + +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.buildMediaGroupWaiter( initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter>>? = null -) = flowsUpdatesFilter.expectFlow(bot, initRequest, count, errorFactory) { update -> - update.asSentMediaGroupUpdate() ?.data ?.let { mediaGroup -> - val mapped = mediaGroup.mapNotNull { it.withContent() } - if (mediaGroup.all { message -> message.content is T } && (filter == null || filter(mapped))) { - listOf( - mediaGroup.map { it.content as T } - ) - } else { - null - } - } ?: emptyList() -}.take(count).toList() + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow> = buildMediaGroupMessagesWaiter(initRequest, errorFactory).map { it.map { it.content } } suspend fun BehaviourContext.waitMediaGroup( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>>? = null -) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitPlaylist( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>>? = null -) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitDocumentsGroup( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>>? = null -) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitVisualGallery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>>? = null -) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitPhotoGallery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>>? = null -) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoGallery( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter>>? = null -) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupWaiter(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt new file mode 100644 index 0000000000..29f03d276e --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt @@ -0,0 +1,54 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate +import dev.inmo.tgbotapi.extensions.utils.withContent +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +import dev.inmo.tgbotapi.types.message.content.* +import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow + +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.buildMediaGroupMessagesWaiter( + initRequest: Request<*>? = null, + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow>> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update -> + update.asSentMediaGroupUpdate() ?.data ?.let { mediaGroup -> + val mapped = mediaGroup.mapNotNull { it.withContent() } + listOf( + mapped + ) + } ?: emptyList() +} + +suspend fun BehaviourContext.waitMediaGroupMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +suspend fun BehaviourContext.waitPlaylistMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +suspend fun BehaviourContext.waitDocumentsGroupMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +suspend fun BehaviourContext.waitVisualGalleryMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +suspend fun BehaviourContext.waitPhotoGalleryMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +suspend fun BehaviourContext.waitVideoGalleryMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt index 4529b0a2b7..2d1c16c90f 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt @@ -9,32 +9,24 @@ import dev.inmo.tgbotapi.types.message.PassportMessage import dev.inmo.tgbotapi.types.passport.PassportData import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportElement import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias PassportMessageMapper = suspend PassportMessage.() -> PassportData -@RiskFeature("Do not use this message directly, use waitPassportMessagesWith or waitAnyPassportMessages instead") +@RiskFeature(lowLevelRiskFeatureMessage) suspend inline fun BehaviourContext.waitPassportMessagesWith( - count: Int = 1, initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - count, errorFactory ) { - val data = it.asMessageUpdate() ?.data ?.asPassportMessage() ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - data.passportData.data.filterIsInstance() - } else { - emptyList() - } -}.toList().toList() + it.asMessageUpdate() ?.data ?.asPassportMessage() ?.passportData ?.data ?.filterIsInstance() ?: emptyList() +} suspend fun BehaviourContext.waitAnyPassportMessages( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitPassportMessagesWith(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitPassportMessagesWith(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt index ec50dba0cd..a59fcccc4b 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt @@ -5,34 +5,19 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.polls.PollAnswer +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias PollAnswerMapper = suspend PollAnswer.() -> PollAnswer? -private suspend inline fun BehaviourContext.waitPollAnswers( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( - initRequest, - count, - errorFactory -) { - val data = it.asPollAnswerUpdate() ?.data as? O ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - listOf(data) - } else { - emptyList() - } -}.toList().toList() - -/** - * This wait will be triggered only for stopped polls and polls, which are sent by the bot - */ suspend fun BehaviourContext.waitPollAnswers( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitPollAnswers(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( + initRequest, + errorFactory +) { + it.asPollAnswerUpdate() ?.data.let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt index f5f4c2e700..1dd9ad044c 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt @@ -5,54 +5,44 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asPollUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.polls.* +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias PollMapper = suspend T.() -> T? -private suspend inline fun BehaviourContext.waitPolls( - count: Int = 1, +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitPolls( initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - count, errorFactory ) { - val data = it.asPollUpdate() ?.data as? O ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - listOf(data) - } else { - emptyList() - } -}.toList().toList() + (it.asPollUpdate() ?.data as? O).let(::listOfNotNull) +} /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot */ suspend fun BehaviourContext.waitPollUpdates( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitPolls(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitPolls(initRequest, errorFactory) /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot */ suspend fun BehaviourContext.waitQuizPollUpdates( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitPolls(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitPolls(initRequest, errorFactory) /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot */ suspend fun BehaviourContext.waitRegularPollUpdates( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) = waitPolls(count, initRequest, errorFactory, filter) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitPolls(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt index 5a072a1653..0c2fcb5cf3 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt @@ -5,37 +5,19 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery? -private suspend inline fun BehaviourContext.waitPreCheckoutQueries( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( - initRequest, - count, - errorFactory -) { - val data = it.asPreCheckoutQueryUpdate() ?.data as? O ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - listOf(data) - } else { - emptyList() - } -}.toList().toList() - - suspend fun BehaviourContext.waitPreCheckoutQueries( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) : List = waitPreCheckoutQueries( - count, + errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - errorFactory, - filter -) + errorFactory +) { + it.asPreCheckoutQueryUpdate() ?.data.let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt index 0788867926..a35a7b9a66 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt @@ -5,37 +5,17 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.payments.ShippingQuery +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias ShippingQueryMapper = suspend ShippingQuery.() -> ShippingQuery? -private suspend inline fun BehaviourContext.waitShippingQueries( - count: Int = 1, - initRequest: Request<*>? = null, - noinline errorFactory: NullableRequestBuilder<*> = { null }, - filter: SimpleFilter? = null -): List = expectFlow( - initRequest, - count, - errorFactory -) { - val data = it.asShippingQueryUpdate() ?.data as? O ?: return@expectFlow emptyList() - if (filter == null || filter(data)) { - listOf(data) - } else { - emptyList() - } -}.toList().toList() - - suspend fun BehaviourContext.waitShippingQueries( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - count: Int = 1, - filter: SimpleFilter? = null -) : List = waitShippingQueries( - count, + errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( initRequest, - errorFactory, - filter -) + errorFactory +) { + (it.asShippingQueryUpdate() ?.data).let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt index ac5b3deaba..5d7cfcc624 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt @@ -3,9 +3,12 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.utils import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTypeReceiver import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitEditedLocation +import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitEditedLocationMessage import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.LiveLocationContent +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.first /** * Use this extension when you want to follow [LiveLocation] until it will became [StaticLocation]. This method @@ -20,11 +23,7 @@ suspend fun BehaviourContext.followLocation( onLocation(message.content.location) while (currentLocation !is StaticLocation) { - currentLocation = waitEditedLocation( - filter = { - it.messageId == message.messageId && it.chat.id == message.chat.id - } - ).first().location + currentLocation = waitEditedLocationMessage().filter { it.messageId == message.messageId && it.chat.id == message.chat.id }.first().content.location onLocation(currentLocation) } } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt index 6f6bee5cc5..532aec780e 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt @@ -22,7 +22,7 @@ fun aggregateFlows( return sharedFlow } -fun Flow>.flatMap(): Flow = flow { +fun Flow>.flatten(): Flow = flow { collect { it.forEach { emit(it) @@ -30,6 +30,9 @@ fun Flow>.flatMap(): Flow = flow { } } +@Deprecated("Renamed", ReplaceWith("flatten", "dev.inmo.tgbotapi.extensions.utils.flatten")) +fun Flow>.flatMap(): Flow = flatten() + fun Flow.flatMap(mapper: (T) -> Iterable): Flow = flow { collect { mapper(it).forEach { diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt index a2b75c0b95..dff78316e4 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.shortcuts import dev.inmo.tgbotapi.extensions.utils.aggregateFlows import dev.inmo.tgbotapi.extensions.utils.flatMap +import dev.inmo.tgbotapi.extensions.utils.flatten import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -111,7 +112,7 @@ fun FlowsUpdatesFilter.audioMessagesWithMediaGroups( scopeToIncludeChannels: CoroutineScope? = null ) = merge( filterContentMessages(scopeToIncludeChannels), - mediaGroupAudioMessages(scopeToIncludeChannels).flatMap() + mediaGroupAudioMessages(scopeToIncludeChannels).flatten() ) fun Flow.contactMessages() = filterContentMessages() @@ -132,7 +133,7 @@ fun FlowsUpdatesFilter.documentMessagesWithMediaGroups( scopeToIncludeChannels: CoroutineScope? = null ) = merge( filterContentMessages(scopeToIncludeChannels), - mediaGroupDocumentMessages(scopeToIncludeChannels).flatMap() + mediaGroupDocumentMessages(scopeToIncludeChannels).flatten() ) fun Flow.gameMessages() = filterContentMessages() @@ -159,7 +160,7 @@ fun FlowsUpdatesFilter.photoMessagesWithMediaGroups( scopeToIncludeChannels: CoroutineScope? = null ) = merge( filterContentMessages(scopeToIncludeChannels), - mediaGroupPhotosMessages(scopeToIncludeChannels).flatMap() + mediaGroupPhotosMessages(scopeToIncludeChannels).flatten() ) /** * Shortcut for [photoMessages] @@ -200,7 +201,7 @@ fun FlowsUpdatesFilter.videoMessagesWithMediaGroups( scopeToIncludeChannels: CoroutineScope? = null ) = merge( filterContentMessages(scopeToIncludeChannels), - mediaGroupVideosMessages(scopeToIncludeChannels).flatMap() + mediaGroupVideosMessages(scopeToIncludeChannels).flatten() ) fun Flow.videoNoteMessages() = filterContentMessages() From 416187e079949cee7c8f3d078955b565d5274af7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 22 May 2022 01:40:03 +0600 Subject: [PATCH 8/9] remove deprecations --- CHANGELOG.md | 2 + .../EditChatMessageLiveLocation.kt | 92 ------- .../EditInlineMessageLiveLocation.kt | 25 -- .../StopChatMessageLiveLocation.kt | 43 ---- .../StopInlineMessageLiveLocation.kt | 17 -- .../ReplyMarkup/EditChatMessageReplyMarkup.kt | 42 ---- .../EditInlineMessageReplyMarkup.kt | 17 -- .../BehaviourContextWithFSMBuilder.kt | 3 - .../StateHandlingErrorHandler.kt | 10 - .../behaviour_builder/BehaviourContext.kt | 44 +--- .../expectations/WaitEventAction.kt | 20 -- .../expectations/WaitEventActionMessages.kt | 21 -- .../triggers_handling/EventTriggers.kt | 80 ------ .../CommonAbstracts/CommonContactData.kt | 4 - .../CommonAbstracts/CommonSendInvoiceData.kt | 4 - .../CommonAbstracts/CommonVenueData.kt | 4 - .../inmo/tgbotapi/CommonAbstracts/FromUser.kt | 4 - .../inmo/tgbotapi/CommonAbstracts/Headed.kt | 4 - .../CommonAbstracts/HorizontallyAccured.kt | 4 - .../inmo/tgbotapi/CommonAbstracts/Livable.kt | 4 - .../tgbotapi/CommonAbstracts/Locationed.kt | 4 - .../tgbotapi/CommonAbstracts/MimeTyped.kt | 4 - .../tgbotapi/CommonAbstracts/Performerable.kt | 4 - .../CommonAbstracts/ProximityAlertable.kt | 4 - .../inmo/tgbotapi/CommonAbstracts/Texted.kt | 18 -- .../inmo/tgbotapi/CommonAbstracts/Titled.kt | 4 - .../inmo/tgbotapi/CommonAbstracts/WithUser.kt | 4 - .../CommonAbstracts/types/ChatRequest.kt | 4 - .../types/DisableNotification.kt | 4 - .../types/DisableWebPagePreview.kt | 4 - .../types/InlineMessageAction.kt | 4 - .../CommonAbstracts/types/MessageAction.kt | 4 - .../types/OptionalChatRequest.kt | 4 - .../CommonAbstracts/types/ProtectContent.kt | 4 - .../CommonAbstracts/types/ReplyMarkup.kt | 4 - .../CommonAbstracts/types/ReplyMessageId.kt | 4 - .../CommonAbstracts/types/UntilDate.kt | 4 - .../inmo/tgbotapi/bot/Ktor/KtorCallFactory.kt | 4 - .../tgbotapi/bot/Ktor/KtorRequestsExecutor.kt | 32 --- .../Ktor/base/AbstractRequestCallFactory.kt | 6 - .../DownloadFileChannelRequestCallFactory.kt | 4 - .../base/DownloadFileRequestCallFactory.kt | 4 - .../Ktor/base/MultipartRequestCallFactory.kt | 4 - .../bot/Ktor/base/SimpleRequestCallFactory.kt | 4 - .../tgbotapi/requests/abstracts/InputFile.kt | 13 - .../EditChatMessageLiveLocation.kt | 7 - .../EditInlineMessageLiveLocation.kt | 4 - .../StopChatMessageLiveLocation.kt | 7 - .../StopInlineMessageLiveLocation.kt | 4 - .../ReplyMarkup/EditChatMessageReplyMarkup.kt | 7 - .../EditInlineMessageReplyMarkup.kt | 4 - .../types/CallbackQuery/CallbackQuery.kt | 7 - .../types/CallbackQuery/DataCallbackQuery.kt | 4 - .../GameShortNameCallbackQuery.kt | 4 - .../InlineMessageIdCallbackQuery.kt | 4 - .../InlineMessageIdDataCallbackQuery.kt | 4 - ...lineMessageIdGameShortNameCallbackQuery.kt | 4 - .../CallbackQuery/MessageCallbackQuery.kt | 4 - .../CallbackQuery/MessageDataCallbackQuery.kt | 4 - .../MessageGameShortNameCallbackQuery.kt | 4 - .../types/ChatAdministratorRightsImpl.kt | 4 - .../ChatMember/AdministratorChatMemberImpl.kt | 4 - .../types/ChatMember/CreatorChatMember.kt | 4 - .../types/ChatMember/KickedChatMember.kt | 4 - .../types/ChatMember/LeftChatMemberImpl.kt | 4 - .../types/ChatMember/MemberChatMemberImpl.kt | 4 - .../types/ChatMember/RestrictedChatMember.kt | 4 - .../abstracts/AdministratorChatMember.kt | 7 - .../ChatMember/abstracts/BannedChatMember.kt | 4 - .../abstracts/ChatAdministratorRights.kt | 7 - .../types/ChatMember/abstracts/ChatMember.kt | 7 - .../ChatMember/abstracts/LeftChatMember.kt | 4 - .../ChatMember/abstracts/MemberChatMember.kt | 4 - .../abstracts/SpecialRightsChatMember.kt | 4 - .../types/InputMedia/InputMediaAnimation.kt | 39 --- .../types/InputMedia/InputMediaAudio.kt | 62 ----- .../types/InputMedia/InputMediaDocument.kt | 53 ---- .../types/InputMedia/InputMediaPhoto.kt | 40 --- .../types/InputMedia/InputMediaVideo.kt | 28 --- .../tgbotapi/types/InputMedia/Typealiases.kt | 34 --- .../types/MessageEntity/RemoveLeading.kt | 8 - .../textsources/BoldTextSource.kt | 17 -- .../textsources/BotCommandTextSource.kt | 16 -- .../textsources/CashTagTextSource.kt | 17 -- .../textsources/CodeTextSource.kt | 13 - .../textsources/EMailTextSource.kt | 17 -- .../textsources/HashTagTextSource.kt | 20 -- .../textsources/ItalicTextSource.kt | 18 -- .../textsources/MentionTextSource.kt | 28 --- .../textsources/PhoneNumberTextSource.kt | 18 -- .../textsources/PreTextSource.kt | 12 - .../textsources/RegularTextSource.kt | 11 - .../textsources/SpoilerTextSource.kt | 18 -- .../textsources/StrikethroughTextSource.kt | 17 -- .../textsources/TextLinkTextSource.kt | 13 - .../textsources/TextMentionTextSource.kt | 51 ---- .../MessageEntity/textsources/TextSource.kt | 50 ---- .../textsources/TextSourceSerializer.kt | 5 - .../textsources/TextSourcesOrElse.kt | 15 -- .../textsources/URLTextSource.kt | 13 - .../textsources/UnderlineTextSource.kt | 19 -- .../tgbotapi/types/ParseMode/ParseMode.kt | 31 --- .../kotlin/dev/inmo/tgbotapi/types/User.kt | 22 -- .../types/chat/abstracts/Typealiases.kt | 25 -- .../chat/abstracts/extended/Typealiases.kt | 19 -- .../types/chat/extended/Typealiases.kt | 19 -- .../inmo/tgbotapi/types/files/VideoFile.kt | 13 - .../types/files/abstracts/OldTypealiases.kt | 22 -- .../tgbotapi/types/files/sticker/Sticker.kt | 19 -- .../ChatEvents/abstracts/VideoChatEvent.kt | 5 - .../ChatEvents/voice/VideoChatEnded.kt | 3 - .../voice/VideoChatParticipantsInvited.kt | 3 - .../ChatEvents/voice/VideoChatScheduled.kt | 3 - .../ChatEvents/voice/VideoChatStarted.kt | 3 - .../types/message/content/Abstracts.kt | 2 - .../types/message/content/AbstractsMedia.kt | 2 - .../message/content/abstracts/Typealiases.kt | 25 -- .../message/content/media/Typealiases.kt | 44 ---- .../types/message/payments/InvoiceContent.kt | 4 - .../types/passport/encrypted/PassportFile.kt | 4 - .../ChannelPostMediaGroupUpdate.kt | 4 - .../EditChannelPostMediaGroupUpdate.kt | 4 - .../EditMessageMediaGroupUpdate.kt | 4 - .../MediaGroupUpdates/MediaGroupUpdate.kt | 10 - .../MessageMediaGroupUpdate.kt | 4 - .../kotlin/dev/inmo/tgbotapi/utils/Matrix.kt | 65 ----- .../dev/inmo/tgbotapi/utils/StorageFile.kt | 72 ------ .../tgbotapi/utils/TelegramAPIUrlsKeeper.kt | 7 - .../inmo/tgbotapi/utils/StorageFileFactory.kt | 14 -- .../tgbotapi/extensions/utils/ClassCasts.kt | 230 ------------------ .../utils/extensions/raw/Message.kt | 16 -- .../utils/types/files/ContentAsStorageFile.kt | 43 ---- .../tgbotapi/webapps/CryptoJSExtensions.kt | 9 - 133 files changed, 3 insertions(+), 2133 deletions(-) delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt delete mode 100644 tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/StateHandlingErrorHandler.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonContactData.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonVenueData.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/FromUser.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Headed.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/HorizontallyAccured.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Livable.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Locationed.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/MimeTyped.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Performerable.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/ProximityAlertable.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Titled.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/WithUser.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ChatRequest.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/DisableNotification.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/DisableWebPagePreview.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/InlineMessageAction.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/MessageAction.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/OptionalChatRequest.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ProtectContent.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ReplyMarkup.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ReplyMessageId.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/UntilDate.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorCallFactory.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/AbstractRequestCallFactory.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileRequestCallFactory.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/GameShortNameCallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdCallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdDataCallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdGameShortNameCallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageCallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageDataCallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageGameShortNameCallbackQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatAdministratorRightsImpl.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/KickedChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/RestrictedChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/BannedChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatAdministratorRights.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/LeftChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/MemberChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/SpecialRightsChatMember.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/Typealiases.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RemoveLeading.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/SpoilerTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourcesOrElse.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/User.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/Typealiases.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/extended/Typealiases.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/extended/Typealiases.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/abstracts/OldTypealiases.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/sticker/Sticker.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/Typealiases.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/Typealiases.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/InvoiceContent.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/PassportFile.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/ChannelPostMediaGroupUpdate.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditChannelPostMediaGroupUpdate.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditMessageMediaGroupUpdate.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MediaGroupUpdate.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MessageMediaGroupUpdate.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt delete mode 100644 tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/StorageFileFactory.kt delete mode 100644 tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt delete mode 100644 tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/CryptoJSExtensions.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ebb719f54..5c3766c58e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 2.0.0 +___ALL PREVIOUS DEPRECATIONS HAVE BEEN REMOVED___ + * `Behaviour Builder`: * Mappers have been removed from waiters extensions * Triggers extensions now will use filtering inside of context receiver instead of passing the filters into `BehaviourContext`. That means that in the subcontext will not be used preinstalled filters for their `BehaviourContext` and filter of trigger will not be used in subcontext diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt deleted file mode 100644 index c0a4cbc475..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt +++ /dev/null @@ -1,92 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.location.LiveLocation -import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.content.LocationContent -import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation")) -suspend fun TelegramBot.editLiveLocation( - chatId: ChatIdentifier, - messageId: MessageIdentifier, - latitude: Double, - longitude: Double, - horizontalAccuracy: Meters? = null, - heading: Degrees? = null, - proximityAlertRadius: Meters? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = editLiveLocation(chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation")) -suspend fun TelegramBot.editLiveLocation( - chat: Chat, - messageId: MessageIdentifier, - latitude: Double, - longitude: Double, - horizontalAccuracy: Meters? = null, - heading: Degrees? = null, - proximityAlertRadius: Meters? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = editLiveLocation(chat, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation")) -suspend fun TelegramBot.editLiveLocation( - message: ContentMessage, - latitude: Double, - longitude: Double, - horizontalAccuracy: Meters? = null, - heading: Degrees? = null, - proximityAlertRadius: Meters? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = editLiveLocation(message, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation")) -suspend fun TelegramBot.editLiveLocation( - chatId: ChatIdentifier, - messageId: MessageIdentifier, - location: LiveLocation, - replyMarkup: InlineKeyboardMarkup? = null -) = editLiveLocation(chatId, messageId, location, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation")) -suspend fun TelegramBot.editLiveLocation( - chat: Chat, - messageId: MessageIdentifier, - location: LiveLocation, - replyMarkup: InlineKeyboardMarkup? = null -) = editLiveLocation(chat, messageId, location, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation")) -suspend fun TelegramBot.editLiveLocation( - message: ContentMessage, - location: LiveLocation, - replyMarkup: InlineKeyboardMarkup? = null -) = editLiveLocation(message, location, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt deleted file mode 100644 index 56b2a842aa..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt +++ /dev/null @@ -1,25 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation -import dev.inmo.tgbotapi.requests.edit.location.live.EditInlineMessageLiveLocation -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.location.LiveLocation - -@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation")) -suspend fun TelegramBot.editLiveLocation( - inlineMessageId: InlineMessageIdentifier, - latitude: Double, - longitude: Double, - horizontalAccuracy: Meters? = null, - heading: Degrees? = null, - proximityAlertRadius: Meters? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = editLiveLocation(inlineMessageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup) -@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation")) -suspend fun TelegramBot.editLiveLocation( - inlineMessageId: InlineMessageIdentifier, - location: LiveLocation, - replyMarkup: InlineKeyboardMarkup? = null -) = editLiveLocation(inlineMessageId, location, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt deleted file mode 100644 index 7b4c8c1138..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt +++ /dev/null @@ -1,43 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation -import dev.inmo.tgbotapi.requests.edit.location.live.StopChatMessageLiveLocation -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageIdentifier -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.content.LocationContent - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation")) -suspend fun TelegramBot.stopLiveLocation( - chatId: ChatIdentifier, - messageId: MessageIdentifier, - replyMarkup: InlineKeyboardMarkup? = null -) = stopLiveLocation(chatId, messageId, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation")) -suspend fun TelegramBot.stopLiveLocation( - chat: Chat, - messageId: MessageIdentifier, - replyMarkup: InlineKeyboardMarkup? = null -) = stopLiveLocation(chat, messageId, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation")) -suspend fun TelegramBot.stopLiveLocation( - message: ContentMessage, - replyMarkup: InlineKeyboardMarkup? = null -) = stopLiveLocation(message, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt deleted file mode 100644 index 12162cdee7..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation -import dev.inmo.tgbotapi.requests.edit.location.live.StopInlineMessageLiveLocation -import dev.inmo.tgbotapi.types.InlineMessageIdentifier -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation")) -suspend fun TelegramBot.stopLiveLocation( - inlineMessageId: InlineMessageIdentifier, - replyMarkup: InlineKeyboardMarkup? = null -) = stopLiveLocation(inlineMessageId, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt deleted file mode 100644 index e404c43612..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt +++ /dev/null @@ -1,42 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageIdentifier -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup")) -suspend fun TelegramBot.editMessageReplyMarkup( - chatId: ChatIdentifier, - messageId: MessageIdentifier, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageReplyMarkup(chatId, messageId, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup")) -suspend fun TelegramBot.editMessageReplyMarkup( - chat: Chat, - messageId: MessageIdentifier, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageReplyMarkup(chat, messageId, replyMarkup) - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup")) -suspend fun TelegramBot.editMessageReplyMarkup( - message: Message, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageReplyMarkup(message, replyMarkup) - diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt deleted file mode 100644 index 6b4e77a06c..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup -import dev.inmo.tgbotapi.requests.edit.reply_markup.EditInlineMessageReplyMarkup -import dev.inmo.tgbotapi.types.InlineMessageIdentifier -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup - -/** - * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] - * as a builder for that - */ -@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup")) -suspend fun TelegramBot.editMessageReplyMarkup( - inlineMessageId: InlineMessageIdentifier, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageReplyMarkup(inlineMessageId, replyMarkup) diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt index 89491b98b1..e090774496 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt @@ -13,9 +13,6 @@ import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow -@Deprecated("Will be removed soon") -typealias BehaviourContextWithFSMBuilder = BehaviourContextWithFSM - /** * Creates [BehaviourContextWithFSM] via creating of [DefaultBehaviourContext] with [this] as [TelegramBot], * [scope] as target scope for that [DefaultBehaviourContext] and [upstreamUpdatesFlow]. Pass [statesManager] diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/StateHandlingErrorHandler.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/StateHandlingErrorHandler.kt deleted file mode 100644 index 6688d81aca..0000000000 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/StateHandlingErrorHandler.kt +++ /dev/null @@ -1,10 +0,0 @@ -package dev.inmo.tgbotapi.extensions.behaviour_builder - -import dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler - -@Deprecated("Has been added in microutils", ReplaceWith("StateHandlingErrorHandler", "dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler")) -typealias StateHandlingErrorHandler = StateHandlingErrorHandler -@Deprecated("Has been added in microutils", ReplaceWith("DefaultStateHandlingErrorHandler", "dev.inmo.micro_utils.fsm.common.utils.DefaultStateHandlingErrorHandler")) -val DefaultStateHandlingErrorHandler = dev.inmo.micro_utils.fsm.common.utils.DefaultStateHandlingErrorHandler -@Deprecated("Has been added in microutils", ReplaceWith("defaultStateHandlingErrorHandler", "dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler")) -inline fun defaultStateHandlingErrorHandler() = dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler() diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index a1c5173def..9885da3d5a 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -80,7 +80,7 @@ class DefaultBehaviourContext( onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, private val upstreamUpdatesFlow: Flow? = null, override val triggersHolder: TriggersHolder = TriggersHolder(), - @Deprecated("This method is not used anymore") + @Deprecated("This parameter is not used anymore") private val updatesFilter: BehaviourContextAndTypeReceiver? = null ) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext { @@ -208,48 +208,6 @@ suspend fun BC.createSubContextAndDoWithUpdatesFilter ) } -/** - * Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context - * using [doInContext] - * - * @param stopOnCompletion ___TRUE BY DEFAULT___ - */ -@Deprecated("Renamed", ReplaceWith("createSubContextAndDoWithUpdatesFilter", "dev.inmo.tgbotapi.extensions.behaviour_builder.createSubContextAndDoWithUpdatesFilter")) -suspend fun BC.doInSubContextWithUpdatesFilter( - updatesFilter: CustomBehaviourContextAndTypeReceiver?, - stopOnCompletion: Boolean = true, - updatesUpstreamFlow: Flow = allUpdatesFlow, - scope: CoroutineScope = LinkedSupervisorScope(), - triggersHolder: TriggersHolder = this.triggersHolder, - behaviourContextReceiver: CustomBehaviourContextReceiver -): T { - return createSubContext( - scope, - triggersHolder, - updatesUpstreamFlow, - updatesFilter - ).doInContext( - stopOnCompletion, - behaviourContextReceiver - ) -} - -@Deprecated("Redundant", ReplaceWith("createSubContextAndDoWithUpdatesFilter", "dev.inmo.tgbotapi.extensions.behaviour_builder.createSubContextAndDoWithUpdatesFilter")) -suspend fun BehaviourContext.doInSubContext( - stopOnCompletion: Boolean = true, - updatesUpstreamFlow: Flow = allUpdatesFlow, - scope: CoroutineScope = LinkedSupervisorScope(), - triggersHolder: TriggersHolder = this.triggersHolder, - behaviourContextReceiver: BehaviourContextReceiver -) = createSubContextAndDoWithUpdatesFilter( - scope, - triggersHolder, - updatesUpstreamFlow, - updatesFilter = null, - stopOnCompletion, - behaviourContextReceiver -) - /** * This method will cancel ALL subsequent contexts, expectations and waiters */ diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 6a23a0952a..414fd7b4a1 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -45,26 +45,6 @@ suspend fun BehaviourContext.waitChatEvents( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEvents(initRequest, errorFactory) -@Deprecated("Renamed as Video instead of Voice") -suspend fun BehaviourContext.waitVoiceChatEvents( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null } -) = waitEvents(initRequest, errorFactory) -@Deprecated("Renamed as Video instead of Voice") -suspend fun BehaviourContext.waitVoiceChatStartedEvents( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null } -) = waitEvents(initRequest, errorFactory) -@Deprecated("Renamed as Video instead of Voice") -suspend fun BehaviourContext.waitVoiceChatEndedEvents( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null } -) = waitEvents(initRequest, errorFactory) -@Deprecated("Renamed as Video instead of Voice") -suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null } -) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoChatEvents( initRequest: Request<*>? = null, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt index 2df1b701d9..f01530cf21 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt @@ -43,27 +43,6 @@ suspend fun BehaviourContext.waitChatEventsMessages( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEventsMessages(initRequest, errorFactory) -@Deprecated("Renamed as Video instead of Voice") -suspend fun BehaviourContext.waitVoiceChatEventsMessages( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null } -) = waitEventsMessages(initRequest, errorFactory) -@Deprecated("Renamed as Video instead of Voice") -suspend fun BehaviourContext.waitVoiceChatStartedEventsMessages( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null } -) = waitEventsMessages(initRequest, errorFactory) -@Deprecated("Renamed as Video instead of Voice") -suspend fun BehaviourContext.waitVoiceChatEndedEventsMessages( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null } -) = waitEventsMessages(initRequest, errorFactory) -@Deprecated("Renamed as Video instead of Voice") -suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEventsMessages( - initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null } -) = waitEventsMessages(initRequest, errorFactory) - suspend fun BehaviourContext.waitVideoChatEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index ae1998941b..cde6ed010e 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -84,86 +84,6 @@ suspend fun BC.onChatEvent( scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) -/** - * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call - * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, - * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] - * to combinate several filters - * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously - * in one "stream". Output of [markerFactory] will be used as a key for "stream" - * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that - * data - */ -@Deprecated("Renamed as Video instead of Voice") -suspend fun BC.onVoiceChatEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> -) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - -/** - * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call - * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, - * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] - * to combinate several filters - * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously - * in one "stream". Output of [markerFactory] will be used as a key for "stream" - * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that - * data - */ -@Deprecated("Renamed as Video instead of Voice") -suspend fun BC.onVoiceChatStartedEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> -) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - -/** - * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call - * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, - * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] - * to combinate several filters - * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously - * in one "stream". Output of [markerFactory] will be used as a key for "stream" - * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that - * data - */ -@Deprecated("Renamed as Video instead of Voice") -suspend fun BC.onVoiceChatEndedEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> -) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - -/** - * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call - * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, - * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. - * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] - * to combinate several filters - * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously - * in one "stream". Output of [markerFactory] will be used as a key for "stream" - * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that - * data - */ -@Deprecated("Renamed as Video instead of Voice") -suspend fun BC.onVoiceChatParticipantsInvitedEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> -) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonContactData.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonContactData.kt deleted file mode 100644 index ed02d37445..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonContactData.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("CommonContactData", "dev.inmo.tgbotapi.abstracts.CommonContactData")) -typealias CommonContactData = dev.inmo.tgbotapi.abstracts.CommonContactData diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt deleted file mode 100644 index d4af30e79c..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonSendInvoiceData.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("CommonSendInvoiceData", "dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData")) -typealias CommonSendInvoiceData = dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonVenueData.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonVenueData.kt deleted file mode 100644 index 592f4e2c7d..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/CommonVenueData.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("CommonVenueData", "dev.inmo.tgbotapi.abstracts.CommonVenueData")) -typealias CommonVenueData = dev.inmo.tgbotapi.abstracts.CommonVenueData diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/FromUser.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/FromUser.kt deleted file mode 100644 index efaa1cfcca..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/FromUser.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("FromUser", "dev.inmo.tgbotapi.abstracts.FromUser")) -typealias FromUser = dev.inmo.tgbotapi.abstracts.FromUser diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Headed.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Headed.kt deleted file mode 100644 index 9aa8c2f7e7..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Headed.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("Headed", "dev.inmo.tgbotapi.abstracts.Headed")) -typealias Headed = dev.inmo.tgbotapi.abstracts.Headed diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/HorizontallyAccured.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/HorizontallyAccured.kt deleted file mode 100644 index c27098506b..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/HorizontallyAccured.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("HorizontallyAccured", "dev.inmo.tgbotapi.abstracts.HorizontallyAccured")) -typealias HorizontallyAccured = dev.inmo.tgbotapi.abstracts.HorizontallyAccured diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Livable.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Livable.kt deleted file mode 100644 index 3374272245..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Livable.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("Livable", "dev.inmo.tgbotapi.abstracts.Livable")) -typealias Livable = dev.inmo.tgbotapi.abstracts.Livable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Locationed.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Locationed.kt deleted file mode 100644 index 06600ff671..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Locationed.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("Locationed", "dev.inmo.tgbotapi.abstracts.Locationed")) -typealias Locationed = dev.inmo.tgbotapi.abstracts.Locationed diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/MimeTyped.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/MimeTyped.kt deleted file mode 100644 index 8f3388745f..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/MimeTyped.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("MimeTyped", "dev.inmo.tgbotapi.abstracts.MimeTyped")) -typealias MimeTyped = dev.inmo.tgbotapi.abstracts.MimeTyped diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Performerable.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Performerable.kt deleted file mode 100644 index b5a1ba3509..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Performerable.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("Performerable", "dev.inmo.tgbotapi.abstracts.Performerable")) -typealias Performerable = dev.inmo.tgbotapi.abstracts.Performerable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/ProximityAlertable.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/ProximityAlertable.kt deleted file mode 100644 index 7a9d37e444..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/ProximityAlertable.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("ProximityAlertable", "dev.inmo.tgbotapi.abstracts.ProximityAlertable")) -typealias ProximityAlertable = dev.inmo.tgbotapi.abstracts.ProximityAlertable 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 deleted file mode 100644 index 7d3621a155..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Texted.kt +++ /dev/null @@ -1,18 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("Texted", "dev.inmo.tgbotapi.abstracts.Texted")) -typealias Texted = dev.inmo.tgbotapi.abstracts.Texted -@Deprecated("Replaced", ReplaceWith("TextedWithTextSources", "dev.inmo.tgbotapi.abstracts.TextedWithTextSources")) -typealias TextedWithTextSources = dev.inmo.tgbotapi.abstracts.TextedWithTextSources - -@Deprecated("Replaced", ReplaceWith("ParsableOutput", "dev.inmo.tgbotapi.abstracts.ParsableOutput")) -typealias ParsableOutput = dev.inmo.tgbotapi.abstracts.ParsableOutput - -@Deprecated("Replaced", ReplaceWith("EntitiesOutput", "dev.inmo.tgbotapi.abstracts.EntitiesOutput")) -typealias EntitiesOutput = dev.inmo.tgbotapi.abstracts.EntitiesOutput - -@Deprecated("Replaced", ReplaceWith("TextedOutput", "dev.inmo.tgbotapi.abstracts.TextedOutput")) -typealias TextedOutput = dev.inmo.tgbotapi.abstracts.TextedOutput - -@Deprecated("Replaced", ReplaceWith("TextedInput", "dev.inmo.tgbotapi.abstracts.TextedInput")) -typealias TextedInput = dev.inmo.tgbotapi.abstracts.TextedInput diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Titled.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Titled.kt deleted file mode 100644 index ca20e0005a..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/Titled.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("Titled", "dev.inmo.tgbotapi.abstracts.Titled")) -typealias Titled = dev.inmo.tgbotapi.abstracts.Titled diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/WithUser.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/WithUser.kt deleted file mode 100644 index 224ed922c1..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/WithUser.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -@Deprecated("Replaced", ReplaceWith("WithUser", "dev.inmo.tgbotapi.abstracts.WithUser")) -typealias WithUser = dev.inmo.tgbotapi.abstracts.WithUser diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ChatRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ChatRequest.kt deleted file mode 100644 index 4ceeae3844..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ChatRequest.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("ChatRequest", "dev.inmo.tgbotapi.abstracts.types.ChatRequest")) -typealias ChatRequest = dev.inmo.tgbotapi.abstracts.types.ChatRequest diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/DisableNotification.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/DisableNotification.kt deleted file mode 100644 index adfc644e55..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/DisableNotification.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("DisableNotification", "dev.inmo.tgbotapi.abstracts.types.DisableNotification")) -typealias DisableNotification = dev.inmo.tgbotapi.abstracts.types.DisableNotification diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/DisableWebPagePreview.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/DisableWebPagePreview.kt deleted file mode 100644 index c990cef83d..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/DisableWebPagePreview.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("DisableWebPagePreview", "dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview")) -typealias DisableWebPagePreview = dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/InlineMessageAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/InlineMessageAction.kt deleted file mode 100644 index 0b327a755d..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/InlineMessageAction.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("InlineMessageAction", "dev.inmo.tgbotapi.abstracts.types.InlineMessageAction")) -typealias InlineMessageAction = dev.inmo.tgbotapi.abstracts.types.InlineMessageAction diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/MessageAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/MessageAction.kt deleted file mode 100644 index 16b237cff5..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/MessageAction.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("MessageAction:", "dev.inmo.tgbotapi.abstracts.types.MessageAction:")) -typealias MessageAction = dev.inmo.tgbotapi.abstracts.types.MessageAction diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/OptionalChatRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/OptionalChatRequest.kt deleted file mode 100644 index 674983e52c..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/OptionalChatRequest.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("OptionalChatRequest", "dev.inmo.tgbotapi.abstracts.types.OptionalChatRequest")) -typealias OptionalChatRequest = dev.inmo.tgbotapi.abstracts.types.OptionalChatRequest diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ProtectContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ProtectContent.kt deleted file mode 100644 index 9efa2c7653..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ProtectContent.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("ProtectContent", "dev.inmo.tgbotapi.abstracts.types.ProtectContent")) -typealias ProtectContent = dev.inmo.tgbotapi.abstracts.types.ProtectContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ReplyMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ReplyMarkup.kt deleted file mode 100644 index 8b373ac5ef..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ReplyMarkup.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("ReplyMarkup", "dev.inmo.tgbotapi.abstracts.types.ReplyMarkup")) -typealias ReplyMarkup = dev.inmo.tgbotapi.abstracts.types.ReplyMarkup diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ReplyMessageId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ReplyMessageId.kt deleted file mode 100644 index 661b05f841..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/ReplyMessageId.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("ReplyMessageId", "dev.inmo.tgbotapi.abstracts.types.ReplyMessageId")) -typealias ReplyMessageId = dev.inmo.tgbotapi.abstracts.types.ReplyMessageId diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/UntilDate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/UntilDate.kt deleted file mode 100644 index 317d8988b8..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/types/UntilDate.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts.types - -@Deprecated("Replaced", ReplaceWith("UntilDate", "dev.inmo.tgbotapi.abstracts.types.UntilDate")) -typealias UntilDate = dev.inmo.tgbotapi.abstracts.types.UntilDate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorCallFactory.kt deleted file mode 100644 index 27bfcd91a4..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorCallFactory.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.bot.Ktor - -@Deprecated("Replaced", ReplaceWith("KtorCallFactory", "dev.inmo.tgbotapi.bot.ktor.KtorCallFactory")) -typealias KtorCallFactory = dev.inmo.tgbotapi.bot.ktor.KtorCallFactory 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 deleted file mode 100644 index a0ffdf6d3c..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt +++ /dev/null @@ -1,32 +0,0 @@ -package dev.inmo.tgbotapi.bot.Ktor - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.utils.* - -@RiskFeature -@Deprecated("Replaced", ReplaceWith("createTelegramBotDefaultKtorCallRequestsFactories", "dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories")) -fun createTelegramBotDefaultKtorCallRequestsFactories() = dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories() - -@Deprecated("Replaced", ReplaceWith("KtorRequestsExecutor", "dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor")) -typealias KtorRequestsExecutor = dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor - -@Deprecated("Replaced", ReplaceWith("KtorRequestsExecutorBuilder", "dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder")) -typealias KtorRequestsExecutorBuilder = dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder - -@Deprecated("telegramBot", ReplaceWith("createTelegramBotDefaultKtorCallRequestsFactories", "dev.inmo.tgbotapi.bot.ktor.telegramBot")) -inline fun telegramBot( - telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, - builder: KtorRequestsExecutorBuilder.() -> Unit = {} -): TelegramBot = dev.inmo.tgbotapi.bot.ktor.telegramBot(telegramAPIUrlsKeeper, builder) - -/** - * Shortcut for [telegramBot] - */ -@Suppress("NOTHING_TO_INLINE") -@Deprecated("telegramBot", ReplaceWith("createTelegramBotDefaultKtorCallRequestsFactories", "dev.inmo.tgbotapi.bot.ktor.telegramBot")) -inline fun telegramBot( - token: String, - apiUrl: String = telegramBotAPIDefaultUrl, - testServer: Boolean = false, - builder: KtorRequestsExecutorBuilder.() -> Unit = {} -): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), builder) 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 deleted file mode 100644 index 370bc110e7..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/AbstractRequestCallFactory.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.inmo.tgbotapi.bot.Ktor.base - -var defaultUpdateTimeoutForZeroDelay = dev.inmo.tgbotapi.bot.ktor.base.defaultUpdateTimeoutForZeroDelay - -@Deprecated("Replaced", ReplaceWith("AbstractRequestCallFactory", "dev.inmo.tgbotapi.bot.ktor.base.AbstractRequestCallFactory")) -typealias AbstractRequestCallFactory = dev.inmo.tgbotapi.bot.ktor.base.AbstractRequestCallFactory diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt deleted file mode 100644 index 56534bc0ad..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.bot.Ktor.base - -@Deprecated("Replaced", ReplaceWith("DownloadFileChannelRequestCallFactory", "dev.inmo.tgbotapi.bot.ktor.base.DownloadFileRequestCallFactory")) -typealias DownloadFileChannelRequestCallFactory = dev.inmo.tgbotapi.bot.ktor.base.DownloadFileRequestCallFactory diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileRequestCallFactory.kt deleted file mode 100644 index 5eabacad94..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileRequestCallFactory.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.bot.Ktor.base - -@Deprecated("Replaced", ReplaceWith("DownloadFileRequestCallFactory", "dev.inmo.tgbotapi.bot.ktor.base.DownloadFileRequestCallFactory")) -typealias DownloadFileRequestCallFactory = dev.inmo.tgbotapi.bot.ktor.base.DownloadFileRequestCallFactory 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 deleted file mode 100644 index bc55fc3fd3..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.bot.Ktor.base - -@Deprecated("Replaced", ReplaceWith("MultipartRequestCallFactory", "dev.inmo.tgbotapi.bot.ktor.base.MultipartRequestCallFactory")) -typealias MultipartRequestCallFactory = dev.inmo.tgbotapi.bot.ktor.base.MultipartRequestCallFactory diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt deleted file mode 100644 index 56195671e8..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.bot.Ktor.base - -@Deprecated("Replaced", ReplaceWith("SimpleRequestCallFactory", "dev.inmo.tgbotapi.bot.ktor.base.SimpleRequestCallFactory")) -typealias SimpleRequestCallFactory = dev.inmo.tgbotapi.bot.ktor.base.SimpleRequestCallFactory diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt index 4a9cf1a557..afd6df3640 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt @@ -79,21 +79,8 @@ data class MultipartFile ( override val fileId: String = "${uuid4()}.${filename.fileExtension}" val input: Input get() = inputSource() - - @Deprecated("Storage file now is not necessary") - constructor( - file: StorageFile, - filename: String = file.fileName - ) : this( - filename, - file::input - ) } -@Deprecated("Storage file now is not necessary") -@Suppress("NOTHING_TO_INLINE", "unused") -inline fun StorageFile.asMultipartFile() = MultipartFile(fileName, ::input) - @Suppress("NOTHING_TO_INLINE", "unused") suspend inline fun ByteReadChannel.asMultipartFile( fileName: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt deleted file mode 100644 index f7e4a81997..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.requests.edit.LiveLocation - -@Deprecated("Replaced", ReplaceWith("editMessageLiveLocationMethod", "dev.inmo.tgbotapi.requests.edit.location.live.editMessageLiveLocationMethod")) -const val editMessageLiveLocationMethod = dev.inmo.tgbotapi.requests.edit.location.live.editMessageLiveLocationMethod - -@Deprecated("Replaced", ReplaceWith("EditChatMessageLiveLocation", "dev.inmo.tgbotapi.requests.edit.location.live.EditChatMessageLiveLocation")) -typealias EditChatMessageLiveLocation = dev.inmo.tgbotapi.requests.edit.location.live.EditChatMessageLiveLocation diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt deleted file mode 100644 index fe5af0dc52..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.requests.edit.LiveLocation - -@Deprecated("Replaced", ReplaceWith("EditInlineMessageLiveLocation", "dev.inmo.tgbotapi.requests.edit.location.live.EditInlineMessageLiveLocation")) -typealias EditInlineMessageLiveLocation = dev.inmo.tgbotapi.requests.edit.location.live.EditInlineMessageLiveLocation diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt deleted file mode 100644 index 076a246b0e..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.requests.edit.LiveLocation - -@Deprecated("Replaced", ReplaceWith("stopMessageLiveLocationMethod", "dev.inmo.tgbotapi.requests.edit.location.live.stopMessageLiveLocationMethod")) -const val stopMessageLiveLocationMethod = dev.inmo.tgbotapi.requests.edit.location.live.stopMessageLiveLocationMethod - -@Deprecated("Replaced", ReplaceWith("StopChatMessageLiveLocation", "dev.inmo.tgbotapi.requests.edit.location.live.StopChatMessageLiveLocation")) -typealias StopChatMessageLiveLocation = dev.inmo.tgbotapi.requests.edit.location.live.StopChatMessageLiveLocation diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt deleted file mode 100644 index 992f51bfe4..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.requests.edit.LiveLocation - -@Deprecated("Replaced", ReplaceWith("StopInlineMessageLiveLocation", "dev.inmo.tgbotapi.requests.edit.location.live.StopInlineMessageLiveLocation")) -typealias StopInlineMessageLiveLocation = dev.inmo.tgbotapi.requests.edit.location.live.StopInlineMessageLiveLocation diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt deleted file mode 100644 index 3fc96449ad..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.requests.edit.ReplyMarkup - -@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkupMethod", "dev.inmo.tgbotapi.requests.edit.reply_markup.editMessageReplyMarkupMethod")) -const val editMessageReplyMarkupMethod = dev.inmo.tgbotapi.requests.edit.reply_markup.editMessageReplyMarkupMethod - -@Deprecated("Replaced", ReplaceWith("EditChatMessageReplyMarkup", "dev.inmo.tgbotapi.requests.edit.reply_markup.EditChatMessageReplyMarkup")) -typealias EditChatMessageReplyMarkup = dev.inmo.tgbotapi.requests.edit.reply_markup.EditChatMessageReplyMarkup diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt deleted file mode 100644 index a5820c2301..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.requests.edit.ReplyMarkup - -@Deprecated("Replaced", ReplaceWith("EditInlineMessageReplyMarkup", "dev.inmo.tgbotapi.requests.edit.reply_markup.EditInlineMessageReplyMarkup")) -typealias EditInlineMessageReplyMarkup = dev.inmo.tgbotapi.requests.edit.reply_markup.EditInlineMessageReplyMarkup diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt deleted file mode 100644 index c5bcff1c70..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("CallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.CallbackQuery")) -typealias CallbackQuery = dev.inmo.tgbotapi.types.queries.callback.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("UnknownCallbackQueryType", "dev.inmo.tgbotapi.types.queries.callback.UnknownCallbackQueryType")) -typealias UnknownCallbackQueryType = dev.inmo.tgbotapi.types.queries.callback.UnknownCallbackQueryType diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt deleted file mode 100644 index 80152765da..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("DataCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery")) -typealias DataCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/GameShortNameCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/GameShortNameCallbackQuery.kt deleted file mode 100644 index a200ae40db..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/GameShortNameCallbackQuery.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("GameShortNameCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.GameShortNameCallbackQuery")) -typealias GameShortNameCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.GameShortNameCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdCallbackQuery.kt deleted file mode 100644 index 37eb7a8c69..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdCallbackQuery.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("InlineMessageIdCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery")) -typealias InlineMessageIdCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdDataCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdDataCallbackQuery.kt deleted file mode 100644 index 5d49e5bcb3..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdDataCallbackQuery.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("InlineMessageIdDataCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdDataCallbackQuery")) -typealias InlineMessageIdDataCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdDataCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdGameShortNameCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdGameShortNameCallbackQuery.kt deleted file mode 100644 index d133eb4a5f..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdGameShortNameCallbackQuery.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("InlineMessageIdGameShortNameCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdGameShortNameCallbackQuery")) -typealias InlineMessageIdGameShortNameCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdGameShortNameCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageCallbackQuery.kt deleted file mode 100644 index 07f1c2bf88..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageCallbackQuery.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("MessageCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.MessageCallbackQuery")) -typealias MessageCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.MessageCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageDataCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageDataCallbackQuery.kt deleted file mode 100644 index 10fa1bf4f7..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageDataCallbackQuery.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("MessageDataCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.MessageDataCallbackQuery")) -typealias MessageDataCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.MessageDataCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageGameShortNameCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageGameShortNameCallbackQuery.kt deleted file mode 100644 index ac2ce35f72..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageGameShortNameCallbackQuery.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.CallbackQuery - -@Deprecated("Replaced", ReplaceWith("MessageGameShortNameCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.MessageGameShortNameCallbackQuery")) -typealias MessageGameShortNameCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.MessageGameShortNameCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatAdministratorRightsImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatAdministratorRightsImpl.kt deleted file mode 100644 index 6f88f65b07..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatAdministratorRightsImpl.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types - -@Deprecated("Renamed", ReplaceWith("ChatAdministratorRightsImpl", "dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRightsImpl")) -typealias ChatAdministratorRightsImpl = dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRightsImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt deleted file mode 100644 index 5e30fbbe29..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember - -@Deprecated("AdministratorChatMemberImpl", ReplaceWith("AdministratorChatMemberImpl", "dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl")) -typealias AdministratorChatMemberImpl = dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt deleted file mode 100644 index 045772c3d3..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember - -@Deprecated("CreatorChatMember", ReplaceWith("CreatorChatMember", "dev.inmo.tgbotapi.types.chat.member.CreatorChatMember")) -typealias CreatorChatMember = dev.inmo.tgbotapi.types.chat.member.CreatorChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/KickedChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/KickedChatMember.kt deleted file mode 100644 index fd14d6cb5b..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/KickedChatMember.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember - -@Deprecated("KickedChatMember", ReplaceWith("KickedChatMember", "dev.inmo.tgbotapi.types.chat.member.KickedChatMember")) -typealias KickedChatMember = dev.inmo.tgbotapi.types.chat.member.KickedChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt deleted file mode 100644 index c14ceae383..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember - -@Deprecated("LeftChatMemberImpl", ReplaceWith("LeftChatMemberImpl", "dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl")) -typealias LeftChatMemberImpl = dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt deleted file mode 100644 index 2e1e6cef43..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember - -@Deprecated("MemberChatMemberImpl", ReplaceWith("MemberChatMemberImpl", "dev.inmo.tgbotapi.types.chat.member.MemberChatMemberImpl")) -typealias MemberChatMemberImpl = dev.inmo.tgbotapi.types.chat.member.MemberChatMemberImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/RestrictedChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/RestrictedChatMember.kt deleted file mode 100644 index ffd910bbba..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/RestrictedChatMember.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember - -@Deprecated("RestrictedChatMember", ReplaceWith("RestrictedChatMember", "dev.inmo.tgbotapi.types.chat.member.RestrictedChatMember")) -typealias RestrictedChatMember = dev.inmo.tgbotapi.types.chat.member.RestrictedChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt deleted file mode 100644 index 05cb4364dc..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember.abstracts - -@Deprecated("AdministratorChatMember", ReplaceWith("AdministratorChatMember", "dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember")) -typealias AdministratorChatMember = dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember - -@Deprecated("AdministratorChatMemberSerializer", ReplaceWith("AdministratorChatMemberSerializer", "dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberSerializer")) -typealias AdministratorChatMemberSerializer = dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberSerializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/BannedChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/BannedChatMember.kt deleted file mode 100644 index 6fd4f6867c..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/BannedChatMember.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember.abstracts - -@Deprecated("BannedChatMember", ReplaceWith("BannedChatMember", "dev.inmo.tgbotapi.types.chat.member.BannedChatMember")) -typealias BannedChatMember = dev.inmo.tgbotapi.types.chat.member.BannedChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatAdministratorRights.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatAdministratorRights.kt deleted file mode 100644 index 93c0cbc72a..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatAdministratorRights.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember.abstracts - -@Deprecated("SpecialChatAdministratorRights", ReplaceWith("SpecialChatAdministratorRights", "dev.inmo.tgbotapi.types.chat.member.SpecialChatAdministratorRights")) -typealias SpecialChatAdministratorRights = dev.inmo.tgbotapi.types.chat.member.SpecialChatAdministratorRights - -@Deprecated("ChatAdministratorRights", ReplaceWith("ChatAdministratorRights", "dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRights")) -typealias ChatAdministratorRights = dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRights diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt deleted file mode 100644 index 6498f6090d..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember.abstracts - -@Deprecated("ChatMember", ReplaceWith("ChatMember", "dev.inmo.tgbotapi.types.chat.member.ChatMember")) -typealias ChatMember = dev.inmo.tgbotapi.types.chat.member.ChatMember - -@Deprecated("ChatMemberSerializer", ReplaceWith("ChatMemberSerializer", "dev.inmo.tgbotapi.types.chat.member.ChatMemberSerializer")) -typealias ChatMemberSerializer = dev.inmo.tgbotapi.types.chat.member.ChatMemberSerializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/LeftChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/LeftChatMember.kt deleted file mode 100644 index 831545fe87..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/LeftChatMember.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember.abstracts - -@Deprecated("LeftChatMember", ReplaceWith("LeftChatMember", "dev.inmo.tgbotapi.types.chat.member.LeftChatMember")) -typealias LeftChatMember = dev.inmo.tgbotapi.types.chat.member.LeftChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/MemberChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/MemberChatMember.kt deleted file mode 100644 index 5885111058..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/MemberChatMember.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember.abstracts - -@Deprecated("MemberChatMember", ReplaceWith("MemberChatMember", "dev.inmo.tgbotapi.types.chat.member.MemberChatMember")) -typealias MemberChatMember = dev.inmo.tgbotapi.types.chat.member.MemberChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/SpecialRightsChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/SpecialRightsChatMember.kt deleted file mode 100644 index 0bf0cc79a3..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/SpecialRightsChatMember.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.ChatMember.abstracts - -@Deprecated("SpecialRightsChatMember", ReplaceWith("SpecialRightsChatMember", "dev.inmo.tgbotapi.types.chat.member.SpecialRightsChatMember")) -typealias SpecialRightsChatMember = dev.inmo.tgbotapi.types.chat.member.SpecialRightsChatMember 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 deleted file mode 100644 index cf81ce9cfa..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt +++ /dev/null @@ -1,39 +0,0 @@ -package dev.inmo.tgbotapi.types.InputMedia - -import dev.inmo.tgbotapi.requests.abstracts.InputFile -import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.message.toRawMessageEntities -import dev.inmo.tgbotapi.types.message.ParseMode -import dev.inmo.tgbotapi.types.media.TelegramMediaAnimation -import dev.inmo.tgbotapi.utils.extensions.makeString - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaAnimation", "dev.inmo.tgbotapi.types.media.TelegramMediaAnimation")) -fun InputMediaAnimation( - file: InputFile, - text: String? = null, - parseMode: ParseMode? = null, - width: Int? = null, - height: Int? = null, - duration: Long? = null, - thumb: InputFile? = null -) = TelegramMediaAnimation(file, text, parseMode, null, width, height, duration, thumb) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaAnimation", "dev.inmo.tgbotapi.types.media.TelegramMediaAnimation")) -fun InputMediaAnimation( - file: InputFile, - entities: TextSourcesList, - width: Int? = null, - height: Int? = null, - duration: Long? = null, - thumb: InputFile? = null -) = TelegramMediaAnimation( - file, - entities.makeString(), - null, - entities.toRawMessageEntities(), - width, - height, - duration, - thumb -) - diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt deleted file mode 100644 index 2d47d3a0cb..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt +++ /dev/null @@ -1,62 +0,0 @@ -package dev.inmo.tgbotapi.types.InputMedia - -import dev.inmo.tgbotapi.requests.abstracts.InputFile -import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.message.toRawMessageEntities -import dev.inmo.tgbotapi.types.message.ParseMode -import dev.inmo.tgbotapi.types.files.AudioFile -import dev.inmo.tgbotapi.types.media.TelegramMediaAudio -import dev.inmo.tgbotapi.utils.extensions.makeString - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaAudio", "dev.inmo.tgbotapi.types.media.TelegramMediaAudio")) -fun InputMediaAudio( - file: InputFile, - entities: TextSourcesList, - duration: Long? = null, - performer: String? = null, - title: String? = null, - thumb: InputFile? = null -) = TelegramMediaAudio( - file, entities.makeString(), null, entities.toRawMessageEntities(), duration, performer, title, thumb -) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaAudio", "dev.inmo.tgbotapi.types.media.TelegramMediaAudio")) -fun InputMediaAudio( - file: InputFile, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - performer: String? = null, - title: String? = null, - thumb: InputFile? = null -) = TelegramMediaAudio( - file, text, parseMode, null, duration, performer, title, thumb -) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaAudio", "dev.inmo.tgbotapi.types.media.TelegramMediaAudio")) -fun AudioFile.toInputMediaAudio( - text: String? = null, - parseMode: ParseMode? = null, - title: String? = this.title -): InputMediaAudio = TelegramMediaAudio( - fileId, - text, - parseMode, - duration, - performer, - title, - thumb ?.fileId -) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaAudio", "dev.inmo.tgbotapi.types.media.TelegramMediaAudio")) -fun AudioFile.toInputMediaAudio( - textSources: TextSourcesList = emptyList(), - title: String? = this.title -): InputMediaAudio = TelegramMediaAudio( - fileId, - textSources, - duration, - performer, - title, - thumb ?.fileId -) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt deleted file mode 100644 index 26410ef131..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt +++ /dev/null @@ -1,53 +0,0 @@ -package dev.inmo.tgbotapi.types.InputMedia - -import dev.inmo.tgbotapi.requests.abstracts.InputFile -import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.message.toRawMessageEntities -import dev.inmo.tgbotapi.types.message.ParseMode -import dev.inmo.tgbotapi.types.files.DocumentFile -import dev.inmo.tgbotapi.types.media.TelegramMediaDocument -import dev.inmo.tgbotapi.utils.extensions.makeString - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaDocument", "dev.inmo.tgbotapi.types.media.TelegramMediaDocument")) -fun InputMediaDocument( - file: InputFile, - text: String? = null, - parseMode: ParseMode? = null, - thumb: InputFile? = null, - disableContentTypeDetection: Boolean? = null -) = TelegramMediaDocument(file, text, parseMode, null, thumb, disableContentTypeDetection) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaDocument", "dev.inmo.tgbotapi.types.media.TelegramMediaDocument")) -fun InputMediaDocument( - file: InputFile, - entities: TextSourcesList, - thumb: InputFile? = null, - disableContentTypeDetection: Boolean? = null -) = TelegramMediaDocument( - file, - entities.makeString(), - null, - entities.toRawMessageEntities(), - thumb, - disableContentTypeDetection -) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaDocument", "dev.inmo.tgbotapi.types.media.TelegramMediaDocument")) -fun DocumentFile.toInputMediaDocument( - text: String? = null, - parseMode: ParseMode? = null -) = TelegramMediaDocument( - fileId, - text, - parseMode, - thumb ?.fileId -) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaDocument", "dev.inmo.tgbotapi.types.media.TelegramMediaDocument")) -fun DocumentFile.toInputMediaDocument( - textSources: TextSourcesList = emptyList() -) = TelegramMediaDocument( - fileId, - textSources, - thumb ?.fileId -) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt deleted file mode 100644 index d554eecbc7..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt +++ /dev/null @@ -1,40 +0,0 @@ -package dev.inmo.tgbotapi.types.InputMedia - -import dev.inmo.tgbotapi.requests.abstracts.InputFile -import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.message.toRawMessageEntities -import dev.inmo.tgbotapi.types.message.ParseMode -import dev.inmo.tgbotapi.types.files.PhotoSize -import dev.inmo.tgbotapi.types.media.TelegramMediaPhoto -import dev.inmo.tgbotapi.utils.extensions.makeString - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaPhoto", "dev.inmo.tgbotapi.types.media.TelegramMediaPhoto")) -fun InputMediaPhoto( - file: InputFile, - text: String? = null, - parseMode: ParseMode? = null -) = TelegramMediaPhoto(file, text, parseMode, null) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaPhoto", "dev.inmo.tgbotapi.types.media.TelegramMediaPhoto")) -fun InputMediaPhoto( - file: InputFile, - entities: TextSourcesList -) = TelegramMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities()) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaPhoto", "dev.inmo.tgbotapi.types.media.TelegramMediaPhoto")) -fun PhotoSize.toInputMediaPhoto( - text: String? = null, - parseMode: ParseMode? = null -): InputMediaPhoto = TelegramMediaPhoto( - fileId, - text, - parseMode -) - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaPhoto", "dev.inmo.tgbotapi.types.media.TelegramMediaPhoto")) -fun PhotoSize.toInputMediaPhoto( - textSources: TextSourcesList = emptyList() -): InputMediaPhoto = TelegramMediaPhoto( - fileId, - textSources -) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt deleted file mode 100644 index 64d64d8a39..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt +++ /dev/null @@ -1,28 +0,0 @@ -package dev.inmo.tgbotapi.types.InputMedia - -import dev.inmo.tgbotapi.requests.abstracts.InputFile -import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.message.toRawMessageEntities -import dev.inmo.tgbotapi.types.message.ParseMode -import dev.inmo.tgbotapi.types.media.TelegramMediaVideo -import dev.inmo.tgbotapi.utils.extensions.makeString - -@Deprecated("Replaced and renamed", ReplaceWith("TelegramMediaVideo", "dev.inmo.tgbotapi.types.media.TelegramMediaVideo")) -fun InputMediaVideo( - file: InputFile, - text: String? = null, - parseMode: ParseMode? = null, - width: Int? = null, - height: Int? = null, - duration: Long? = null, - thumb: InputFile? = null -) = TelegramMediaVideo(file, text, parseMode, null, width, height, duration, thumb) - -fun InputMediaVideo( - file: InputFile, - entities: TextSourcesList, - width: Int? = null, - height: Int? = null, - duration: Long? = null, - thumb: InputFile? = null -) = TelegramMediaVideo(file, entities.makeString(), null, entities.toRawMessageEntities(), width, height, duration, thumb) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/Typealiases.kt deleted file mode 100644 index dee16d09fa..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/Typealiases.kt +++ /dev/null @@ -1,34 +0,0 @@ -package dev.inmo.tgbotapi.types.InputMedia - -@Deprecated("Replaced and renamed", ReplaceWith("DuratedInputMedia", "dev.inmo.tgbotapi.types.media.DuratedInputMedia")) -typealias DuratedInputMedia = dev.inmo.tgbotapi.types.media.DuratedTelegramMedia -@Deprecated("Replaced and renamed", ReplaceWith("InputMedia", "dev.inmo.tgbotapi.types.media.InputMedia")) -typealias InputMedia = dev.inmo.tgbotapi.types.media.TelegramMedia -@Deprecated("Replaced and renamed", ReplaceWith("InputMediaAnimation", "dev.inmo.tgbotapi.types.media.InputMediaAnimation")) -typealias InputMediaAnimation = dev.inmo.tgbotapi.types.media.TelegramMediaAnimation -@Deprecated("Replaced and renamed", ReplaceWith("InputMediaAudio", "dev.inmo.tgbotapi.types.media.InputMediaAudio")) -typealias InputMediaAudio = dev.inmo.tgbotapi.types.media.TelegramMediaAudio -@Deprecated("Replaced and renamed", ReplaceWith("InputMediaDocument", "dev.inmo.tgbotapi.types.media.InputMediaDocument")) -typealias InputMediaDocument = dev.inmo.tgbotapi.types.media.TelegramMediaDocument -@Deprecated("Replaced and renamed", ReplaceWith("InputMediaPhoto", "dev.inmo.tgbotapi.types.media.InputMediaPhoto")) -typealias InputMediaPhoto = dev.inmo.tgbotapi.types.media.TelegramMediaPhoto -@Deprecated("Replaced and renamed", ReplaceWith("InputMediaSerializer", "dev.inmo.tgbotapi.types.media.InputMediaSerializer")) -typealias InputMediaSerializer = dev.inmo.tgbotapi.types.media.TelegramMediaSerializer -@Deprecated("Replaced and renamed", ReplaceWith("InputMediaVideo", "dev.inmo.tgbotapi.types.media.InputMediaVideo")) -typealias InputMediaVideo = dev.inmo.tgbotapi.types.media.TelegramMediaVideo -@Deprecated("Replaced and renamed", ReplaceWith("MediaGroupMemberInputMedia", "dev.inmo.tgbotapi.types.media.MediaGroupMemberInputMedia")) -typealias MediaGroupMemberInputMedia = dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia -@Deprecated("Replaced and renamed", ReplaceWith("AudioMediaGroupMemberInputMedia", "dev.inmo.tgbotapi.types.media.AudioMediaGroupMemberInputMedia")) -typealias AudioMediaGroupMemberInputMedia = dev.inmo.tgbotapi.types.media.AudioMediaGroupMemberTelegramMedia -@Deprecated("Replaced and renamed", ReplaceWith("DocumentMediaGroupMemberInputMedia", "dev.inmo.tgbotapi.types.media.DocumentMediaGroupMemberInputMedia")) -typealias DocumentMediaGroupMemberInputMedia = dev.inmo.tgbotapi.types.media.DocumentMediaGroupMemberTelegramMedia -@Deprecated("Replaced and renamed", ReplaceWith("VisualMediaGroupMemberInputMedia", "dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberInputMedia")) -typealias VisualMediaGroupMemberInputMedia = dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia -@Deprecated("Replaced and renamed", ReplaceWith("MediaGroupMemberInputMediaSerializer", "dev.inmo.tgbotapi.types.media.MediaGroupMemberInputMediaSerializer")) -typealias MediaGroupMemberInputMediaSerializer = dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMediaSerializer -@Deprecated("Replaced and renamed", ReplaceWith("ThumbedInputMedia", "dev.inmo.tgbotapi.types.media.ThumbedInputMedia")) -typealias ThumbedInputMedia = dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia -@Deprecated("Replaced and renamed", ReplaceWith("SizedInputMedia", "dev.inmo.tgbotapi.types.media.SizedInputMedia")) -typealias SizedInputMedia = dev.inmo.tgbotapi.types.media.SizedTelegramMedia -@Deprecated("Replaced and renamed", ReplaceWith("TitledInputMedia", "dev.inmo.tgbotapi.types.media.TitledInputMedia")) -typealias TitledInputMedia = dev.inmo.tgbotapi.types.media.TitledTelegramMedia diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RemoveLeading.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RemoveLeading.kt deleted file mode 100644 index 31b76cf1ce..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RemoveLeading.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity - -@Deprecated("Redundant and will be removed soon") -fun String.removeLeading(word: String) = if (startsWith(word)) { - substring(word.length) -} else { - this -} 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 deleted file mode 100644 index 435a74e5e1..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see bold - */ -@Deprecated("Replaced", ReplaceWith("BoldTextSource", "dev.inmo.tgbotapi.types.message.textsources.BoldTextSource")) -typealias BoldTextSource = dev.inmo.tgbotapi.types.message.textsources.BoldTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("bold", "dev.inmo.tgbotapi.types.message.textsources.bold")) -inline fun bold(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.bold(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("bold", "dev.inmo.tgbotapi.types.message.textsources.bold")) -inline fun bold(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.bold(*parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("bold", "dev.inmo.tgbotapi.types.message.textsources.bold")) -inline fun bold(text: String) = dev.inmo.tgbotapi.types.message.textsources.bold(text) 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 deleted file mode 100644 index 1abdc2e068..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt +++ /dev/null @@ -1,16 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -private val commandRegex = Regex("[/!][^@\\s]*") - -/** - * @see botCommand - */ -@Deprecated("Replaced", ReplaceWith("BotCommandTextSource", "dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource")) -typealias BotCommandTextSource = dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource - -/** - * @param command Without leading "/" - */ -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("botCommand", "dev.inmo.tgbotapi.types.message.textsources.botCommand")) -inline fun botCommand(command: String) = dev.inmo.tgbotapi.types.message.textsources.botCommand(command) 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 deleted file mode 100644 index a6f9d1a0f7..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see cashTag - */ -@Deprecated("Replaced", ReplaceWith("CashTagTextSource", "dev.inmo.tgbotapi.types.message.textsources.CashTagTextSource")) -typealias CashTagTextSource = dev.inmo.tgbotapi.types.message.textsources.CashTagTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("cashTag", "dev.inmo.tgbotapi.types.message.textsources.cashTag")) -inline fun cashTag(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.cashTag(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("cashTag", "dev.inmo.tgbotapi.types.message.textsources.cashTag")) -inline fun cashTag(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.cashTag(*parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("cashTag", "dev.inmo.tgbotapi.types.message.textsources.cashTag")) -inline fun cashTag(tag: String) = dev.inmo.tgbotapi.types.message.textsources.cashTag(tag) 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 deleted file mode 100644 index 96f39ce223..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.utils.internal.code - -/** - * @see code - */ -@Deprecated("Replaced", ReplaceWith("CodeTextSource", "dev.inmo.tgbotapi.types.message.textsources.CodeTextSource")) -typealias CodeTextSource = dev.inmo.tgbotapi.types.message.textsources.CodeTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("code", "dev.inmo.tgbotapi.types.message.textsources.code")) -inline fun code(code: String) = dev.inmo.tgbotapi.types.message.textsources.code(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 deleted file mode 100644 index 18842eb8da..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see email - */ -@Deprecated("Replaced", ReplaceWith("EMailTextSource", "dev.inmo.tgbotapi.types.message.textsources.EMailTextSource")) -typealias EMailTextSource = dev.inmo.tgbotapi.types.message.textsources.EMailTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("email", "dev.inmo.tgbotapi.types.message.textsources.email")) -inline fun email(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.email(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("email", "dev.inmo.tgbotapi.types.message.textsources.email")) -inline fun email(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.email(*parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("email", "dev.inmo.tgbotapi.types.message.textsources.email")) -inline fun email(emailAddress: String) = dev.inmo.tgbotapi.types.message.textsources.email(emailAddress) 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 deleted file mode 100644 index d9aaeb9878..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt +++ /dev/null @@ -1,20 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see hashtag - */ -@Deprecated("Replaced", ReplaceWith("HashTagTextSource", "dev.inmo.tgbotapi.types.message.textsources.HashTagTextSource")) -typealias HashTagTextSource = dev.inmo.tgbotapi.types.message.textsources.HashTagTextSource - -@Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_API_USAGE") -@Deprecated("Replaced", ReplaceWith("hashtag", "dev.inmo.tgbotapi.types.message.textsources.hashtag")) -inline fun hashtag(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.hashtag(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("hashtag", "dev.inmo.tgbotapi.types.message.textsources.hashtag")) -inline fun hashtag(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.hashtag(*parts) -/** - * Without sharp (#) - */ -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("hashtag", "dev.inmo.tgbotapi.types.message.textsources.hashtag")) -inline fun hashtag(hashtag: String) = dev.inmo.tgbotapi.types.message.textsources.hashtag(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 deleted file mode 100644 index 7c5aeea699..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt +++ /dev/null @@ -1,18 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see italic - */ -@Deprecated("Replaced", ReplaceWith("ItalicTextSource", "dev.inmo.tgbotapi.types.message.textsources.ItalicTextSource")) -typealias ItalicTextSource = dev.inmo.tgbotapi.types.message.textsources.ItalicTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("italic", "dev.inmo.tgbotapi.types.message.textsources.italic")) -inline fun italic(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.italic(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("italic", "dev.inmo.tgbotapi.types.message.textsources.italic")) -inline fun italic(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.italic(*parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("italic", "dev.inmo.tgbotapi.types.message.textsources.italic")) -inline fun italic(text: String) = dev.inmo.tgbotapi.types.message.textsources.italic(text) - 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 deleted file mode 100644 index e783e2b76e..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt +++ /dev/null @@ -1,28 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.types.Username - -/** - * @see mention - */ -@Deprecated("Replaced", ReplaceWith("MentionTextSource", "dev.inmo.tgbotapi.types.message.textsources.MentionTextSource")) -typealias MentionTextSource = dev.inmo.tgbotapi.types.message.textsources.MentionTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.mention(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.mention(*parts) - -/** - * Without leading "@" - */ -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(whoToMention: String) = dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention) - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(whoToMention: Username) = dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention) - 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 deleted file mode 100644 index 5f3c780fdd..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt +++ /dev/null @@ -1,18 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see phone - */ -@Deprecated("Replaced", ReplaceWith("PhoneNumberTextSource", "dev.inmo.tgbotapi.types.message.textsources.PhoneNumberTextSource")) -typealias PhoneNumberTextSource = dev.inmo.tgbotapi.types.message.textsources.PhoneNumberTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("phone", "dev.inmo.tgbotapi.types.message.textsources.phone")) -inline fun phone(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.phone(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("phone", "dev.inmo.tgbotapi.types.message.textsources.phone")) -inline fun phone(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.phone(*parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("phone", "dev.inmo.tgbotapi.types.message.textsources.phone")) -inline fun phone(number: String) = dev.inmo.tgbotapi.types.message.textsources.phone(number) - 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 deleted file mode 100644 index bd9e06a7c2..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt +++ /dev/null @@ -1,12 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see pre - */ -@Deprecated("Replaced", ReplaceWith("PreTextSource", "dev.inmo.tgbotapi.types.message.textsources.PreTextSource")) -typealias PreTextSource = dev.inmo.tgbotapi.types.message.textsources.PreTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("pre", "dev.inmo.tgbotapi.types.message.textsources.pre")) -inline fun pre(code: String, language: String? = null) = dev.inmo.tgbotapi.types.message.textsources.pre(code, language) - 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 deleted file mode 100644 index 28b73c2263..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt +++ /dev/null @@ -1,11 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see regular - */ -@Deprecated("Replaced", ReplaceWith("RegularTextSource", "dev.inmo.tgbotapi.types.message.textsources.RegularTextSource")) -typealias RegularTextSource = dev.inmo.tgbotapi.types.message.textsources.RegularTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("regular", "dev.inmo.tgbotapi.types.message.textsources.regular")) -inline fun regular(text: String) = dev.inmo.tgbotapi.types.message.textsources.regular(text) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/SpoilerTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/SpoilerTextSource.kt deleted file mode 100644 index df3dc56f86..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/SpoilerTextSource.kt +++ /dev/null @@ -1,18 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see italic - */ -@Deprecated("Replaced", ReplaceWith("SpoilerTextSource", "dev.inmo.tgbotapi.types.message.textsources.SpoilerTextSource")) -typealias SpoilerTextSource = dev.inmo.tgbotapi.types.message.textsources.SpoilerTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("spoiler", "dev.inmo.tgbotapi.types.message.textsources.spoiler")) -inline fun spoiler(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.spoiler(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("spoiler", "dev.inmo.tgbotapi.types.message.textsources.spoiler")) -inline fun spoiler(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.spoiler(*parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("spoiler", "dev.inmo.tgbotapi.types.message.textsources.spoiler")) -inline fun spoiler(text: String) = dev.inmo.tgbotapi.types.message.textsources.spoiler(text) - 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 deleted file mode 100644 index ae87e43d53..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -/** - * @see strikethrough - */ -@Deprecated("Replaced", ReplaceWith("StrikethroughTextSource", "dev.inmo.tgbotapi.types.message.textsources.StrikethroughTextSource")) -typealias StrikethroughTextSource = dev.inmo.tgbotapi.types.message.textsources.StrikethroughTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("strikethrough", "dev.inmo.tgbotapi.types.message.textsources.strikethrough")) -inline fun strikethrough(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.strikethrough(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("strikethrough", "dev.inmo.tgbotapi.types.message.textsources.strikethrough")) -inline fun strikethrough(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.strikethrough(*parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("strikethrough", "dev.inmo.tgbotapi.types.message.textsources.strikethrough")) -inline fun strikethrough(text: String) = dev.inmo.tgbotapi.types.message.textsources.strikethrough(text) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt deleted file mode 100644 index ce2e734880..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.utils.internal.link - -/** - * @see link - */ -@Deprecated("Replaced", ReplaceWith("TextLinkTextSource", "dev.inmo.tgbotapi.types.message.textsources.TextLinkTextSource")) -typealias TextLinkTextSource = dev.inmo.tgbotapi.types.message.textsources.TextLinkTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("link", "dev.inmo.tgbotapi.types.message.textsources.link")) -inline fun link(text: String, url: String) = dev.inmo.tgbotapi.types.message.textsources.link(text, url) 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 deleted file mode 100644 index 772a6dffe8..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt +++ /dev/null @@ -1,51 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.types.Identifier -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.chat.User -import dev.inmo.tgbotapi.types.message.textsources.mention - -/** - * @see mention - */ -@Deprecated("Replaced", ReplaceWith("TextMentionTextSource", "dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource")) -typealias TextMentionTextSource = dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(parts: TextSourcesList, user: User) = mention(parts, user) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("User.mention", "dev.inmo.tgbotapi.types.message.textsources.User.mention")) -inline fun User.mention(parts: TextSourcesList) = mention(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(parts: TextSourcesList, userId: UserId) = mention(parts, userId) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("UserId.mention", "dev.inmo.tgbotapi.types.message.textsources.UserId.mention")) -inline fun UserId.mention(parts: TextSourcesList) = mention(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(parts: TextSourcesList, id: Identifier) = mention(parts, id) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("Identifier.mention", "dev.inmo.tgbotapi.types.message.textsources.Identifier.mention")) -inline fun Identifier.mention(parts: TextSourcesList) = mention(parts) -@Suppress("NOTHING_TO_INLINE") -inline fun mention(user: User, vararg parts: TextSource) = mention(user, *parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(text: String, user: User) = mention(text, user) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("User.mention", "dev.inmo.tgbotapi.types.message.textsources.User.mention")) -inline fun User.mention(text: String) = mention(text) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(text: String, userId: UserId) = mention(text, userId) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("UserId.mention", "dev.inmo.tgbotapi.types.message.textsources.UserId.mention")) -inline fun UserId.mention(text: String) = mention(text) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("mention", "dev.inmo.tgbotapi.types.message.textsources.mention")) -inline fun mention(text: String, id: Identifier) = mention(text, id) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("Identifier.mention", "dev.inmo.tgbotapi.types.message.textsources.Identifier.mention")) -inline fun Identifier.mention(text: String) = mention(text) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt deleted file mode 100644 index 3f3776347e..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt +++ /dev/null @@ -1,50 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.types.captionLength -import dev.inmo.tgbotapi.types.message.textsources.separateForCaption -import dev.inmo.tgbotapi.types.message.textsources.separateForMessage -import dev.inmo.tgbotapi.types.message.textsources.separateForText -import dev.inmo.tgbotapi.types.textLength - -const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods" - -@Deprecated("Replaced", ReplaceWith("TextSourcesList", "dev.inmo.tgbotapi.types.message.textsources.TextSourcesList")) -typealias TextSourcesList = dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -@Deprecated("Replaced", ReplaceWith("MutableTextSourcesList", "dev.inmo.tgbotapi.types.message.textsources.MutableTextSourcesList")) -typealias MutableTextSourcesList = dev.inmo.tgbotapi.types.message.textsources.MutableTextSourcesList - -@Deprecated("Replaced", ReplaceWith("TextSource", "dev.inmo.tgbotapi.types.message.textsources.TextSource")) -typealias TextSource = dev.inmo.tgbotapi.types.message.textsources.TextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.message.textsources.plus")) -inline operator fun TextSource.plus(other: TextSource) = listOf(this, other) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.message.textsources.plus")) -inline operator fun TextSource.plus(other: List) = listOf(this) + other -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.message.textsources.plus")) -inline operator fun TextSource.plus(text: String) = listOf(this, regular(text)) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.message.textsources.plus")) -inline operator fun List.plus(text: String) = this + regular(text) - -@Deprecated("Replaced", ReplaceWith("MultilevelTextSource", "dev.inmo.tgbotapi.types.message.textsources.MultilevelTextSource")) -typealias MultilevelTextSource = dev.inmo.tgbotapi.types.message.textsources.MultilevelTextSource - -@Deprecated("Replaced", ReplaceWith("separateForMessage", "dev.inmo.tgbotapi.types.message.textsources.separateForMessage")) -inline fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null) = separateForMessage(limit, numberOfParts) - -/** - * This method will prepare [TextSource]s list for messages. Remember, that first part will be separated with - * [captionLength] and all others with - */ -@Deprecated("Replaced", ReplaceWith("separateForCaption", "dev.inmo.tgbotapi.types.message.textsources.separateForCaption")) -fun List.separateForCaption() = separateForCaption() - -/** - * This method will prepare [TextSource]s list for messages with [textLength] - */ -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("separateForText", "dev.inmo.tgbotapi.types.message.textsources.separateForText")) -inline fun List.separateForText() = separateForText() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt deleted file mode 100644 index b15efad0be..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourceSerializer.kt +++ /dev/null @@ -1,5 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.types.message.textsources.TextSourceSerializer - -val TextSourceSerializer = TextSourceSerializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourcesOrElse.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourcesOrElse.kt deleted file mode 100644 index 3fc73e7919..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSourcesOrElse.kt +++ /dev/null @@ -1,15 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.utils.RiskFeature - -@RiskFeature -inline fun textSourcesOrElse( - textSources: TextSourcesList, - block: () -> TextSourcesList -) = dev.inmo.tgbotapi.types.message.textsources.textSourcesOrElse(textSources, block) - -@RiskFeature -inline fun textSourcesOrElseTextSource( - textSources: TextSourcesList, - block: () -> TextSource -) = dev.inmo.tgbotapi.types.message.textsources.textSourcesOrElseTextSource(textSources, block) 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 deleted file mode 100644 index f27222bb75..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.utils.internal.link - -/** - * @see link - */ -@Deprecated("Replaced", ReplaceWith("URLTextSource", "dev.inmo.tgbotapi.types.message.textsources.URLTextSource")) -typealias URLTextSource = dev.inmo.tgbotapi.types.message.textsources.URLTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("link", "dev.inmo.tgbotapi.types.message.textsources.link")) -inline fun link(url: String) = dev.inmo.tgbotapi.types.message.textsources.link(url) 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 deleted file mode 100644 index def733b371..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt +++ /dev/null @@ -1,19 +0,0 @@ -package dev.inmo.tgbotapi.types.MessageEntity.textsources - -import dev.inmo.tgbotapi.utils.internal.underline - -/** - * @see underline - */ -@Deprecated("Replaced", ReplaceWith("UnderlineTextSource", "dev.inmo.tgbotapi.types.message.textsources.UnderlineTextSource")) -typealias UnderlineTextSource = dev.inmo.tgbotapi.types.message.textsources.UnderlineTextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("underline", "dev.inmo.tgbotapi.types.message.textsources.underline")) -inline fun underline(parts: TextSourcesList) = dev.inmo.tgbotapi.types.message.textsources.underline(parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("underline", "dev.inmo.tgbotapi.types.message.textsources.underline")) -inline fun underline(vararg parts: TextSource) = dev.inmo.tgbotapi.types.message.textsources.underline(*parts) -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("underline", "dev.inmo.tgbotapi.types.message.textsources.underline")) -inline fun underline(text: String) = dev.inmo.tgbotapi.types.message.textsources.underline(text) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt deleted file mode 100644 index 926ff79322..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt +++ /dev/null @@ -1,31 +0,0 @@ -package dev.inmo.tgbotapi.types.ParseMode - -@Deprecated("Replaced", ReplaceWith("ParseMode", "dev.inmo.tgbotapi.types.message.ParseMode")) -typealias ParseMode = dev.inmo.tgbotapi.types.message.ParseMode - -@Deprecated("Replaced", ReplaceWith("MarkdownParseMode", "dev.inmo.tgbotapi.types.message.MarkdownParseMode")) -typealias MarkdownParseMode = dev.inmo.tgbotapi.types.message.MarkdownParseMode - -@Deprecated("Replaced", ReplaceWith("MarkdownV2ParseMode", "dev.inmo.tgbotapi.types.message.MarkdownV2ParseMode")) -typealias MarkdownV2ParseMode = dev.inmo.tgbotapi.types.message.MarkdownV2ParseMode -@Deprecated("Replaced", ReplaceWith("HTMLParseMode", "dev.inmo.tgbotapi.types.message.HTMLParseMode")) -typealias HTMLParseMode = dev.inmo.tgbotapi.types.message.HTMLParseMode - -@Deprecated("Replaced", ReplaceWith("Markdown", "dev.inmo.tgbotapi.types.message.Markdown")) -typealias Markdown = dev.inmo.tgbotapi.types.message.Markdown -@Deprecated("Replaced", ReplaceWith("MarkdownV2", "dev.inmo.tgbotapi.types.message.MarkdownV2")) -typealias MarkdownV2 = dev.inmo.tgbotapi.types.message.MarkdownV2 -@Deprecated("Replaced", ReplaceWith("HTML", "dev.inmo.tgbotapi.types.message.HTML")) -typealias HTML = dev.inmo.tgbotapi.types.message.HTML - -/** - * This variable respects to default parse mode used in places like next: - * - * * [dev.inmo.tgbotapi.types.message.content.TextContent.createResends] - * * - */ -@Deprecated("Replaced", ReplaceWith("defaultParseMode", "dev.inmo.tgbotapi.types.message.defaultParseMode")) -var defaultParseMode = dev.inmo.tgbotapi.types.message.defaultParseMode - -@Deprecated("Replaced", ReplaceWith("ParseModeSerializer", "dev.inmo.tgbotapi.types.message.ParseModeSerializer")) -typealias ParseModeSerializer = dev.inmo.tgbotapi.types.message.ParseModeSerializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/User.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/User.kt deleted file mode 100644 index 3a4f3f2cfd..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/User.kt +++ /dev/null @@ -1,22 +0,0 @@ -package dev.inmo.tgbotapi.types - -@Deprecated("Replaced", ReplaceWith("User", "dev.inmo.tgbotapi.types.chat.User")) -typealias User = dev.inmo.tgbotapi.types.chat.User - -@Deprecated("Replaced", ReplaceWith("CommonUser", "dev.inmo.tgbotapi.types.chat.CommonUser")) -typealias CommonUser = dev.inmo.tgbotapi.types.chat.CommonUser - -@Deprecated("Replaced", ReplaceWith("ExtendedUser", "dev.inmo.tgbotapi.types.chat.ExtendedUser")) -typealias ExtendedUser = dev.inmo.tgbotapi.types.chat.ExtendedUser - -@Deprecated("Replaced", ReplaceWith("Bot", "dev.inmo.tgbotapi.types.chat.Bot")) -typealias Bot = dev.inmo.tgbotapi.types.chat.Bot - -@Deprecated("Replaced", ReplaceWith("CommonBot", "dev.inmo.tgbotapi.types.chat.CommonBot")) -typealias CommonBot = dev.inmo.tgbotapi.types.chat.CommonBot - -@Deprecated("Replaced", ReplaceWith("ExtendedBot", "dev.inmo.tgbotapi.types.chat.ExtendedBot")) -typealias ExtendedBot = dev.inmo.tgbotapi.types.chat.ExtendedBot - -@Deprecated("Replaced", ReplaceWith("UserSerializer", "dev.inmo.tgbotapi.types.chat.UserSerializer")) -typealias UserSerializer = dev.inmo.tgbotapi.types.chat.UserSerializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/Typealiases.kt deleted file mode 100644 index 5ddd62c421..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/Typealiases.kt +++ /dev/null @@ -1,25 +0,0 @@ -package dev.inmo.tgbotapi.types.chat.abstracts - -@Deprecated("Replaced", ReplaceWith("ChannelChat", "dev.inmo.tgbotapi.types.chat.ChannelChat")) -typealias ChannelChat = dev.inmo.tgbotapi.types.chat.ChannelChat - -@Deprecated("Replaced", ReplaceWith("GroupChat", "dev.inmo.tgbotapi.types.chat.GroupChat")) -typealias GroupChat = dev.inmo.tgbotapi.types.chat.GroupChat - -@Deprecated("Replaced", ReplaceWith("PrivateChat", "dev.inmo.tgbotapi.types.chat.PrivateChat")) -typealias PrivateChat = dev.inmo.tgbotapi.types.chat.PrivateChat - -@Deprecated("Replaced", ReplaceWith("PublicChat", "dev.inmo.tgbotapi.types.chat.PublicChat")) -typealias PublicChat = dev.inmo.tgbotapi.types.chat.PublicChat - -@Deprecated("Replaced", ReplaceWith("SupergroupChat", "dev.inmo.tgbotapi.types.chat.SupergroupChat")) -typealias SupergroupChat = dev.inmo.tgbotapi.types.chat.SupergroupChat - -@Deprecated("Replaced", ReplaceWith("SuperPublicChat", "dev.inmo.tgbotapi.types.chat.SuperPublicChat")) -typealias SuperPublicChat = dev.inmo.tgbotapi.types.chat.SuperPublicChat - -@Deprecated("Replaced", ReplaceWith("UsernameChat", "dev.inmo.tgbotapi.types.chat.UsernameChat")) -typealias UsernameChat = dev.inmo.tgbotapi.types.chat.UsernameChat - -@Deprecated("Replaced", ReplaceWith("Chat", "dev.inmo.tgbotapi.types.chat.Chat")) -typealias Chat = dev.inmo.tgbotapi.types.chat.Chat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/extended/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/extended/Typealiases.kt deleted file mode 100644 index a520dbad34..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/abstracts/extended/Typealiases.kt +++ /dev/null @@ -1,19 +0,0 @@ -package dev.inmo.tgbotapi.types.chat.abstracts.extended - -@Deprecated("Replaced", ReplaceWith("ExtendedChannelChat", "dev.inmo.tgbotapi.types.chat.ExtendedChannelChat")) -typealias ExtendedChannelChat = dev.inmo.tgbotapi.types.chat.ExtendedChannelChat - -@Deprecated("Replaced", ReplaceWith("ExtendedGroupChat", "dev.inmo.tgbotapi.types.chat.ExtendedGroupChat")) -typealias ExtendedGroupChat = dev.inmo.tgbotapi.types.chat.ExtendedGroupChat - -@Deprecated("Replaced", ReplaceWith("ExtendedPrivateChat", "dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat")) -typealias ExtendedPrivateChat = dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat - -@Deprecated("Replaced", ReplaceWith("ExtendedPublicChat", "dev.inmo.tgbotapi.types.chat.ExtendedPublicChat")) -typealias ExtendedPublicChat = dev.inmo.tgbotapi.types.chat.ExtendedPublicChat - -@Deprecated("Replaced", ReplaceWith("ExtendedSupergroupChat", "dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat")) -typealias ExtendedSupergroupChat = dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat - -@Deprecated("Replaced", ReplaceWith("ExtendedChat", "dev.inmo.tgbotapi.types.chat.ExtendedChat")) -typealias ExtendedChat = dev.inmo.tgbotapi.types.chat.ExtendedChat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/extended/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/extended/Typealiases.kt deleted file mode 100644 index b8e99b677b..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/extended/Typealiases.kt +++ /dev/null @@ -1,19 +0,0 @@ -package dev.inmo.tgbotapi.types.chat.extended - -@Deprecated("Replaced", ReplaceWith("ExtendedChannelChatImpl", "dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl")) -typealias ExtendedChannelChatImpl = dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl -@Deprecated("Replaced", ReplaceWith("ExtendedGroupChatImpl", "dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl")) -typealias ExtendedGroupChatImpl = dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl -@Deprecated("Replaced", ReplaceWith("ExtendedPrivateChatImpl", "dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl")) -typealias ExtendedPrivateChatImpl = dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl - -@Deprecated("ExtendedUser", ReplaceWith("ExtendedPrivateChatImpl", "dev.inmo.tgbotapi.types.chat.ExtendedUser")) -typealias ExtendedUser = ExtendedPrivateChatImpl - -@Deprecated("Replaced", ReplaceWith("ExtendedSupergroupChatImpl", "dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl")) -typealias ExtendedSupergroupChatImpl = dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl -@Deprecated("Replaced", ReplaceWith("ExtendedBot", "dev.inmo.tgbotapi.types.chat.ExtendedBot")) -typealias ExtendedBot = dev.inmo.tgbotapi.types.chat.ExtendedBot - -@Deprecated("Replaced", ReplaceWith("UnknownExtendedChat", "dev.inmo.tgbotapi.types.chat.UnknownExtendedChat")) -typealias UnknownExtendedChat = dev.inmo.tgbotapi.types.chat.UnknownExtendedChat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index 16cb60da04..c963d3babf 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -56,16 +56,3 @@ inline fun VideoFile.toTelegramMediaVideo( duration, thumb ?.fileId ) - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Renamed", ReplaceWith("toTelegramMediaVideo", "dev.inmo.tgbotapi.types.files.toTelegramMediaVideo")) -inline fun VideoFile.toInputMediaVideo( - text: String? = null, - parseMode: ParseMode? = null -) = toTelegramMediaVideo(text, parseMode) - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Renamed", ReplaceWith("toTelegramMediaVideo", "dev.inmo.tgbotapi.types.files.toTelegramMediaVideo")) -inline fun VideoFile.toInputMediaVideo( - textSources: TextSourcesList -) = toTelegramMediaVideo(textSources) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/abstracts/OldTypealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/abstracts/OldTypealiases.kt deleted file mode 100644 index 3b5864dfec..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/abstracts/OldTypealiases.kt +++ /dev/null @@ -1,22 +0,0 @@ -package dev.inmo.tgbotapi.types.files.abstracts - -@Deprecated("Renamed", ReplaceWith("CustomNamedMediaFile", "dev.inmo.tgbotapi.types.files.CustomNamedMediaFile")) -typealias CustomNamedMediaFile = dev.inmo.tgbotapi.types.files.CustomNamedMediaFile - -@Deprecated("Replaced", ReplaceWith("MimedMediaFile", "dev.inmo.tgbotapi.types.files.MimedMediaFile")) -typealias MimedMediaFile = dev.inmo.tgbotapi.types.files.MimedMediaFile - -@Deprecated("Replaced", ReplaceWith("PlayableMediaFile", "dev.inmo.tgbotapi.types.files.PlayableMediaFile")) -typealias PlayableMediaFile = dev.inmo.tgbotapi.types.files.PlayableMediaFile - -@Deprecated("Replaced", ReplaceWith("SizedMediaFile", "dev.inmo.tgbotapi.types.files.SizedMediaFile")) -typealias SizedMediaFile = dev.inmo.tgbotapi.types.files.SizedMediaFile - -@Deprecated("Replaced", ReplaceWith("TelegramMediaFile", "dev.inmo.tgbotapi.types.files.TelegramMediaFile")) -typealias TelegramMediaFile = dev.inmo.tgbotapi.types.files.TelegramMediaFile - -@Deprecated("Replaced", ReplaceWith("ThumbedMediaFile", "dev.inmo.tgbotapi.types.files.ThumbedMediaFile")) -typealias ThumbedMediaFile = dev.inmo.tgbotapi.types.files.ThumbedMediaFile - -@Deprecated("Replaced", ReplaceWith("TitledMediaFile", "dev.inmo.tgbotapi.types.files.TitledMediaFile")) -typealias TitledMediaFile = dev.inmo.tgbotapi.types.files.TitledMediaFile diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/sticker/Sticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/sticker/Sticker.kt deleted file mode 100644 index c0da51eba1..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/sticker/Sticker.kt +++ /dev/null @@ -1,19 +0,0 @@ -package dev.inmo.tgbotapi.types.files.sticker - -@Deprecated("Replaced", ReplaceWith("StickerSurrogate", "dev.inmo.tgbotapi.types.files.StickerSurrogate")) -typealias StickerSurrogate = dev.inmo.tgbotapi.types.files.StickerSurrogate - -@Deprecated("Replaced", ReplaceWith("Sticker", "dev.inmo.tgbotapi.types.files.Sticker")) -typealias Sticker = dev.inmo.tgbotapi.types.files.Sticker - -@Deprecated("Replaced", ReplaceWith("StickerSerializer", "dev.inmo.tgbotapi.types.files.StickerSerializer")) -typealias StickerSerializer = dev.inmo.tgbotapi.types.files.StickerSerializer - -@Deprecated("Replaced", ReplaceWith("SimpleSticker", "dev.inmo.tgbotapi.types.files.SimpleSticker")) -typealias SimpleSticker = dev.inmo.tgbotapi.types.files.SimpleSticker - -@Deprecated("Replaced", ReplaceWith("AnimatedSticker", "dev.inmo.tgbotapi.types.files.AnimatedSticker")) -typealias AnimatedSticker = dev.inmo.tgbotapi.types.files.AnimatedSticker - -@Deprecated("Replaced", ReplaceWith("VideoSticker", "dev.inmo.tgbotapi.types.files.VideoSticker")) -typealias VideoSticker = dev.inmo.tgbotapi.types.files.VideoSticker diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VideoChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VideoChatEvent.kt index 077f9d32ba..bdc3a67d7f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VideoChatEvent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VideoChatEvent.kt @@ -1,8 +1,3 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts -import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled - interface VideoChatEvent : PublicChatEvent - -@Deprecated("Renamed", ReplaceWith("VideoChatEvent", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEvent")) -typealias VoiceChatEvent = VideoChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt index d13204b791..e51859e969 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt @@ -16,6 +16,3 @@ data class VideoChatEnded( val timeSpan: TimeSpan get() = TimeSpan(duration.seconds.milliseconds) } - -@Deprecated("Renamed", ReplaceWith("VideoChatEnded", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded")) -typealias VoiceChatEnded = VideoChatEnded diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatParticipantsInvited.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatParticipantsInvited.kt index 3c1a1d2e89..850190babe 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatParticipantsInvited.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatParticipantsInvited.kt @@ -11,6 +11,3 @@ data class VideoChatParticipantsInvited( @SerialName(usersField) val users: List = emptyList() ) : VideoChatEvent - -@Deprecated("Renamed", ReplaceWith("VideoChatParticipantsInvited", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited")) -typealias VoiceChatParticipantsInvited = VideoChatParticipantsInvited diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatScheduled.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatScheduled.kt index 5bb18b6ec2..b5178c99ed 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatScheduled.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatScheduled.kt @@ -11,6 +11,3 @@ data class VideoChatScheduled( @SerialName(startDateField) val startDate: TelegramDate ) : VideoChatEvent - -@Deprecated("Renamed", ReplaceWith("VideoChatScheduled", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled")) -typealias VoiceChatScheduled = VideoChatScheduled diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatStarted.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatStarted.kt index 0c9d08546a..f8f1787f0b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatStarted.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatStarted.kt @@ -5,6 +5,3 @@ import kotlinx.serialization.Serializable @Serializable object VideoChatStarted : VideoChatEvent - -@Deprecated("Renamed", ReplaceWith("VideoChatStarted", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatStarted")) -typealias VoiceChatStarted = VideoChatStarted diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt index 51e2415eca..857ff558d8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt @@ -106,8 +106,6 @@ sealed interface MediaCollectionContent: MessageContent, M sealed interface MediaContent: MessageContent { val media: TelegramMediaFile fun asTelegramMedia(): TelegramMedia - @Deprecated("Renamed", ReplaceWith("asTelegramMedia()")) - fun asInputMedia(): TelegramMedia = asTelegramMedia() } sealed interface ResendableContent { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt index 0d63566299..3d31a732c1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt @@ -19,8 +19,6 @@ sealed interface DocumentMediaGroupContent : MediaGroupContent { sealed interface MediaGroupContent : TextedMediaContent { fun toMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia - @Deprecated("Renamed", ReplaceWith("toMediaGroupMemberTelegramMedia()")) - fun toMediaGroupMemberInputMedia(): MediaGroupMemberTelegramMedia = toMediaGroupMemberTelegramMedia() } sealed interface TextedMediaContent : MediaContent, TextedInput diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/Typealiases.kt deleted file mode 100644 index 44b7c8ba6f..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/abstracts/Typealiases.kt +++ /dev/null @@ -1,25 +0,0 @@ -package dev.inmo.tgbotapi.types.message.content.abstracts - -@Deprecated("This class has been moved to the other package", ReplaceWith("AudioMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent")) -typealias AudioMediaGroupContent = dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("DocumentMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent")) -typealias DocumentMediaGroupContent = dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("VisualMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent")) -typealias VisualMediaGroupContent = dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("MediaCollectionContent", "dev.inmo.tgbotapi.types.message.content.MediaCollectionContent")) -typealias MediaCollectionContent = dev.inmo.tgbotapi.types.message.content.MediaCollectionContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("MediaContent", "dev.inmo.tgbotapi.types.message.content.MediaContent")) -typealias MediaContent = dev.inmo.tgbotapi.types.message.content.MediaContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("MessageContent", "dev.inmo.tgbotapi.types.message.content.MessageContent")) -typealias MessageContent = dev.inmo.tgbotapi.types.message.content.MessageContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("PossiblySentViaBotCommonMessage", "dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage")) -typealias PossiblySentViaBotCommonMessage = dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage - -@Deprecated("This class has been moved to the other package", ReplaceWith("ResendableContent", "dev.inmo.tgbotapi.types.message.content.ResendableContent")) -typealias ResendableContent = dev.inmo.tgbotapi.types.message.content.ResendableContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/Typealiases.kt deleted file mode 100644 index fc15c3fa4a..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/media/Typealiases.kt +++ /dev/null @@ -1,44 +0,0 @@ -package dev.inmo.tgbotapi.types.message.content.media - -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent -import dev.inmo.tgbotapi.types.message.content.asDocumentContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("VoiceContent", "dev.inmo.tgbotapi.types.message.content.VoiceContent")) -typealias VoiceContent = dev.inmo.tgbotapi.types.message.content.VoiceContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("VisualMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent")) -typealias VisualMediaGroupContent = dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("VideoNoteContent", "dev.inmo.tgbotapi.types.message.content.VideoNoteContent")) -typealias VideoNoteContent = dev.inmo.tgbotapi.types.message.content.VideoNoteContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("VideoContent", "dev.inmo.tgbotapi.types.message.content.VideoContent")) -typealias VideoContent = dev.inmo.tgbotapi.types.message.content.VideoContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("TextedMediaContent", "dev.inmo.tgbotapi.types.message.content.TextedMediaContent")) -typealias TextedMediaContent = dev.inmo.tgbotapi.types.message.content.TextedMediaContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("StickerContent", "dev.inmo.tgbotapi.types.message.content.StickerContent")) -typealias StickerContent = dev.inmo.tgbotapi.types.message.content.StickerContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("PhotoContent", "dev.inmo.tgbotapi.types.message.content.PhotoContent")) -typealias PhotoContent = dev.inmo.tgbotapi.types.message.content.PhotoContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("DocumentMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent")) -typealias DocumentMediaGroupContent = dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("DocumentContent", "dev.inmo.tgbotapi.types.message.content.DocumentContent")) -typealias DocumentContent = dev.inmo.tgbotapi.types.message.content.DocumentContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("asDocumentContent", "dev.inmo.tgbotapi.types.message.content.asDocumentContent")) -inline fun MediaContent.asDocumentContent() = asDocumentContent() - -@Deprecated("This class has been moved to the other package", ReplaceWith("AudioMediaGroupContent", "dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent")) -typealias AudioMediaGroupContent = dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("AudioContent", "dev.inmo.tgbotapi.types.message.content.AudioContent")) -typealias AudioContent = dev.inmo.tgbotapi.types.message.content.AudioContent - -@Deprecated("This class has been moved to the other package", ReplaceWith("AnimationContent", "dev.inmo.tgbotapi.types.message.content.AnimationContent")) -typealias AnimationContent = dev.inmo.tgbotapi.types.message.content.AnimationContent - diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/InvoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/InvoiceContent.kt deleted file mode 100644 index 3fd9b21378..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/InvoiceContent.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.message.payments - -@Deprecated("This class has been moved to the other package", ReplaceWith("InvoiceContent", "dev.inmo.tgbotapi.types.message.content.InvoiceContent")) -typealias InvoiceContent = dev.inmo.tgbotapi.types.message.content.InvoiceContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/PassportFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/PassportFile.kt deleted file mode 100644 index c780c64243..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/encrypted/PassportFile.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.passport.encrypted - -@Deprecated("Replaced", ReplaceWith("PassportFile", "dev.inmo.tgbotapi.types.files.PassportFile")) -typealias PassportFile = dev.inmo.tgbotapi.types.files.PassportFile diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/ChannelPostMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/ChannelPostMediaGroupUpdate.kt deleted file mode 100644 index 8769009f31..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/ChannelPostMediaGroupUpdate.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.update.MediaGroupUpdates - -@Deprecated("Replaced", ReplaceWith("ChannelPostMediaGroupUpdate", "dev.inmo.tgbotapi.types.update.media_group.ChannelPostMediaGroupUpdate")) -typealias ChannelPostMediaGroupUpdate = dev.inmo.tgbotapi.types.update.media_group.ChannelPostMediaGroupUpdate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditChannelPostMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditChannelPostMediaGroupUpdate.kt deleted file mode 100644 index d77d8e5ef3..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditChannelPostMediaGroupUpdate.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.update.MediaGroupUpdates - -@Deprecated("Replaced", ReplaceWith("EditChannelPostMediaGroupUpdate", "dev.inmo.tgbotapi.types.update.media_group.EditChannelPostMediaGroupUpdate")) -typealias EditChannelPostMediaGroupUpdate = dev.inmo.tgbotapi.types.update.media_group.EditChannelPostMediaGroupUpdate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditMessageMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditMessageMediaGroupUpdate.kt deleted file mode 100644 index 42cc5d6bb5..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/EditMessageMediaGroupUpdate.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.update.MediaGroupUpdates - -@Deprecated("Replaced", ReplaceWith("EditMessageMediaGroupUpdate", "dev.inmo.tgbotapi.types.update.media_group.EditMessageMediaGroupUpdate")) -typealias EditMessageMediaGroupUpdate = dev.inmo.tgbotapi.types.update.media_group.EditMessageMediaGroupUpdate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MediaGroupUpdate.kt deleted file mode 100644 index 83609e4244..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MediaGroupUpdate.kt +++ /dev/null @@ -1,10 +0,0 @@ -package dev.inmo.tgbotapi.types.update.MediaGroupUpdates - -@Deprecated("Replaced", ReplaceWith("MediaGroupUpdate", "dev.inmo.tgbotapi.types.update.media_group.MediaGroupUpdate")) -typealias MediaGroupUpdate = dev.inmo.tgbotapi.types.update.media_group.MediaGroupUpdate - -@Deprecated("Replaced", ReplaceWith("SentMediaGroupUpdate", "dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate")) -typealias SentMediaGroupUpdate = dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate - -@Deprecated("Replaced", ReplaceWith("EditMediaGroupUpdate", "dev.inmo.tgbotapi.types.update.media_group.EditMediaGroupUpdate")) -typealias EditMediaGroupUpdate = dev.inmo.tgbotapi.types.update.media_group.EditMediaGroupUpdate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MessageMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MessageMediaGroupUpdate.kt deleted file mode 100644 index b250aeccd9..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MediaGroupUpdates/MessageMediaGroupUpdate.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.inmo.tgbotapi.types.update.MediaGroupUpdates - -@Deprecated("Replaced", ReplaceWith("MessageMediaGroupUpdate", "dev.inmo.tgbotapi.types.update.media_group.MessageMediaGroupUpdate")) -typealias MessageMediaGroupUpdate = dev.inmo.tgbotapi.types.update.media_group.MessageMediaGroupUpdate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt index 902554c978..cd307582a4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt @@ -2,71 +2,6 @@ package dev.inmo.tgbotapi.utils import dev.inmo.tgbotapi.types.buttons.Matrix -/** - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder - */ -@Deprecated("This functionality will be removed soon") -fun row(block: RowBuilder.() -> Unit): List { - return RowBuilder().also(block).row -} - -/** - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder - */ -@Deprecated("This functionality will be removed soon") -fun MatrixBuilder.row(block: RowBuilder.() -> Unit) { - add(RowBuilder().also(block).row) -} - -/** - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder - */ -@Deprecated("This functionality will be removed soon") -fun MatrixBuilder.row(vararg elements: T) { - add(elements.toList()) -} - -/** - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder - */ -@Deprecated("This functionality will be removed soon") -fun matrix(block: MatrixBuilder.() -> Unit): Matrix { - return MatrixBuilder().also(block).matrix -} - -/** - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder - */ -@Deprecated("This functionality will be removed soon") -fun flatMatrix(block: RowBuilder.() -> Unit): Matrix { - return MatrixBuilder().apply { - row(block) - }.matrix -} - -/** - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder - */ -@Deprecated("This functionality will be removed soon") -fun flatMatrix(vararg elements: T): Matrix { - return MatrixBuilder().apply { - row { elements.forEach { +it } } - }.matrix -} - -/** - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder - * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder - */ -@Deprecated("This functionality will be removed soon") -operator fun RowBuilder.plus(t: T) = add(t) - open class RowBuilder { private val mutRow: MutableList = ArrayList() val row: List 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 deleted file mode 100644 index 69dd7b3d3e..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt +++ /dev/null @@ -1,72 +0,0 @@ -package dev.inmo.tgbotapi.utils - -import com.benasher44.uuid.uuid4 -import dev.inmo.micro_utils.common.MPPFile -import dev.inmo.micro_utils.common.filename -import io.ktor.utils.io.* -import io.ktor.utils.io.core.ByteReadPacket -import io.ktor.utils.io.core.Input -import kotlinx.serialization.Serializable - -/** - * Contains info about file, which potentially can be sent to telegram system. - * - * @param fileName Filename - * @param inputSource Lambda which able to allocate [Input] for uploading/manipulating data - * - * @see StorageFileInfo - * @see asStorageFile - */ -@Deprecated("Storage file now is not necessary") -data class StorageFile( - val fileName: String, - private val inputSource: () -> Input -) { - val input: Input - get() = inputSource() - - /** - * This methods is required for random generation of name for keeping warranties about unique file name - */ - fun generateCustomName() = "${uuid4()}.${fileName.fileExtension}" - -} - -@Deprecated("Storage file now is not necessary") -@Suppress("NOTHING_TO_INLINE") -inline fun StorageFile( - fileName: String, - bytes: ByteArray -) = StorageFile( - fileName -) { - ByteReadPacket(bytes) -} - -@Deprecated("StorageFile now is not necessary") -@Suppress("NOTHING_TO_INLINE") -suspend inline fun StorageFile( - fileName: String, - byteReadChannel: ByteReadChannel -) = StorageFile( - fileName, - inputSource = byteReadChannel.asInput().let { { it } } -) - -@Deprecated("StorageFile now is not necessary") -@Suppress("NOTHING_TO_INLINE", "unused") -inline fun ByteArray.asStorageFile( - fileName: String -) = StorageFile(fileName, this) - -@Deprecated("StorageFile now is not necessary") -@Suppress("NOTHING_TO_INLINE", "unused") -suspend inline fun ByteReadChannel.asStorageFile( - fileName: String -) = StorageFile(fileName, this) - -@Deprecated("StorageFile now is not necessary") -@Suppress("NOTHING_TO_INLINE", "unused") -suspend inline fun ByteReadChannelAllocator.asStorageFile( - fileName: String -) = this.invoke().asStorageFile(fileName) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper.kt index 16df51532b..17f7389b6f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper.kt @@ -60,11 +60,4 @@ class TelegramAPIUrlsKeeper( return HMAC.hmacSHA256(webAppDataSecretKeyHash.bytes, preparedData.toByteArray()).hexLower == hash.lowercase() } - - /** - * @param rawData Data from [dev.inmo.tgbotapi.webapps.WebApp.initData] - * @param hash Data from [dev.inmo.tgbotapi.webapps.WebApp.initDataUnsafe] from the field [dev.inmo.tgbotapi.webapps.WebAppInitData.hash] - */ - @Deprecated("Renamed", ReplaceWith("checkWebAppData")) - inline fun checkWebAppLink(rawData: String, hash: String) = checkWebAppData(rawData, hash) } 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 deleted file mode 100644 index be39de9c66..0000000000 --- a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/StorageFileFactory.kt +++ /dev/null @@ -1,14 +0,0 @@ -package dev.inmo.tgbotapi.utils - -import io.ktor.utils.io.streams.asInput -import java.io.File -import java.nio.file.Files - -@Deprecated("StorageFile now is not necessary") -fun StorageFile( - file: File -) = StorageFile( - file.name -) { - file.inputStream().asInput() -} diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 8bb132515a..9751afd056 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -936,18 +936,6 @@ inline fun Message.asChannelContentMessageImpl(): UnconnectedFromChannelGroupCon inline fun Message.requireChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl = this as UnconnectedFromChannelGroupContentMessageImpl -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenConnectedFromChannelGroupContentMessage", "dev.inmo.tgbotapi.extensions.utils.whenConnectedFromChannelGroupContentMessage")) -inline fun Message.whenFromChannelGroupContentMessageImpl(block: (ConnectedFromChannelGroupContentMessage) -> T) = whenConnectedFromChannelGroupContentMessage(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asConnectedFromChannelGroupContentMessage", "dev.inmo.tgbotapi.extensions.utils.asConnectedFromChannelGroupContentMessage")) -inline fun Message.asFromChannelGroupContentMessageImpl(): ConnectedFromChannelGroupContentMessage? = asConnectedFromChannelGroupContentMessage() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireConnectedFromChannelGroupContentMessage", "dev.inmo.tgbotapi.extensions.utils.requireConnectedFromChannelGroupContentMessage")) -inline fun Message.requireFromChannelGroupContentMessageImpl(): ConnectedFromChannelGroupContentMessage = requireConnectedFromChannelGroupContentMessage() - @PreviewFeature inline fun Message.whenPassportMessage(block: (PassportMessage) -> T) = asPassportMessage() ?.let(block) @@ -1892,162 +1880,6 @@ inline fun ChatMember.asSpecialRightsChatMember(): SpecialRightsChatMember? = th @PreviewFeature inline fun ChatMember.requireSpecialRightsChatMember(): SpecialRightsChatMember = this as SpecialRightsChatMember -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenAudioMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.whenAudioMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.whenAudioMediaGroupMemberInputMedia(block: (AudioMediaGroupMemberTelegramMedia) -> T) = whenAudioMediaGroupMemberTelegramMedia(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asAudioMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.asAudioMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.asAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberTelegramMedia? = asAudioMediaGroupMemberTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireAudioMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.requireAudioMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.requireAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberTelegramMedia = requireAudioMediaGroupMemberTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenDocumentMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.whenDocumentMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.whenDocumentMediaGroupMemberInputMedia(block: (DocumentMediaGroupMemberTelegramMedia) -> T) = whenDocumentMediaGroupMemberTelegramMedia(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asDocumentMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.asDocumentMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.asDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberTelegramMedia? = asDocumentMediaGroupMemberTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireDocumentMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.requireDocumentMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.requireDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberTelegramMedia = requireDocumentMediaGroupMemberTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenDuratedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.whenDuratedTelegramMedia")) -inline fun TelegramMedia.whenDuratedInputMedia(block: (DuratedTelegramMedia) -> T) = whenDuratedTelegramMedia(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asDuratedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.asDuratedTelegramMedia")) -inline fun TelegramMedia.asDuratedInputMedia(): DuratedTelegramMedia? = asDuratedTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireDuratedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.requireDuratedTelegramMedia")) -inline fun TelegramMedia.requireDuratedInputMedia(): DuratedTelegramMedia = requireDuratedTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenTelegramMediaAnimation", "dev.inmo.tgbotapi.extensions.utils.whenTelegramMediaAnimation")) -inline fun TelegramMedia.whenInputMediaAnimation(block: (TelegramMediaAnimation) -> T) = whenTelegramMediaAnimation(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asTelegramMediaAnimation", "dev.inmo.tgbotapi.extensions.utils.asTelegramMediaAnimation")) -inline fun TelegramMedia.asInputMediaAnimation(): TelegramMediaAnimation? = asTelegramMediaAnimation() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireTelegramMediaAnimation", "dev.inmo.tgbotapi.extensions.utils.requireTelegramMediaAnimation")) -inline fun TelegramMedia.requireInputMediaAnimation(): TelegramMediaAnimation = requireTelegramMediaAnimation() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenTelegramMediaAudio", "dev.inmo.tgbotapi.extensions.utils.whenTelegramMediaAudio")) -inline fun TelegramMedia.whenInputMediaAudio(block: (TelegramMediaAudio) -> T) = whenTelegramMediaAudio(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asTelegramMediaAudio", "dev.inmo.tgbotapi.extensions.utils.asTelegramMediaAudio")) -inline fun TelegramMedia.asInputMediaAudio(): TelegramMediaAudio? = asTelegramMediaAudio() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireTelegramMediaAudio", "dev.inmo.tgbotapi.extensions.utils.requireTelegramMediaAudio")) -inline fun TelegramMedia.requireInputMediaAudio(): TelegramMediaAudio = requireTelegramMediaAudio() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenTelegramMediaDocument", "dev.inmo.tgbotapi.extensions.utils.whenTelegramMediaDocument")) -inline fun TelegramMedia.whenInputMediaDocument(block: (TelegramMediaDocument) -> T) = whenTelegramMediaDocument(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asTelegramMediaDocument", "dev.inmo.tgbotapi.extensions.utils.asTelegramMediaDocument")) -inline fun TelegramMedia.asInputMediaDocument(): TelegramMediaDocument? = asTelegramMediaDocument() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireTelegramMediaDocument", "dev.inmo.tgbotapi.extensions.utils.requireTelegramMediaDocument")) -inline fun TelegramMedia.requireInputMediaDocument(): TelegramMediaDocument = requireTelegramMediaDocument() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenTelegramMediaPhoto", "dev.inmo.tgbotapi.extensions.utils.whenTelegramMediaPhoto")) -inline fun TelegramMedia.whenInputMediaPhoto(block: (TelegramMediaPhoto) -> T) = whenTelegramMediaPhoto(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asTelegramMediaPhoto", "dev.inmo.tgbotapi.extensions.utils.asTelegramMediaPhoto")) -inline fun TelegramMedia.asInputMediaPhoto(): TelegramMediaPhoto? = asTelegramMediaPhoto() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireTelegramMediaPhoto", "dev.inmo.tgbotapi.extensions.utils.requireTelegramMediaPhoto")) -inline fun TelegramMedia.requireInputMediaPhoto(): TelegramMediaPhoto = requireTelegramMediaPhoto() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenTelegramMediaVideo", "dev.inmo.tgbotapi.extensions.utils.whenTelegramMediaVideo")) -inline fun TelegramMedia.whenInputMediaVideo(block: (TelegramMediaVideo) -> T) = whenTelegramMediaVideo(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asTelegramMediaVideo", "dev.inmo.tgbotapi.extensions.utils.asTelegramMediaVideo")) -inline fun TelegramMedia.asInputMediaVideo(): TelegramMediaVideo? = asTelegramMediaVideo() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireTelegramMediaVideo", "dev.inmo.tgbotapi.extensions.utils.requireTelegramMediaVideo")) -inline fun TelegramMedia.requireInputMediaVideo(): TelegramMediaVideo = requireTelegramMediaVideo() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.whenMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.whenMediaGroupMemberInputMedia(block: (MediaGroupMemberTelegramMedia) -> T) = whenMediaGroupMemberTelegramMedia(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.asMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.asMediaGroupMemberInputMedia(): MediaGroupMemberTelegramMedia? = asMediaGroupMemberTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.requireMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.requireMediaGroupMemberInputMedia(): MediaGroupMemberTelegramMedia = requireMediaGroupMemberTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenSizedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.whenSizedTelegramMedia")) -inline fun TelegramMedia.whenSizedInputMedia(block: (SizedTelegramMedia) -> T) = whenSizedTelegramMedia(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asSizedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.asSizedTelegramMedia")) -inline fun TelegramMedia.asSizedInputMedia(): SizedTelegramMedia? = asSizedTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireSizedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.requireSizedTelegramMedia")) -inline fun TelegramMedia.requireSizedInputMedia(): SizedTelegramMedia = requireSizedTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenThumbedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.whenThumbedTelegramMedia")) -inline fun TelegramMedia.whenThumbedInputMedia(block: (ThumbedTelegramMedia) -> T) = whenThumbedTelegramMedia(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asThumbedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.asThumbedTelegramMedia")) -inline fun TelegramMedia.asThumbedInputMedia(): ThumbedTelegramMedia? = asThumbedTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireThumbedTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.requireThumbedTelegramMedia")) -inline fun TelegramMedia.requireThumbedInputMedia(): ThumbedTelegramMedia = requireThumbedTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenTitledTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.whenTitledTelegramMedia")) -inline fun TelegramMedia.whenTitledInputMedia(block: (TitledTelegramMedia) -> T) = whenTitledTelegramMedia(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asTitledTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.asTitledTelegramMedia")) -inline fun TelegramMedia.asTitledInputMedia(): TitledTelegramMedia? = asTitledTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireTitledTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.requireTitledTelegramMedia")) -inline fun TelegramMedia.requireTitledInputMedia(): TitledTelegramMedia = requireTitledTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("whenVisualMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.whenVisualMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.whenVisualMediaGroupMemberInputMedia(block: (VisualMediaGroupMemberTelegramMedia) -> T) = whenVisualMediaGroupMemberTelegramMedia(block) - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("asVisualMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.asVisualMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.asVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberTelegramMedia? = asVisualMediaGroupMemberTelegramMedia() - -@PreviewFeature -@Deprecated("Renamed", ReplaceWith("requireVisualMediaGroupMemberTelegramMedia", "dev.inmo.tgbotapi.extensions.utils.requireVisualMediaGroupMemberTelegramMedia")) -inline fun TelegramMedia.requireVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberTelegramMedia = requireVisualMediaGroupMemberTelegramMedia() - @PreviewFeature inline fun TelegramMedia.whenAudioMediaGroupMemberTelegramMedia(block: (AudioMediaGroupMemberTelegramMedia) -> T) = asAudioMediaGroupMemberTelegramMedia() ?.let(block) @@ -3360,68 +3192,6 @@ inline fun ChatEvent.asSupergroupEvent(): SupergroupEvent? = this as? Supergroup @PreviewFeature inline fun ChatEvent.requireSupergroupEvent(): SupergroupEvent = this as SupergroupEvent -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.whenVoiceChatEvent(block: (VideoChatEvent) -> T) = asVoiceChatEvent() ?.let(block) - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.asVoiceChatEvent(): VideoChatEvent? = this as? VideoChatEvent - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.requireVoiceChatEvent(): VideoChatEvent = this as VideoChatEvent - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.whenVoiceChatEnded(block: (VideoChatEnded) -> T) = asVoiceChatEnded() ?.let(block) - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.asVoiceChatEnded(): VideoChatEnded? = this as? VideoChatEnded - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.requireVoiceChatEnded(): VideoChatEnded = this as VideoChatEnded - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.whenVoiceChatParticipantsInvited(block: (VideoChatParticipantsInvited) -> T) = asVoiceChatParticipantsInvited() ?.let(block) - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.asVoiceChatParticipantsInvited(): VideoChatParticipantsInvited? = - this as? VideoChatParticipantsInvited - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.requireVoiceChatParticipantsInvited(): VideoChatParticipantsInvited = - this as VideoChatParticipantsInvited - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.whenVoiceChatStarted(block: (VideoChatStarted) -> T) = asVoiceChatStarted() ?.let(block) - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.asVoiceChatStarted(): VideoChatStarted? = this as? VideoChatStarted - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.requireVoiceChatStarted(): VideoChatStarted = this as VideoChatStarted - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.whenVoiceChatScheduled(block: (VideoChatScheduled) -> T) = asVoiceChatScheduled() ?.let(block) - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.asVoiceChatScheduled(): VideoChatScheduled? = this as? VideoChatScheduled - -@PreviewFeature -@Deprecated("Renamed as Video instead of Voice") -inline fun ChatEvent.requireVoiceChatScheduled(): VideoChatScheduled = this as VideoChatScheduled - @PreviewFeature inline fun ChatEvent.whenVideoChatEvent(block: (VideoChatEvent) -> T) = asVideoChatEvent() ?.let(block) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index 1bb5856bfc..40054eabf4 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -178,22 +178,6 @@ inline val Message.successful_payment: SuccessfulPayment? get() = asChatEventMessage() ?.chatEvent ?.asSuccessfulPaymentEvent() ?.payment @RiskFeature(RawFieldsUsageWarning) -@Deprecated("Renamed as video instead of voice") -inline val Message.voice_chat_scheduled: VideoChatScheduled? - get() = asChatEventMessage() ?.chatEvent ?.asVoiceChatScheduled() -@RiskFeature(RawFieldsUsageWarning) -@Deprecated("Renamed as video instead of voice") -inline val Message.voice_chat_started: VideoChatStarted? - get() = asChatEventMessage() ?.chatEvent ?.asVoiceChatStarted() -@RiskFeature(RawFieldsUsageWarning) -@Deprecated("Renamed as video instead of voice") -inline val Message.voice_chat_ended: VideoChatEnded? - get() = asChatEventMessage() ?.chatEvent ?.asVoiceChatEnded() -@RiskFeature(RawFieldsUsageWarning) -@Deprecated("Renamed as video instead of voice") -inline val Message.voice_chat_participants_invited: VideoChatParticipantsInvited? - get() = asChatEventMessage() ?.chatEvent ?.asVoiceChatParticipantsInvited() -@RiskFeature(RawFieldsUsageWarning) inline val Message.video_chat_scheduled: VideoChatScheduled? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatScheduled() @RiskFeature(RawFieldsUsageWarning) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt deleted file mode 100644 index 323617f3c4..0000000000 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt +++ /dev/null @@ -1,43 +0,0 @@ -package dev.inmo.tgbotapi.extensions.utils.types.files - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.requests.DownloadFileStream -import dev.inmo.tgbotapi.requests.abstracts.FileId -import dev.inmo.tgbotapi.requests.get.GetFile -import dev.inmo.tgbotapi.types.files.PathedFile -import dev.inmo.tgbotapi.types.files.TelegramMediaFile -import dev.inmo.tgbotapi.types.message.content.MediaContent -import dev.inmo.tgbotapi.utils.* - -@Deprecated("StorageFile now is not necessary") -suspend fun convertToStorageFile( - downloadStreamAllocator: ByteReadChannelAllocator, - pathedFile: PathedFile -): StorageFile { - return downloadStreamAllocator.asStorageFile( - pathedFile.fileName - ) -} - -@Deprecated("StorageFile now is not necessary") -suspend fun TelegramBot.convertToStorageFile( - pathedFile: PathedFile -): StorageFile = convertToStorageFile( - execute(DownloadFileStream(pathedFile.filePath)), - pathedFile -) - -@Deprecated("StorageFile now is not necessary") -suspend fun TelegramBot.convertToStorageFile( - fileId: FileId -): StorageFile = convertToStorageFile(execute(GetFile(fileId))) - -@Deprecated("StorageFile now is not necessary") -suspend fun TelegramBot.convertToStorageFile( - file: TelegramMediaFile -): StorageFile = convertToStorageFile(file.fileId) - -@Deprecated("StorageFile now is not necessary") -suspend fun TelegramBot.convertToStorageFile( - content: MediaContent -): StorageFile = convertToStorageFile(content.media) diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/CryptoJSExtensions.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/CryptoJSExtensions.kt deleted file mode 100644 index cb061c9594..0000000000 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/CryptoJSExtensions.kt +++ /dev/null @@ -1,9 +0,0 @@ -package dev.inmo.tgbotapi.webapps - -import dev.inmo.micro_utils.crypto.CryptoJs - -@Deprecated("Useless") -fun CryptoJs.HmacSHA256(text: String, key: String) = this.asDynamic().HmacSHA256(text, key).unsafeCast() - -@Deprecated("Useless") -fun CryptoJs.hex(text: String) = this.asDynamic().format.Hex(text).unsafeCast() From 74304904999a9b2076675eb7e98c8664ec63d0b5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 22 May 2022 01:46:11 +0600 Subject: [PATCH 9/9] fixes for build --- .../EditedContentTriggers.kt | 1 - .../bot/SetMyDefaultAdministratorRights.kt | 1 + .../kotlin/dev/inmo/tgbotapi/utils/Matrix.kt | 58 +++++ .../utils/formatting/EntitiesBuilder.kt | 198 +++++++++--------- .../utils/updates/CommandsFilters.kt | 2 +- 5 files changed, 159 insertions(+), 101 deletions(-) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt index 34b7b5c27d..e68ff542a2 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt @@ -25,7 +25,6 @@ import dev.inmo.tgbotapi.extensions.utils.withContent import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.* -import dev.inmo.tgbotapi.types.message.content.abstracts.* import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent import dev.inmo.tgbotapi.types.message.content.InvoiceContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDefaultAdministratorRights.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDefaultAdministratorRights.kt index cc30b7070a..b5691330e8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDefaultAdministratorRights.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDefaultAdministratorRights.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.bot import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRightsImpl import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt index cd307582a4..51e9ca80a1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt @@ -2,6 +2,64 @@ package dev.inmo.tgbotapi.utils import dev.inmo.tgbotapi.types.buttons.Matrix +/** + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder + */ +fun row(block: RowBuilder.() -> Unit): List { + return RowBuilder().also(block).row +} + +/** + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder + */ +fun MatrixBuilder.row(block: RowBuilder.() -> Unit) { + add(RowBuilder().also(block).row) +} + +/** + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder + */ +fun MatrixBuilder.row(vararg elements: T) { + add(elements.toList()) +} + +/** + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder + */ +fun matrix(block: MatrixBuilder.() -> Unit): Matrix { + return MatrixBuilder().also(block).matrix +} + +/** + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder + */ +fun flatMatrix(block: RowBuilder.() -> Unit): Matrix { + return MatrixBuilder().apply { + row(block) + }.matrix +} + +/** + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder + */ +fun flatMatrix(vararg elements: T): Matrix { + return MatrixBuilder().apply { + row { elements.forEach { +it } } + }.matrix +} + +/** + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder + * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder + */ +operator fun RowBuilder.plus(t: T) = add(t) + open class RowBuilder { private val mutRow: MutableList = ArrayList() val row: List diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt index a60e862b2d..6fa296a680 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt @@ -48,7 +48,7 @@ class EntitiesBuilder internal constructor( operator fun invoke(vararg source: TextSource) = addAll(source.toList()) operator fun String.unaryPlus(): EntitiesBuilder { - add(dev.inmo.tgbotapi.types.MessageEntity.textsources.regular(this)) + add(dev.inmo.tgbotapi.types.message.textsources.regular(this)) return this@EntitiesBuilder } @@ -65,70 +65,70 @@ class EntitiesBuilder internal constructor( } /** - * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.bold] + * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ -inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(parts)) +inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.bold(parts)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine /** - * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.bold]. + * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(buildEntities(separator, init))) +inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.bold] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine /** - * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.bold] + * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ -inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(*parts)) +inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.bold(*parts)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine /** - * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.bold] + * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ -inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.bold(text)) +inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.bold(text)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine /** - * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.spoiler] + * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ -inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.spoiler(parts)) +inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(parts)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine /** - * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.spoiler]. + * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.spoiler(buildEntities(separator, init))) +inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.spoiler] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine /** - * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.spoiler] + * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ -inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.spoiler(*parts)) +inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(*parts)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine /** - * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.spoiler] + * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ -inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.spoiler(text)) +inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(text)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ @@ -136,9 +136,9 @@ inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine /** - * Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.botCommand] + * Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand] */ -inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.botCommand(command)) +inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(command)) /** * Version of [EntitiesBuilder.botCommand] with new line at the end */ @@ -146,35 +146,35 @@ inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + /** - * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag] + * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ -inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(parts)) +inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(parts)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine /** - * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag]. + * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(buildEntities(separator, init))) +inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.cashTag] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine /** - * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag] + * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ -inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(*parts)) +inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(*parts)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine /** - * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag] + * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ -inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.cashTag(text)) +inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(text)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ @@ -182,9 +182,9 @@ inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine /** - * Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.code] + * Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.code] */ -inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.code(code)) +inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.message.textsources.code(code)) /** * Version of [EntitiesBuilder.code] with new line at the end */ @@ -192,35 +192,35 @@ inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine /** - * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.email] + * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ -inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(parts)) +inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.email(parts)) /** * Version of [EntitiesBuilder.email] with new line at the end */ inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine /** - * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.email]. + * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(buildEntities(separator, init))) +inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.email] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine /** - * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.email] + * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ -inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(*parts)) +inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.email(*parts)) /** * Version of [EntitiesBuilder.email] with new line at the end */ inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine /** - * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.email] + * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ -inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.email(emailAddress)) +inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.message.textsources.email(emailAddress)) /** * Version of [EntitiesBuilder.email] with new line at the end */ @@ -228,35 +228,35 @@ inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) + /** - * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag] + * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ -inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(parts)) +inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(parts)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine /** - * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag]. + * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(buildEntities(separator, init))) +inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.hashtag] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine /** - * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag] + * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ -inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(*parts)) +inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(*parts)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine /** - * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag] + * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ -inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.hashtag(hashtag)) +inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(hashtag)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ @@ -264,35 +264,35 @@ inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLi /** - * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.italic] + * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ -inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(parts)) +inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.italic(parts)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine /** - * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.italic]. + * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(buildEntities(separator, init))) +inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.italic] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine /** - * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.italic] + * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ -inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(*parts)) +inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.italic(*parts)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine /** - * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.italic] + * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ -inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.italic(text)) +inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.italic(text)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ @@ -300,43 +300,43 @@ inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine /** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.mention] + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(parts)) +inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine /** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.mention]. + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(buildEntities(separator, init))) +inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.mention] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine /** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.mention] + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(*parts)) +inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.mention(*parts)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine /** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.mention] + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(whoToMention)) +inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine /** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.mention] + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(parts, user)) +inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts, user)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ @@ -344,15 +344,15 @@ inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = menti inline fun EntitiesBuilder.mention( user: User, vararg parts: TextSource -) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(user, *parts)) +) = add(dev.inmo.tgbotapi.types.message.textsources.mention(user, *parts)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ inline fun EntitiesBuilder.mentionln(user: User, vararg parts: TextSource) = mention(user, *parts) + newLine /** - * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.mention] + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.mention(text, user)) +inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(text, user)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ @@ -360,35 +360,35 @@ inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text) + /** - * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.phone] + * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ -inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(parts)) +inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.phone(parts)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine /** - * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.phone]. + * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(buildEntities(separator, init))) +inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.phone] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine /** - * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.phone] + * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ -inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(*parts)) +inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.phone(*parts)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine /** - * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.phone] + * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ -inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.phone(number)) +inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.message.textsources.phone(number)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ @@ -396,24 +396,24 @@ inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine /** - * Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.pre] + * Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.pre] */ -inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.pre(code, language)) +inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.message.textsources.pre(code, language)) /** * Version of [EntitiesBuilder.pre] with new line at the end */ inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) + newLine /** - * Will add simple [dev.inmo.tgbotapi.types.MessageEntity.textsources.regular] [TextSource] + * Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] * * @see RegularTextSource * @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln */ inline fun EntitiesBuilder.regular(text: String) = - add(dev.inmo.tgbotapi.types.MessageEntity.textsources.regular(text)) + add(dev.inmo.tgbotapi.types.message.textsources.regular(text)) /** - * Will add simple [dev.inmo.tgbotapi.types.MessageEntity.textsources.regular] [TextSource] and "\n" at the end + * Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] and "\n" at the end * * @see RegularTextSource * @see dev.inmo.tgbotapi.extensions.utils.formatting.regular @@ -422,35 +422,35 @@ inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine /** - * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough] + * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ -inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(parts)) +inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(parts)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine /** - * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough]. + * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(buildEntities(separator, init))) +inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine /** - * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough] + * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ -inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(*parts)) +inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(*parts)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine /** - * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough] + * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ -inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.strikethrough(text)) +inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(text)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ @@ -458,17 +458,17 @@ inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) + /** - * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.link] + * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] */ -inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.link(text, url)) +inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(text, url)) /** * Version of [EntitiesBuilder.link] with new line at the end */ inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine /** - * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.link] + * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] */ -inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.link(url)) +inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(url)) /** * Version of [EntitiesBuilder.link] with new line at the end */ @@ -476,35 +476,35 @@ inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine /** - * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.underline] + * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ -inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(parts)) +inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.underline(parts)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine /** - * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.underline]. + * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(buildEntities(separator, init))) +inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline(buildEntities(separator, init))) /** * Version of [EntitiesBuilder.underline] with new line at the end. * Will reuse separator config from [buildEntities] */ inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine /** - * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.underline] + * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ -inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(*parts)) +inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.underline(*parts)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine /** - * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.underline] + * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ -inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.MessageEntity.textsources.underline(text)) +inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.underline(text)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt index a20594e329..246a1586ad 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.updates import dev.inmo.tgbotapi.extensions.utils.onlyTextContentMessages import dev.inmo.tgbotapi.extensions.utils.shortcuts.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.* +import dev.inmo.tgbotapi.types.message.textsources.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList