bfcc117a by Barry

Turned on the error handling in commandhandler

1 parent 4112e223
......@@ -32,29 +32,29 @@ class CommandHandler(object):
locals()['tokens'] = tokens
locals()['next_command'] = None
# try:
if cmd in utils.load_object_from_file('rooms/' + players[id]["room"] + '.json').get('exits'):
params = cmd + " " + params.lower().strip()
cmd = "go"
if cmd == '':
try:
if cmd in utils.load_object_from_file('rooms/' + players[id]["room"] + '.json').get('exits'):
params = cmd + " " + params.lower().strip()
cmd = "go"
if cmd == '':
return True
command = cmd
ldict = locals()
with open('commands/{}.txt'.format(cmd), 'r', encoding='utf-8') as f:
command_text = f.read()
exec(command_text, globals(), ldict)
del command_text
if ldict['next_command'] != None:
locals()['tokens'] = []
tokens = []
with open('commands/{}.txt'.format(ldict['next_command']), 'r', encoding='utf-8') as f:
exec(f.read())
del ldict
return True
command = cmd
ldict = locals()
with open('commands/{}.txt'.format(cmd), 'r', encoding='utf-8') as f:
command_text = f.read()
exec(command_text, globals(), ldict)
del command_text
if ldict['next_command'] != None:
locals()['tokens'] = []
tokens = []
with open('commands/{}.txt'.format(ldict['next_command']), 'r', encoding='utf-8') as f:
exec(f.read())
del ldict
return True
# except Exception as e:
# print('Something happened...')
# print(e)
# mud.send_message(id, "Unknown command '{}'".format(cmd))
# return False
except Exception as e:
print('Something happened...')
print(e)
mud.send_message(id, "Unknown command '{}'".format(cmd))
return False
......