@@ -5,15 +5,22 @@ import dev.inmo.kslog.common.setDefaultKSLog
55import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
66import dev.inmo.tgbotapi.extensions.api.bot.getMe
77import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextData
8+ import dev.inmo.tgbotapi.extensions.behaviour_builder.buildSubcontextInitialAction
89import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
910import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
11+ import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
12+ import dev.inmo.tgbotapi.types.update.abstracts.Update
1013import kotlinx.coroutines.CoroutineScope
1114import kotlinx.coroutines.Dispatchers
1215
13- private var BehaviourContextData .update
14- get() = get(" update" )
16+ private var BehaviourContextData .update: Update ?
17+ get() = get(" update" ) as ? Update
1518 set(value) = set(" update" , value)
1619
20+ private var BehaviourContextData .commonMessage: CommonMessage <* >?
21+ get() = get(" commonMessage" ) as ? CommonMessage <* >
22+ set(value) = set(" commonMessage" , value)
23+
1724/* *
1825 * This place can be the playground for your code.
1926 */
@@ -45,8 +52,10 @@ suspend fun main(vararg args: String) {
4552 }
4653 }
4754 },
48- subcontextInitialAction = {
49- data.update = it
55+ subcontextInitialAction = buildSubcontextInitialAction {
56+ add {
57+ data.update = it
58+ }
5059 }
5160 ) {
5261 // start here!!
@@ -55,6 +64,17 @@ suspend fun main(vararg args: String) {
5564
5665 onCommand(" start" ) {
5766 println (data.update)
67+ println (data.commonMessage)
68+ }
69+
70+ onCommand(
71+ " additional_command" ,
72+ additionalSubcontextInitialAction = { update, commonMessage ->
73+ data.commonMessage = commonMessage
74+ }
75+ ) {
76+ println (data.update)
77+ println (data.commonMessage)
5878 }
5979
6080 allUpdatesFlow.subscribeSafelyWithoutExceptions(this ) {
0 commit comments