Finally caved in and created a command table. It's just going to get too messy with @-commands doing straight module lookups, plus the dict is probably a little faster. Feel free to start moving non-privved @-commands to commands_general and vice-versa since we now have the ability to do so.
This commit is contained in:
parent
2fc06adcfa
commit
ac32ab05c1
7 changed files with 174 additions and 43 deletions
61
cmdtable.py
Normal file
61
cmdtable.py
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import commands_unloggedin
|
||||
import commands_general
|
||||
import commands_privileged
|
||||
import commands_comsys
|
||||
|
||||
# Unlogged-in Command Table
|
||||
uncon_ctable = {
|
||||
"connect": commands_unloggedin.cmd_connect,
|
||||
"create": commands_unloggedin.cmd_create,
|
||||
"quit": commands_unloggedin.cmd_quit,
|
||||
}
|
||||
|
||||
# Command Table
|
||||
ctable = {
|
||||
"drop": commands_general.cmd_drop,
|
||||
"examine": commands_general.cmd_examine,
|
||||
"get": commands_general.cmd_get,
|
||||
"help": commands_general.cmd_help,
|
||||
"idle": commands_general.cmd_idle,
|
||||
"inventory": commands_general.cmd_inventory,
|
||||
"look": commands_general.cmd_look,
|
||||
"page": commands_general.cmd_page,
|
||||
"pose": commands_general.cmd_pose,
|
||||
"quit": commands_general.cmd_quit,
|
||||
"say": commands_general.cmd_say,
|
||||
"time": commands_general.cmd_time,
|
||||
"uptime": commands_general.cmd_uptime,
|
||||
"version": commands_general.cmd_version,
|
||||
"who": commands_general.cmd_who,
|
||||
"@ccreate": commands_privileged.cmd_ccreate,
|
||||
"@create": commands_privileged.cmd_create,
|
||||
"@description": commands_privileged.cmd_description,
|
||||
"@destroy": commands_privileged.cmd_destroy,
|
||||
"@dig": commands_privileged.cmd_dig,
|
||||
"@emit": commands_privileged.cmd_emit,
|
||||
"@find": commands_privileged.cmd_find,
|
||||
"@link": commands_privileged.cmd_link,
|
||||
"@list": commands_privileged.cmd_list,
|
||||
"@name": commands_privileged.cmd_name,
|
||||
"@nextfree": commands_privileged.cmd_nextfree,
|
||||
"@newpassword": commands_privileged.cmd_newpassword,
|
||||
"@open": commands_privileged.cmd_open,
|
||||
"@password": commands_privileged.cmd_password,
|
||||
"@reload": commands_privileged.cmd_reload,
|
||||
"@set": commands_privileged.cmd_set,
|
||||
"@shutdown": commands_privileged.cmd_shutdown,
|
||||
"@teleport": commands_privileged.cmd_teleport,
|
||||
"@unlink": commands_privileged.cmd_unlink,
|
||||
"@wall": commands_privileged.cmd_wall,
|
||||
|
||||
}
|
||||
|
||||
def return_cfunc(func_name, unlogged_cmd=False):
|
||||
"""
|
||||
Returns a reerence to the command's function. If there are no matches,
|
||||
returns false.
|
||||
"""
|
||||
if not unlogged_cmd:
|
||||
return ctable.get(func_name, False)
|
||||
else:
|
||||
return uncon_ctable.get(func_name, False)
|
||||
Loading…
Add table
Add a link
Reference in a new issue