- # TODO: change this to use a dict
- if user.state == "active": handler_active(user, input)
- elif user.state == "entering account name": handler_entering_account_name(user, input)
- elif user.state == "checking password": handler_checking_password(user, input)
- elif user.state == "checking new account name": handler_checking_new_account_name(user, input)
- elif user.state == "entering new password": handler_entering_new_password(user, input)
- elif user.state == "verifying new password": handler_verifying_new_password(user, input)
-
- # if there's input with an unknown user state, something is wrong
- else: handler_fallthrough(user, input)
+ # check to make sure the state is expected, then call that handler
+ exec("handler_" + user.state.replace(" ", "_") + "(user)")