-
Notifications
You must be signed in to change notification settings - Fork 71
/
fsm.py
31 lines (23 loc) · 870 Bytes
/
fsm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from transitions.extensions import GraphMachine
class TocMachine(GraphMachine):
def __init__(self, **machine_configs):
self.machine = GraphMachine(
model = self,
**machine_configs
)
def is_going_to_state1(self, update):
text = update.message.text
return text.lower() == 'go to state1'
def is_going_to_state2(self, update):
text = update.message.text
return text.lower() == 'go to state2'
def on_enter_state1(self, update):
update.message.reply_text("I'm entering state1")
self.go_back(update)
def on_exit_state1(self, update):
print('Leaving state1')
def on_enter_state2(self, update):
update.message.reply_text("I'm entering state2")
self.go_back(update)
def on_exit_state2(self, update):
print('Leaving state2')