2007-05-22 15:11:56 +00:00
|
|
|
"""
|
|
|
|
|
Command Table Entries
|
|
|
|
|
---------------------
|
|
|
|
|
Each command entry consists of a key and a tuple containing a reference to the
|
|
|
|
|
command's function, and a tuple of the permissions to match against. The user
|
|
|
|
|
only need have one of the permissions in the permissions tuple to gain
|
|
|
|
|
access to the command. Obviously, super users don't have to worry about this
|
|
|
|
|
stuff. If the command is open to all (or you want to implement your own
|
|
|
|
|
privilege checking in the command function), use None in place of the
|
|
|
|
|
permissions tuple.
|
|
|
|
|
"""
|
2008-06-15 19:38:39 +00:00
|
|
|
import commands.general
|
2008-12-14 20:21:02 +00:00
|
|
|
import commands.paging
|
2008-12-16 03:36:49 +00:00
|
|
|
import commands.parents
|
2008-06-15 19:38:39 +00:00
|
|
|
import commands.privileged
|
|
|
|
|
import commands.comsys
|
|
|
|
|
import commands.unloggedin
|
|
|
|
|
import commands.info
|
|
|
|
|
import commands.objmanip
|
2009-01-22 14:49:58 +00:00
|
|
|
import commands.search
|
2008-12-14 01:49:37 +00:00
|
|
|
import logger
|
2007-05-22 15:11:56 +00:00
|
|
|
|
2008-12-14 01:49:37 +00:00
|
|
|
class CommandTable(object):
|
2008-06-17 00:38:59 +00:00
|
|
|
"""
|
2008-12-14 01:49:37 +00:00
|
|
|
Stores command tables and performs lookups.
|
2008-06-17 00:38:59 +00:00
|
|
|
"""
|
2009-01-12 18:01:35 +00:00
|
|
|
ctable = None
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
# This ensures there are no leftovers when the class is instantiated.
|
|
|
|
|
self.ctable = {}
|
2008-12-14 01:49:37 +00:00
|
|
|
|
|
|
|
|
def add_command(self, command_string, function, priv_tuple=None):
|
|
|
|
|
"""
|
|
|
|
|
Adds a command to the command table.
|
|
|
|
|
|
|
|
|
|
command_string: (string) Command string (IE: WHO, QUIT, look).
|
|
|
|
|
function: (reference) The command's function.
|
|
|
|
|
priv_tuple: (tuple) String tuple of permissions required for command.
|
|
|
|
|
"""
|
|
|
|
|
self.ctable[command_string] = (function, priv_tuple)
|
|
|
|
|
|
|
|
|
|
def get_command_tuple(self, func_name):
|
|
|
|
|
"""
|
|
|
|
|
Returns a reference to the command's tuple. If there are no matches,
|
|
|
|
|
returns false.
|
|
|
|
|
"""
|
|
|
|
|
return self.ctable.get(func_name, False)
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Global command table for logged in users.
|
|
|
|
|
"""
|
|
|
|
|
GLOBAL_CMD_TABLE = CommandTable()
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("addcom", commands.comsys.cmd_addcom),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("comlist", commands.comsys.cmd_comlist),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("delcom", commands.comsys.cmd_delcom),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("drop", commands.general.cmd_drop),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("examine", commands.general.cmd_examine),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("get", commands.general.cmd_get),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("help", commands.general.cmd_help),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("idle", commands.general.cmd_idle),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("inventory", commands.general.cmd_inventory),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("look", commands.general.cmd_look),
|
2008-12-14 20:21:02 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("page", commands.paging.cmd_page),
|
2008-12-14 01:49:37 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("pose", commands.general.cmd_pose),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("quit", commands.general.cmd_quit),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("say", commands.general.cmd_say),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("time", commands.info.cmd_time),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("uptime", commands.info.cmd_uptime),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("version", commands.info.cmd_version),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("who", commands.general.cmd_who),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@alias", commands.objmanip.cmd_alias),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@boot", commands.privileged.cmd_boot,
|
|
|
|
|
priv_tuple=("genperms.manage_players")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@ccreate", commands.comsys.cmd_ccreate,
|
|
|
|
|
priv_tuple=("objects.add_commchannel")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@cdestroy", commands.comsys.cmd_cdestroy,
|
|
|
|
|
priv_tuple=("objects.delete_commchannel")),
|
2009-01-23 17:25:22 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@cpattr", commands.objmanip.cmd_cpattr,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
2009-01-18 02:34:50 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@chown", commands.objmanip.cmd_chown),
|
2009-01-22 03:19:40 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@cwho", commands.comsys.cmd_cwho),
|
2009-01-18 02:40:57 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@chzone", commands.objmanip.cmd_chzone),
|
2008-12-14 01:49:37 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@cemit", commands.comsys.cmd_cemit),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@clist", commands.comsys.cmd_clist),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@create", commands.objmanip.cmd_create,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@describe", commands.objmanip.cmd_description),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@destroy", commands.objmanip.cmd_destroy,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@dig", commands.objmanip.cmd_dig,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@emit", commands.general.cmd_emit,
|
|
|
|
|
priv_tuple=("genperms.announce")),
|
2008-12-14 20:21:02 +00:00
|
|
|
#GLOBAL_CMD_TABLE.add_command("@pemit", commands.general.cmd_pemit),
|
2008-12-14 01:49:37 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@find", commands.objmanip.cmd_find,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@link", commands.objmanip.cmd_link,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
2009-01-15 05:11:55 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@list", commands.info.cmd_list),
|
2008-12-14 01:49:37 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@name", commands.objmanip.cmd_name),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@nextfree", commands.objmanip.cmd_nextfree,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@newpassword", commands.privileged.cmd_newpassword,
|
|
|
|
|
priv_tuple=("genperms.manage_players")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@open", commands.objmanip.cmd_open,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@password", commands.general.cmd_password),
|
2008-12-16 03:36:49 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@parent", commands.parents.cmd_parent,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
2008-12-14 01:49:37 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@ps", commands.info.cmd_ps,
|
|
|
|
|
priv_tuple=("genperms.process_control")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@reload", commands.privileged.cmd_reload,
|
|
|
|
|
priv_tuple=("genperms.process_control")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@set", commands.objmanip.cmd_set),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@shutdown", commands.privileged.cmd_shutdown,
|
|
|
|
|
priv_tuple=("genperms.process_control")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@stats", commands.info.cmd_stats),
|
2009-01-22 14:49:58 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@search", commands.search.cmd_search,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
2008-12-14 01:49:37 +00:00
|
|
|
GLOBAL_CMD_TABLE.add_command("@teleport", commands.objmanip.cmd_teleport,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@unlink", commands.objmanip.cmd_unlink,
|
|
|
|
|
priv_tuple=("genperms.builder")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@wall", commands.general.cmd_wall,
|
|
|
|
|
priv_tuple=("genperms.announce")),
|
|
|
|
|
GLOBAL_CMD_TABLE.add_command("@wipe", commands.objmanip.cmd_wipe),
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Global unconnected command table, for unauthenticated users.
|
|
|
|
|
"""
|
|
|
|
|
GLOBAL_UNCON_CMD_TABLE = CommandTable()
|
|
|
|
|
GLOBAL_UNCON_CMD_TABLE.add_command("connect", commands.unloggedin.cmd_connect)
|
|
|
|
|
GLOBAL_UNCON_CMD_TABLE.add_command("create", commands.unloggedin.cmd_create)
|
2009-01-23 17:25:22 +00:00
|
|
|
GLOBAL_UNCON_CMD_TABLE.add_command("quit", commands.unloggedin.cmd_quit)
|