diff --git a/CHANGELOG.md b/CHANGELOG.md index 55142b2cdf..3875da0618 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.31.0 +* `Behaviour Builder`: + * Extension `TelegramBot#buildBehaviour` have changed its return value: now it is `Job` instead of + `FlowsUpdatesFilter` + ## 0.30.13 * `Common`: diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt index b27d04396d..d2d4078ad9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/results/audio/InlineQueryResultAudioCommon.kt @@ -8,10 +8,5 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInp const val inlineQueryResultAudioType = "audio" interface InlineQueryResultAudioCommon : InlineQueryResult, - CaptionedOutput, TextedOutput, - WithInputMessageContentInlineQueryResult { - @Deprecated("Will be removed in next major release") - override val caption: String? - get() = text -} + WithInputMessageContentInlineQueryResult diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt index 8138d6db72..5ca9087674 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt @@ -3,8 +3,19 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.utils.PreviewFeature import kotlinx.coroutines.CoroutineScope +/** + * Use this method in case you wish to make some additional actions with [flowUpdatesFilter]. + * + * **WARNING** This method WILL NOT launch any listening of updates. Use something like + * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks + * + * @see [BehaviourContext] + * @see startGettingOfUpdatesByLongPolling + */ +@PreviewFeature suspend fun TelegramBot.buildBehaviour( scope: CoroutineScope, flowUpdatesFilter: FlowsUpdatesFilter, @@ -17,10 +28,19 @@ suspend fun TelegramBot.buildBehaviour( ).block() } +/** + * Use this method to build bot behaviour and run it via long polling. In case you wish to get [FlowsUpdatesFilter] for + * additional manipulations, you must provide external [FlowsUpdatesFilter] in other [buildBehaviour] function. + * + * @see buildBehaviour + * @see BehaviourContext + * @see startGettingOfUpdatesByLongPolling + */ +@PreviewFeature suspend fun TelegramBot.buildBehaviour( scope: CoroutineScope, block: BehaviourContextReceiver -) = FlowsUpdatesFilter().also { +) = FlowsUpdatesFilter().let { buildBehaviour( scope, it, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index 093148c19c..5d3afb72a1 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -8,6 +8,13 @@ import kotlinx.coroutines.CoroutineScope typealias BehaviourContextReceiver = suspend BehaviourContext.() -> T typealias BehaviourContextAndTypeReceiver = suspend BehaviourContext.(I) -> T +/** + * This class contains all necessary tools for work with bots and especially for [buildBehaviour] + * + * @param scope This param will be used for creating of some subscriptions inside of methods, updates listening and + * different other things in context of working with [CoroutineScope] and coroutines. + * @param flowsUpdatesFilter This parameter will be used to subscribe on different types of update + */ data class BehaviourContext( val bot: TelegramBot, val scope: CoroutineScope,