Behaviour Builder with FSM

Behaviour builder with FSM is based on the MicroUtils FSM. There are several important things in FSM:

StatesMachine have two methods:

The most based way to create StatesMachine and register StateHandlers looks like in the next snippet:

buildFSM<TrafficLightState> {
  	strictlyOn<SomeState> {
      	// state handling
    }
}.start(CoroutineScope(...)).join()

Full example
You may find full example of FSM usage in the tests of FSM in MicroUtils

So, you must do next steps before you will launch your bot with FSM:

Bot with FSM

There are several extensions for TelegramBot to create your bot with FSM:

All of them will take as an callback some object with type CustomBehaviourContextReceiver and will looks like in the next snippet:

telegramBotWithBehaviourAndFSMAndStartLongPolling<YourStateType>("BOT_TOKEN") {
    // here you may use any operations from BehaviourBuilder
    // here you may use any operations from BehaviourContextWithFSMBuilder like strictlyOn and others
}

Examples


Revision #4
Created 2 August 2021 17:25:34 by InsanusMokrassar
Updated 26 March 2022 15:10:39 by InsanusMokrassar