mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 01:06:32 +01:00
Add an extra_vars element to the command table that allows extra variables to be passed through the command table. Also added DOING ala MUX.
This commit is contained in:
parent
f2d4b3aba4
commit
7280eaf803
3 changed files with 15 additions and 3 deletions
|
|
@ -38,6 +38,8 @@ class Command(object):
|
|||
command_argument = None
|
||||
# A reference to the command function looked up in a command table.
|
||||
command_function = None
|
||||
# An optional dictionary that is passed through the command table as extra_vars.
|
||||
extra_vars = None
|
||||
|
||||
def parse_command_switches(self):
|
||||
"""
|
||||
|
|
@ -243,6 +245,7 @@ def command_table_lookup(command, command_table, eval_perms=True):
|
|||
raise ExitCommandHandler
|
||||
# If flow reaches this point, user has perms and command is ready.
|
||||
command.command_function = cmdtuple[0]
|
||||
command.extra_vars = cmdtuple[2]
|
||||
|
||||
def handle(command):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -30,15 +30,17 @@ class CommandTable(object):
|
|||
# This ensures there are no leftovers when the class is instantiated.
|
||||
self.ctable = {}
|
||||
|
||||
def add_command(self, command_string, function, priv_tuple=None):
|
||||
def add_command(self, command_string, function, priv_tuple=None,
|
||||
extra_vals=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.
|
||||
extra_vals: (dict) Dictionary to add to the Command object.
|
||||
"""
|
||||
self.ctable[command_string] = (function, priv_tuple)
|
||||
self.ctable[command_string] = (function, priv_tuple, extra_vals)
|
||||
|
||||
def get_command_tuple(self, func_name):
|
||||
"""
|
||||
|
|
@ -54,6 +56,8 @@ 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("doing", commands.general.cmd_who,
|
||||
extra_vals={"show_session_data": False}),
|
||||
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),
|
||||
|
|
|
|||
|
|
@ -347,7 +347,12 @@ def cmd_who(command):
|
|||
session_list = session_mgr.get_session_list()
|
||||
session = command.session
|
||||
pobject = session.get_pobject()
|
||||
show_session_data = pobject.user_has_perm("genperms.see_session_data")
|
||||
|
||||
# In the case of the DOING command, don't show session data regardless.
|
||||
if command.extra_vars and command.extra_vars.get("show_session_data", None) == False:
|
||||
show_session_data = False
|
||||
else:
|
||||
show_session_data = pobject.user_has_perm("genperms.see_session_data")
|
||||
|
||||
# Only those with the see_session_data or superuser status can see
|
||||
# session details.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue