1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-26 18:47:14 +00:00

small update of scenarios

This commit is contained in:
InsanusMokrassar 2021-01-06 23:21:33 +06:00
parent 00873a255c
commit 30e6f68228
2 changed files with 22 additions and 7 deletions

View File

@ -9,8 +9,6 @@ typealias ScenarioAndTypeReceiver<T, I> = suspend Scenario.(I) -> T
data class Scenario(
val bot: TelegramBot,
val flowsUpdatesFilter: FlowsUpdatesFilter,
val scope: CoroutineScope
val scope: CoroutineScope,
val flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter()
)

View File

@ -1,17 +1,34 @@
package dev.inmo.tgbotapi.extensions.steps
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
import kotlinx.coroutines.CoroutineScope
suspend fun TelegramBot.buildScenarios(
scope: CoroutineScope,
flowUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
flowUpdatesFilter: FlowsUpdatesFilter,
block: ScenarioReceiver<Unit>
) {
Scenario(
this,
flowUpdatesFilter,
scope
scope,
flowUpdatesFilter
).block()
}
suspend fun TelegramBot.buildScenarios(
scope: CoroutineScope,
block: ScenarioReceiver<Unit>
) = FlowsUpdatesFilter().also {
buildScenarios(
scope,
it,
block
)
startGettingOfUpdatesByLongPolling(
updatesFilter = it,
scope = scope
)
}