- # 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)
+ # the pairings of user state and command to run
+ handler_dictionary = {
+ "active": handler_active,
+ "entering account name": handler_entering_account_name,
+ "checking password": handler_checking_password,
+ "checking new account name": handler_checking_new_account_name,
+ "entering new password": handler_entering_new_password,
+ "verifying new password": handler_verifying_new_password
+ }
+ # check to make sure the state is expected, then call that handler
+ if user.state in handler_dictionary.keys():
+ handler_dictionary[user.state](user, input_data)