mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-12-04 09:33:44 +00:00
small update of scenarios
This commit is contained in:
1 parent
00873a255c
commit
30e6f68228
2 files changed
+22
-7
No files matched your search
+2
-4
@@ -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()
|
||||
)
|
||||
|
||||
|
||||
+20
-3
@@ -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
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user