1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

deprecate several behaviour builder methods

This commit is contained in:
InsanusMokrassar 2021-10-18 15:48:24 +06:00
parent 15386a63f9
commit f385101e22
3 changed files with 28 additions and 11 deletions

View File

@ -22,10 +22,10 @@ import kotlin.coroutines.coroutineContext
* **WARNING** This method WILL NOT launch any listening of updates. Use something like * **WARNING** This method WILL NOT launch any listening of updates. Use something like
* [startGettingOfUpdatesByLongPolling] or tools for work with webhooks * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks
* *
* @return Created bot which has been used to create [BehaviourContext] via [buildBehaviour] * @return Created bot which has been used to create [BehaviourContext] via [buildBehaviourWithFSM]
* *
* @see [BehaviourContext] * @see [BehaviourContext]
* @see [buildBehaviour] * @see [buildBehaviourWithFSM]
* @see startGettingOfUpdatesByLongPolling * @see startGettingOfUpdatesByLongPolling
*/ */
suspend fun telegramBotWithBehaviourAndFSM( suspend fun telegramBotWithBehaviourAndFSM(
@ -60,8 +60,8 @@ suspend fun telegramBotWithBehaviourAndFSM(
* @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed * @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed
* here * here
* *
* @see [BehaviourContext] * @see BehaviourContext
* @see [buildBehaviour] * @see buildBehaviourWithFSMAndStartLongPolling
* @see startGettingOfUpdatesByLongPolling * @see startGettingOfUpdatesByLongPolling
*/ */
suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling( suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling(

View File

@ -54,7 +54,7 @@ suspend fun TelegramBot.buildBehaviour(
* @see startGettingOfUpdatesByLongPolling * @see startGettingOfUpdatesByLongPolling
*/ */
@PreviewFeature @PreviewFeature
suspend fun TelegramBot.buildBehaviour( suspend fun TelegramBot.buildBehaviourWithLongPolling(
scope: CoroutineScope = defaultCoroutineScopeProvider(), scope: CoroutineScope = defaultCoroutineScopeProvider(),
defaultExceptionsHandler: ExceptionHandler<Unit>? = null, defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
block: BehaviourContextReceiver<Unit> block: BehaviourContextReceiver<Unit>
@ -70,3 +70,11 @@ suspend fun TelegramBot.buildBehaviour(
scope = scope scope = scope
) )
} }
@PreviewFeature
@Deprecated("Renamed to buildBehaviourWithLongPolling")
suspend fun TelegramBot.buildBehaviour(
scope: CoroutineScope = defaultCoroutineScopeProvider(),
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
block: BehaviourContextReceiver<Unit>
) = buildBehaviourWithLongPolling(scope, defaultExceptionsHandler, block)

View File

@ -45,20 +45,19 @@ suspend fun telegramBotWithBehaviour(
} }
/** /**
* Create bot using [telegramBot] and start listening for updates using [buildBehaviour]. * Create bot using [telegramBot] and start listening for updates using [buildBehaviourWithLongPolling].
* Use this method in case you wish to make some additional actions with [flowsUpdatesFilter]. * Use this method in case you wish to make some additional actions with [flowsUpdatesFilter].
* *
* **WARNING** This method WILL NOT launch any listening of updates. Use something like * **WARNING** This method WILL launch updates listening inside of calling [buildBehaviourWithLongPolling]
* [startGettingOfUpdatesByLongPolling] or tools for work with webhooks
* *
* @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed * @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed
* here * here
* *
* @see [BehaviourContext] * @see [BehaviourContext]
* @see [buildBehaviour] * @see buildBehaviourWithLongPolling
* @see startGettingOfUpdatesByLongPolling * @see startGettingOfUpdatesByLongPolling
*/ */
suspend fun telegramBotWithBehaviour( suspend fun telegramBotWithBehaviourAndLongPolling(
token: String, token: String,
scope: CoroutineScope? = null, scope: CoroutineScope? = null,
apiUrl: String = telegramBotAPIDefaultUrl, apiUrl: String = telegramBotAPIDefaultUrl,
@ -71,10 +70,20 @@ suspend fun telegramBotWithBehaviour(
apiUrl, apiUrl,
builder builder
).let { ).let {
it to it.buildBehaviour( it to it.buildBehaviourWithLongPolling(
scope ?: CoroutineScope(coroutineContext), scope ?: CoroutineScope(coroutineContext),
defaultExceptionsHandler, defaultExceptionsHandler,
block block
) )
} }
} }
@Deprecated("Renamed to telegramBotWithBehaviourAndLongPolling")
suspend fun telegramBotWithBehaviour(
token: String,
scope: CoroutineScope? = null,
apiUrl: String = telegramBotAPIDefaultUrl,
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
block: BehaviourContextReceiver<Unit>
) = telegramBotWithBehaviourAndLongPolling(token, scope, apiUrl, builder, defaultExceptionsHandler, block)