Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Barry
/
esp8266-Mud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
bfcc117a
authored
2018-05-07 01:48:43 -0700
by
Barry
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Turned on the error handling in commandhandler
1 parent
4112e223
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
commandhandler.py
commandhandler.py
View file @
bfcc117
...
...
@@ -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
...
...
Please
register
or
sign in
to post a comment