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:
parent
00873a255c
commit
30e6f68228
@ -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()
|
||||
)
|
||||
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user