Revamp how commands are loaded. This will now allow for easy addition of custom commands and over-riding existing Evennia-supplied commands.

This commit is contained in:
Greg Taylor 2009-01-27 15:21:15 +00:00
parent 848c7da075
commit 4ca5a4a7bf
12 changed files with 165 additions and 107 deletions

View file

@ -1,5 +1,5 @@
"""
Command Table Entries
Command Table Module
---------------------
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
@ -8,17 +8,12 @@ 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.
Commands are located under evennia/src/commands. server.py imports these
based on the value of settings.COMMAND_MODULES and
settings.CUSTOM_COMMAND_MODULES. Each module imports cmdtable.py and runs
add_command on the command table each command belongs to.
"""
import commands.general
import commands.paging
import commands.parents
import commands.privileged
import commands.comsys
import commands.unloggedin
import commands.info
import commands.objmanip
import commands.search
import logger
class CommandTable(object):
"""
@ -50,90 +45,9 @@ class CommandTable(object):
return self.ctable.get(func_name, False)
"""
Global command table for logged in users.
Command tables
"""
# Global command table, for authenticated 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("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),
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),
GLOBAL_CMD_TABLE.add_command("page", commands.paging.cmd_page),
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")),
GLOBAL_CMD_TABLE.add_command("@cpattr", commands.objmanip.cmd_cpattr,
priv_tuple=("genperms.builder")),
GLOBAL_CMD_TABLE.add_command("@chown", commands.objmanip.cmd_chown),
GLOBAL_CMD_TABLE.add_command("@cwho", commands.comsys.cmd_cwho),
GLOBAL_CMD_TABLE.add_command("@chzone", commands.objmanip.cmd_chzone),
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")),
#GLOBAL_CMD_TABLE.add_command("@pemit", commands.general.cmd_pemit),
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")),
GLOBAL_CMD_TABLE.add_command("@list", commands.info.cmd_list),
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),
GLOBAL_CMD_TABLE.add_command("@parent", commands.parents.cmd_parent,
priv_tuple=("genperms.builder")),
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),
GLOBAL_CMD_TABLE.add_command("@search", commands.search.cmd_search,
priv_tuple=("genperms.builder")),
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)
GLOBAL_UNCON_CMD_TABLE.add_command("quit", commands.unloggedin.cmd_quit)
# Global unconnected command table, for unauthenticated users.
GLOBAL_UNCON_CMD_TABLE = CommandTable()

View file

@ -7,6 +7,7 @@ import src.comsys
from src import defines_global
from src import ansi
from src.util import functions_general
from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_addcom(command):
"""
@ -49,6 +50,7 @@ def cmd_addcom(command):
src.comsys.send_cmessage(chan_name_parsed, join_msg)
else:
source_object.emit_to("Could not find channel %s." % (chan_name,))
GLOBAL_CMD_TABLE.add_command("addcom", cmd_addcom),
def cmd_delcom(command):
"""
@ -75,6 +77,7 @@ def cmd_delcom(command):
leave_msg = "[%s] %s has left the channel." % \
(chan_name, source_object.get_name(show_dbref=False))
src.comsys.send_cmessage(chan_name, leave_msg)
GLOBAL_CMD_TABLE.add_command("delcom", cmd_delcom),
def cmd_comlist(command):
"""
@ -93,6 +96,7 @@ def cmd_comlist(command):
source_object.emit_to("%-9.9s %-19.19s %s" %
(chan, session.channels_subscribed[chan][0], chan_on))
source_object.emit_to("-- End of comlist --")
GLOBAL_CMD_TABLE.add_command("comlist", cmd_comlist),
def cmd_allcom(command):
"""
@ -129,6 +133,7 @@ def cmd_clist(command):
('-', '-', chan.get_name(), chan.get_owner().get_name(),
'No Description'))
source_object.emit_to("-- End of Channel List --")
GLOBAL_CMD_TABLE.add_command("@clist", cmd_clist),
def cmd_cdestroy(command):
"""
@ -155,6 +160,8 @@ def cmd_cdestroy(command):
else:
source_object.emit_to("Permission denied.")
return
GLOBAL_CMD_TABLE.add_command("@cdestroy", cmd_cdestroy,
priv_tuple=("objects.delete_commchannel")),
def cmd_cset(command):
"""
@ -246,6 +253,7 @@ def cmd_cemit(command):
if not "quiet" in command.command_switches:
source_object.emit_to("Sent - %s" % (name_matches[0],))
src.comsys.send_cmessage(cname_parsed, final_cmessage)
GLOBAL_CMD_TABLE.add_command("@cemit", cmd_cemit),
def cmd_cwho(command):
"""
@ -283,6 +291,7 @@ def cmd_cwho(command):
else:
source_object.emit_to("No channel with that name was found.")
return
GLOBAL_CMD_TABLE.add_command("@cwho", cmd_cwho),
def cmd_ccreate(command):
"""
@ -310,6 +319,8 @@ def cmd_ccreate(command):
# Create and set the object up.
new_chan = src.comsys.create_channel(cname, source_object)
source_object.emit_to("Channel %s created." % (new_chan.get_name(),))
GLOBAL_CMD_TABLE.add_command("@ccreate", cmd_ccreate,
priv_tuple=("objects.add_commchannel")),
def cmd_cchown(command):
"""

View file

@ -3,9 +3,7 @@ Generic command module. Pretty much every command should go here for
now.
"""
import time
from django.conf import settings
from src.config.models import ConfigValue
from src.helpsys.models import HelpEntry
from src.objects.models import Object
@ -13,6 +11,7 @@ from src import defines_global
from src import session_mgr
from src import ansi
from src.util import functions_general
from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_password(command):
"""
@ -55,12 +54,14 @@ def cmd_password(command):
uaccount.set_password(newpass)
uaccount.save()
source_object.emit_to("Password changed.")
GLOBAL_CMD_TABLE.add_command("@password", cmd_password)
def cmd_pemit(command):
"""
Emits something to a player.
"""
# TODO: Implement cmd_pemit
#GLOBAL_CMD_TABLE.add_command("@pemit", cmd_pemit)
def cmd_emit(command):
"""
@ -72,6 +73,8 @@ def cmd_emit(command):
command.source_object.get_location().emit_to_contents(message)
else:
command.source_object.emit_to("Emit what?")
GLOBAL_CMD_TABLE.add_command("@emit", cmd_emit,
priv_tuple=("genperms.announce")),
def cmd_wall(command):
"""
@ -86,6 +89,8 @@ def cmd_wall(command):
message = "%s shouts \"%s\"" % (
command.source_object.get_name(show_dbref=False), wallstring)
session_mgr.announce_all(message)
GLOBAL_CMD_TABLE.add_command("@wall", cmd_wall,
priv_tuple=("genperms.announce"))
def cmd_idle(command):
"""
@ -93,6 +98,7 @@ def cmd_idle(command):
his screen.
"""
pass
GLOBAL_CMD_TABLE.add_command("idle", cmd_idle)
def cmd_inventory(command):
"""
@ -111,6 +117,7 @@ def cmd_inventory(command):
money_name = ConfigValue.objects.get_configvalue("MONEY_NAME_PLURAL")
source_object.emit_to("You have %d %s." % (money, money_name))
GLOBAL_CMD_TABLE.add_command("inventory", cmd_inventory)
def cmd_look(command):
"""
@ -138,6 +145,7 @@ def cmd_look(command):
target_obj.scriptlink.a_desc({
"target_obj": source_object
})
GLOBAL_CMD_TABLE.add_command("look", cmd_look)
def cmd_get(command):
"""
@ -179,6 +187,7 @@ def cmd_get(command):
target_obj.scriptlink.a_get({
"pobject": source_object
})
GLOBAL_CMD_TABLE.add_command("get", cmd_get)
def cmd_drop(command):
"""
@ -212,6 +221,7 @@ def cmd_drop(command):
target_obj.scriptlink.a_drop({
"pobject": source_object
})
GLOBAL_CMD_TABLE.add_command("drop", cmd_drop),
def cmd_examine(command):
"""
@ -327,6 +337,7 @@ def cmd_examine(command):
source_object.emit_to("Home: %s" % (target_obj.get_home(),))
# This obviously isn't valid for rooms.
source_object.emit_to("Location: %s" % (target_obj.get_location(),))
GLOBAL_CMD_TABLE.add_command("examine", cmd_examine)
def cmd_quit(command):
"""
@ -336,6 +347,7 @@ def cmd_quit(command):
session = command.session
session.msg("Quitting!")
session.handle_close()
GLOBAL_CMD_TABLE.add_command("quit", cmd_quit)
def cmd_who(command):
"""
@ -391,6 +403,9 @@ def cmd_who(command):
retval += '%d Players logged in.' % (len(session_list),)
source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("doing", cmd_who,
extra_vals={"show_session_data": False})
GLOBAL_CMD_TABLE.add_command("who", cmd_who)
def cmd_say(command):
"""
@ -413,6 +428,7 @@ def cmd_say(command):
source_object.get_location().emit_to_contents(emit_string,
exclude=source_object)
GLOBAL_CMD_TABLE.add_command("say", cmd_say)
def cmd_pose(command):
"""
@ -436,6 +452,7 @@ def cmd_pose(command):
pose_string)
source_object.get_location().emit_to_contents(sent_msg)
GLOBAL_CMD_TABLE.add_command("pose", cmd_pose)
def cmd_help(command):
"""
@ -469,3 +486,4 @@ def cmd_help(command):
else:
topic = topics[0]
source_object.emit_to("\n\r"+ topic.get_entrytext_ingame())
GLOBAL_CMD_TABLE.add_command("help", cmd_help)

View file

@ -4,17 +4,16 @@ the server instance.
"""
import os
import time
from src.util import functions_general
if not functions_general.host_os_is('nt'):
# Don't import the resource module if the host OS is Windows.
import resource
import django
from src.objects.models import Object
from src import scheduler
from src import defines_global
from src import flags
from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_version(command):
"""
@ -25,6 +24,7 @@ def cmd_version(command):
retval += " Django %s\n\r" % (django.get_version())
retval += "-"*50
command.source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("version", cmd_version),
def cmd_time(command):
"""
@ -32,6 +32,7 @@ def cmd_time(command):
"""
command.source_object.emit_to('Current server time : %s' %
(time.strftime('%a %b %d %H:%M:%S %Y (%Z)', time.localtime(),)))
GLOBAL_CMD_TABLE.add_command("time", cmd_time),
def cmd_uptime(command):
"""
@ -53,6 +54,7 @@ def cmd_uptime(command):
loadavg = os.getloadavg()
source_object.emit_to('Server load (1 min) : %.2f' %
loadavg[0])
GLOBAL_CMD_TABLE.add_command("uptime", cmd_uptime),
def cmd_list(command):
"""
@ -95,6 +97,7 @@ def cmd_list(command):
source_object.emit_to("Flags: "+" ".join(flags.SERVER_FLAGS))
else:
source_object.emit_to(msg_invalid)
GLOBAL_CMD_TABLE.add_command("@list", cmd_list),
def cmd_ps(command):
"""
@ -109,6 +112,8 @@ def cmd_ps(command):
scheduler.get_event_interval(event),
scheduler.get_event_description(event)))
source_object.emit_to("Totals: %d interval events" % (len(scheduler.schedule),))
GLOBAL_CMD_TABLE.add_command("@ps", cmd_ps,
priv_tuple=("genperms.process_control")),
def cmd_stats(command):
"""
@ -124,3 +129,4 @@ def cmd_stats(command):
stats_dict["things"],
stats_dict["players"],
stats_dict["garbage"]))
GLOBAL_CMD_TABLE.add_command("@stats", cmd_stats),

View file

@ -5,6 +5,7 @@ from src.objects.models import Object, Attribute
# We'll import this as the full path to avoid local variable clashes.
import src.flags
from src import ansi
from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_teleport(command):
"""
@ -61,6 +62,8 @@ def cmd_teleport(command):
source_object.emit_to("Teleported.")
source_object.move_to(target_obj, quiet=tel_quietly)
GLOBAL_CMD_TABLE.add_command("@teleport", cmd_teleport,
priv_tuple=("genperms.builder"))
def cmd_alias(command):
"""
@ -107,6 +110,7 @@ def cmd_alias(command):
# Duplicates were found.
source_object.emit_to("Alias '%s' is already in use." % (new_alias,))
return
GLOBAL_CMD_TABLE.add_command("@alias", cmd_alias)
def cmd_wipe(command):
"""
@ -158,6 +162,7 @@ def cmd_wipe(command):
target_obj.clear_attribute(attr.get_name())
source_object.emit_to("%s - %d attributes wiped." % (target_obj.get_name(),
len(attr_matches)))
GLOBAL_CMD_TABLE.add_command("@wipe", cmd_wipe)
def cmd_set(command):
"""
@ -224,11 +229,12 @@ def cmd_set(command):
else:
# We're setting the flag.
if not src.flags.is_modifiable_flag(flag):
source_object.emit_to("You can't set/unset the flag - %s." % (flag,))
source_object.emit_to("You can't set/unset the flag - %s." % flag)
else:
source_object.emit_to('%s - %s set.' % (victim.get_name(),
flag.upper(),))
victim.set_flag(flag, True)
GLOBAL_CMD_TABLE.add_command("@set", cmd_set)
def cmd_find(command):
"""
@ -251,6 +257,8 @@ def cmd_find(command):
source_object.emit_to("%d matches returned." % (len(results),))
else:
source_object.emit_to("No name matches found for: %s" % (searchstring,))
GLOBAL_CMD_TABLE.add_command("@find", cmd_find,
priv_tuple=("genperms.builder"))
def cmd_create(command):
"""
@ -270,6 +278,8 @@ def cmd_create(command):
new_object = Object.objects.create_object(odat)
source_object.emit_to("You create a new thing: %s" % (new_object,))
GLOBAL_CMD_TABLE.add_command("@create", cmd_create,
priv_tuple=("genperms.builder"))
def cmd_cpattr(command):
"""
@ -339,13 +349,17 @@ def cmd_cpattr(command):
tar_obj.set_attribute(tar_attr_string, src_attr_contents)
source_object.emit_to("%s - %s set." % (tar_obj.get_name(),
tar_attr_string))
GLOBAL_CMD_TABLE.add_command("@cpattr", cmd_cpattr,
priv_tuple=("genperms.builder"))
def cmd_nextfree(command):
"""
Returns the next free object number.
"""
nextfree = Object.objects.get_nextfree_dbnum()
command.source_object.emit_to("Next free object number: #%s" % (nextfree,))
command.source_object.emit_to("Next free object number: #%s" % nextfree)
GLOBAL_CMD_TABLE.add_command("@nextfree", cmd_nextfree,
priv_tuple=("genperms.builder"))
def cmd_open(command):
"""
@ -415,7 +429,9 @@ def cmd_open(command):
"home": None}
new_object = Object.objects.create_object(odat)
source_object.emit_to("You open an unlinked exit - %s" % (new_object,))
source_object.emit_to("You open an unlinked exit - %s" % new_object)
GLOBAL_CMD_TABLE.add_command("@open", cmd_open,
priv_tuple=("genperms.builder"))
def cmd_chown(command):
"""
@ -466,6 +482,7 @@ def cmd_chown(command):
# We haven't provided a target.
source_object.emit_to("Who should be the new owner of the object?")
return
GLOBAL_CMD_TABLE.add_command("@chown", cmd_chown)
def cmd_chzone(command):
"""
@ -517,6 +534,7 @@ def cmd_chzone(command):
# We haven't provided a target zone.
source_object.emit_to("What should the object's zone be set to?")
return
GLOBAL_CMD_TABLE.add_command("@chzone", cmd_chzone)
def cmd_link(command):
"""
@ -567,6 +585,8 @@ def cmd_link(command):
# We haven't provided a target.
source_object.emit_to("You must provide a destination to link to.")
return
GLOBAL_CMD_TABLE.add_command("@link", cmd_link,
priv_tuple=("genperms.builder"))
def cmd_unlink(command):
"""
@ -590,7 +610,9 @@ def cmd_unlink(command):
return
target_obj.set_home(None)
source_object.emit_to("You have unlinked %s." % (target_obj.get_name(),))
source_object.emit_to("You have unlinked %s." % target_obj.get_name())
GLOBAL_CMD_TABLE.add_command("@unlink", cmd_unlink,
priv_tuple=("genperms.builder"))
def cmd_dig(command):
"""
@ -612,6 +634,8 @@ def cmd_dig(command):
new_object = Object.objects.create_object(odat)
source_object.emit_to("You create a new room: %s" % (new_object,))
GLOBAL_CMD_TABLE.add_command("@dig", cmd_dig,
priv_tuple=("genperms.builder"))
def cmd_name(command):
"""
@ -647,6 +671,7 @@ def cmd_name(command):
source_object.emit_to("You have renamed %s to %s." % (target_obj,
ansi_name))
target_obj.set_name(new_name)
GLOBAL_CMD_TABLE.add_command("@name", cmd_name)
def cmd_description(command):
"""
@ -680,6 +705,7 @@ def cmd_description(command):
else:
source_object.emit_to("%s - DESCRIPTION set." % target_obj)
target_obj.set_description(new_desc)
GLOBAL_CMD_TABLE.add_command("@describe", cmd_description)
def cmd_destroy(command):
"""
@ -717,3 +743,5 @@ def cmd_destroy(command):
source_object.emit_to("You destroy %s." % target_obj.get_name())
target_obj.destroy()
GLOBAL_CMD_TABLE.add_command("@destroy", cmd_destroy,
priv_tuple=("genperms.builder"))

View file

@ -3,6 +3,7 @@ Paging command and support functions.
"""
from src.objects.models import Object
from src import defines_global
from src.cmdtable import GLOBAL_CMD_TABLE
def get_last_paged_objects(source_object):
"""
@ -125,4 +126,5 @@ def cmd_page(command):
# Now set the LASTPAGED attribute
source_object.set_attribute("LASTPAGED", ','.join(
["#%d" % (x.id) for x in targets]))
["#%d" % (x.id) for x in targets]))
GLOBAL_CMD_TABLE.add_command("page", cmd_page),

View file

@ -2,6 +2,7 @@
Contains commands for managing script parents.
"""
from src import scripthandler
from src.cmdtable import GLOBAL_CMD_TABLE
def clear_cached_scripts(command):
"""
@ -42,4 +43,6 @@ def cmd_parent(command):
clear_cached_scripts(command)
return
command.source_object.emit_to("Must be specified with one of the following switches: showcache, clearcache")
command.source_object.emit_to("Must be specified with one of the following switches: showcache, clearcache")
GLOBAL_CMD_TABLE.add_command("@parent", cmd_parent,
priv_tuple=("genperms.builder")),

View file

@ -7,12 +7,15 @@ from src import defines_global
from src import ansi
from src import session_mgr
from src.util import functions_general
from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_reload(command):
"""
Reloads all modules.
"""
command.source_object.emit_to("To be implemented...")
GLOBAL_CMD_TABLE.add_command("@reload", cmd_reload,
priv_tuple=("genperms.process_control")),
def cmd_boot(command):
"""
@ -84,6 +87,8 @@ def cmd_boot(command):
boot.disconnectClient()
session_mgr.remove_session(boot)
return
GLOBAL_CMD_TABLE.add_command("@boot", cmd_boot,
priv_tuple=("genperms.manage_players"))
def cmd_newpassword(command):
"""
@ -120,6 +125,8 @@ def cmd_newpassword(command):
source_object.emit_to("%s - PASSWORD set." % (target_obj.get_name(),))
target_obj.emit_to("%s has changed your password." %
(source_object.get_name(show_dbref=False),))
GLOBAL_CMD_TABLE.add_command("@newpassword", cmd_newpassword,
priv_tuple=("genperms.manage_players"))
def cmd_shutdown(command):
"""
@ -128,3 +135,5 @@ def cmd_shutdown(command):
command.source_object.emit_to('Shutting down...')
print 'Server shutdown by %s' % (command.source_object.get_name(show_dbref=False),)
command.session.server.shutdown()
GLOBAL_CMD_TABLE.add_command("@shutdown", cmd_shutdown,
priv_tuple=("genperms.process_control"))

View file

@ -4,6 +4,7 @@ Implementation of the @search command that resembles MUX2.
from django.db.models import Q
from src.objects.models import Object
from src import defines_global
from src.cmdtable import GLOBAL_CMD_TABLE
def _parse_restriction_split(source_object, restriction_split, search_low_dbnum,
search_high_dbnum):
@ -229,4 +230,6 @@ def cmd_search(command):
if search_query is None:
return
display_results(source_object, search_query)
display_results(source_object, search_query)
GLOBAL_CMD_TABLE.add_command("@search", cmd_search,
priv_tuple=("genperms.builder")),

View file

@ -6,6 +6,7 @@ from django.contrib.auth.models import User
from src.objects.models import Attribute, Object
from src import defines_global
from src.util import functions_general
from src.cmdtable import GLOBAL_UNCON_CMD_TABLE
def cmd_connect(command):
"""
@ -44,6 +45,7 @@ def cmd_connect(command):
else:
uname = user.username
session.login(user)
GLOBAL_UNCON_CMD_TABLE.add_command("connect", cmd_connect)
def cmd_create(command):
"""
@ -95,6 +97,7 @@ def cmd_create(command):
session.msg("Your password must be 3 characters or longer.")
else:
Object.objects.create_user(command, uname, email, password)
GLOBAL_UNCON_CMD_TABLE.add_command("create", cmd_create)
def cmd_quit(command):
"""
@ -105,3 +108,4 @@ def cmd_quit(command):
session = command.session
session.msg("Disconnecting...")
session.handle_close()
GLOBAL_UNCON_CMD_TABLE.add_command("quit", cmd_quit)

View file

@ -189,6 +189,46 @@ INSTALLED_APPS = (
'game.web.apps.website',
)
"""
A tuple of strings representing all of the Evennia (IE: non-custom) commnad
modules that are used at the login screen in the UNLOGGED command table. Do
not modify this directly, add your custom command modules to
CUSTOM_UNLOGGED_COMMAND_MODULES.
"""
UNLOGGED_COMMAND_MODULES = (
'src.commands.unloggedin',
)
"""
Add your custom command modules under game/gamesrc/commands and to this list.
These will be loaded after the Evennia codebase modules, meaning that any
duplicate command names will be overridden by your version.
"""
CUSTOM_UNLOGGED_COMMAND_MODULES = ()
"""
A tuple of strings representing all of the Evennia (IE: non-custom)
command modules. Do not modify this directly, add your custom command
modules to CUSTOM_COMMAND_MODULES.
"""
COMMAND_MODULES = (
'src.commands.comsys',
'src.commands.general',
'src.commands.info',
'src.commands.objmanip',
'src.commands.paging',
'src.commands.parents',
'src.commands.privileged',
'src.commands.search',
)
"""
Add your custom command modules under game/gamesrc/commands and to this list.
These will be loaded after the Evennia codebase modules, meaning that any
duplicate command names will be overridden by your version.
"""
CUSTOM_COMMAND_MODULES = ()
# If django_extensions is present, import it and install it. Otherwise fail
# silently.
try:

View file

@ -43,6 +43,8 @@ class EvenniaService(service.Service):
for port in settings.GAMEPORTS:
print ' * %s' % (port)
# Populate the command table.
self.load_command_table()
# Cache the aliases from the database for quick access.
alias_mgr.load_cmd_aliases()
@ -62,6 +64,24 @@ class EvenniaService(service.Service):
cursor.execute("PRAGMA synchronous=OFF")
cursor.execute("PRAGMA count_changes=OFF")
cursor.execute("PRAGMA temp_store=2")
def load_command_table(self):
"""
Imports command modules and loads them into the command tables.
"""
# Combine the tuples of command modules to load.
cmd_modules = settings.COMMAND_MODULES +\
settings.CUSTOM_COMMAND_MODULES +\
settings.UNLOGGED_COMMAND_MODULES +\
settings.CUSTOM_UNLOGGED_COMMAND_MODULES
# Import the command modules, which populates the command tables.
for cmd_mod in cmd_modules:
try:
__import__(cmd_mod)
except ImportError:
logger.log_errmsg("ERROR: Unable to load command module: %s" % cmd_mod)
continue
"""
BEGIN GENERAL METHODS