Largely rewrote and refactored the help system.

The help entry database structure has changed! You have to resync or purge
your database or your will get problems!

New features:
* Help entry access now fully controlled by evennia permissions
* Categories for each help entry
* All entries are created dynamically, with a See also: footer calculated
  after the current state of the database.
* Indexes and topic list calculated on the fly (alphabetically/after category)
* Added auto-help help entries for all default commands.
* Only shows commands _actually implemented_ - MUX help db moved into 'MUX' category
  which is not shown by default.
* More powerful auto-help markup - supports categories and permissions (and inheritance).
* Global on/off switch for auto-help, when entering production
* Auto_help_override switch for selectively activating auto-help when developing
  new commands (like the old system).
* Refactored State help system; no more risk of overwriting global help entries.
* State help now defers to main help db when no match found; makes system more transparent.
* State help entries also support categories/permissions (state categories are not
  used much though).

Other updates:
* Added more commands to the batch processor
* Many bug-fixes.

/Griatch
This commit is contained in:
Griatch 2009-10-14 18:15:15 +00:00
parent 46e2cd3ecb
commit 8074617285
27 changed files with 1995 additions and 1072 deletions

View file

@ -55,7 +55,7 @@ from src.statetable import GLOBAL_STATE_TABLE
#global defines for storage
STATENAME="_interactive_batch_processor"
STATENAME="interactive batch processor"
CMDSTACKS={} # user:cmdstack pairs (for interactive)
STACKPTRS={} # user:stackpointer pairs (for interactive)
FILENAMES={} # user:filename pairs (for interactive/reload)
@ -161,6 +161,8 @@ def batch_process(source_object, commands):
def cmd_batchprocess(command):
"""
@batchprocess - build from batch file
Usage:
@batchprocess[/interactive] <filename with full path>
@ -198,16 +200,16 @@ def cmd_batchprocess(command):
CMDSTACKS[source_object] = commands
STACKPTRS[source_object] = 0
FILENAMES[source_object] = filename
source_object.emit_to("Interactive mode (h for help).")
source_object.emit_to("\nBatch processor - Interactive mode ...")
show_curr(source_object)
else:
source_object.emit_to("Running Batch processor - Automatic mode ...")
source_object.clear_state()
batch_process(source_object, commands)
source_object.emit_to("%s== Batchfile '%s' applied." % (cgreen,filename))
GLOBAL_CMD_TABLE.add_command("@batchprocess", cmd_batchprocess,
auto_help=True, staff_help=True,
priv_tuple=("genperms.process_control"))
priv_tuple=("genperms.process_control",), help_category="Building")
#interactive state commands
@ -271,43 +273,71 @@ def reload_stack(source_object):
source_object.emit_to("Commands in file could not be reloaded. Was it moved?")
def move_in_stack(source_object, step=1):
"store data in stack"
global CMDSTACKS, STACKPTRS
N = len(CMDSTACKS[source_object])
currpos = STACKPTRS[source_object]
STACKPTRS[source_object] = max(0,min(N-1,currpos+step))
def exit_state(source_object):
"Quit the state"
global CMDSTACKS,STACKPTRS,FILENAMES
del CMDSTACKS[source_object]
del STACKPTRS[source_object]
del FILENAMES[source_object]
try:
del CMDSTACKS[source_object]
del STACKPTRS[source_object]
del FILENAMES[source_object]
except KeyError:
logger.log_errmsg("Batchprocessor quit error: all state vars could not be deleted.")
source_object.clear_state()
def cmd_state_l(command):
"l-ook at current command definition"
def cmd_state_ll(command):
"""
ll
Look at the full source for the current
command definition.
"""
show_curr(command.source_object,showall=True)
def cmd_state_p(command):
"p-rocess current command definition"
def cmd_state_pp(command):
"""
pp
Process the currently shown command definition.
"""
process_commands(command.source_object)
command.source_object.emit_to(printfooter())
def cmd_state_r(command):
"r-eload file, keep current stack position"
def cmd_state_rr(command):
"""
rr
Reload the batch file, keeping the current
position in it.
"""
reload_stack(command.source_object)
command.source_object.emit_to("\nFile reloaded. Staying on same command.\n")
show_curr(command.source_object)
def cmd_state_rr(command):
"r-eload file, start over"
def cmd_state_rrr(command):
"""
rrr
Reload the batch file, starting over
from the beginning.
"""
global STACKPTRS
reload_stack(command.source_object)
STACKPTRS[command.source_object] = 0
command.source_object.emit_to("\nFile reloaded. Restarting from top.\n")
show_curr(command.source_object)
def cmd_state_n(command):
"n-ext command (no exec)"
def cmd_state_nn(command):
"""
nn
Go to next command. No commands are executed.
"""
source_object = command.source_object
arg = command.command_argument
if arg and arg.isdigit():
@ -317,8 +347,29 @@ def cmd_state_n(command):
move_in_stack(source_object, step)
show_curr(source_object)
def cmd_state_b(command):
"b-ackwards to previous command (no exec)"
def cmd_state_nl(command):
"""
nl
Go to next command, viewing its full source.
No commands are executed.
"""
source_object = command.source_object
arg = command.command_argument
if arg and arg.isdigit():
step = int(command.command_argument)
else:
step = 1
move_in_stack(source_object, step)
show_curr(source_object, showall=True)
def cmd_state_bb(command):
"""
bb
Backwards to previous command. No commands
are executed.
"""
source_object = command.source_object
arg = command.command_argument
if arg and arg.isdigit():
@ -328,8 +379,30 @@ def cmd_state_b(command):
move_in_stack(source_object, step)
show_curr(source_object)
def cmd_state_s(command):
"s-tep to next command (exec)"
def cmd_state_bl(command):
"""
bl
Backwards to previous command, viewing its full
source. No commands are executed.
"""
source_object = command.source_object
arg = command.command_argument
if arg and arg.isdigit():
step = -int(command.command_argument)
else:
step = -1
move_in_stack(source_object, step)
show_curr(source_object, showall=True)
def cmd_state_ss(command):
"""
ss [steps]
Process current command, then step to the next
one. If steps is given,
process this many commands.
"""
source_object = command.source_object
arg = command.command_argument
if arg and arg.isdigit():
@ -339,8 +412,30 @@ def cmd_state_s(command):
process_commands(source_object,step)
show_curr(source_object)
def cmd_state_c(command):
"c-ontinue to process remaining"
def cmd_state_sl(command):
"""
sl [steps]
Process current command, then step to the next
one, viewing its full source. If steps is given,
process this many commands.
"""
source_object = command.source_object
arg = command.command_argument
if arg and arg.isdigit():
step = int(command.command_argument)
else:
step = 1
process_commands(source_object,step)
show_curr(source_object, showall=True)
def cmd_state_cc(command):
"""
cc
Continue to process all remaining
commands.
"""
global CMDSTACKS,STACKPTRS
source_object = command.source_object
N = len(CMDSTACKS[source_object])
@ -350,8 +445,12 @@ def cmd_state_c(command):
exit_state(source_object)
source_object.emit_to("Finished processing batch file.")
def cmd_state_j(command):
"j-ump to specific command index"
def cmd_state_jj(command):
"""
j <command number>
Jump to specific command number
"""
global STACKPTRS
source_object = command.source_object
arg = command.command_argument
@ -365,18 +464,44 @@ def cmd_state_j(command):
move_in_stack(source_object, step)
show_curr(source_object)
def cmd_state_q(command):
"q-uit state."
def cmd_state_jl(command):
"""
jl <command number>
Jump to specific command number and view its full source.
"""
global STACKPTRS
source_object = command.source_object
arg = command.command_argument
if arg and arg.isdigit():
no = int(command.command_argument)-1
else:
source_object.emit_to("You must give a number index.")
return
ptr = STACKPTRS[source_object]
step = no - ptr
move_in_stack(source_object, step)
show_curr(source_object, showall=True)
def cmd_state_qq(command):
"""
qq
Quit the batchprocessor.
"""
exit_state(command.source_object)
command.source_object.emit_to("Aborted interactive batch mode.")
def cmd_state_h(command):
def cmd_state_hh(command):
"Help command"
s = """
Interactive batch processing commands:
nn [steps] - next command (no processing)
nl [steps] - next & look
bb [steps] - back to previous command (no processing)
bl [steps] - back & look
jj <N> - jump to command no N (no processing)
jl <N> - jump & look
pp - process currently shown command (no step)
ss [steps] - process & step
ll - look at full definition of current command
@ -384,8 +509,8 @@ def cmd_state_h(command):
rrr - reload batch file (start from first)
hh - this help list
cc - continue processing to end and quit.
qq - quit (abort all remaining)
cc - continue processing to end, then quit.
qq - quit (abort all remaining commands)
"""
command.source_object.emit_to(s)
@ -394,14 +519,18 @@ def cmd_state_h(command):
GLOBAL_STATE_TABLE.add_state(STATENAME,global_cmds='all',
allow_exits=True,allow_obj_cmds=True)
#add state commands
GLOBAL_STATE_TABLE.add_command(STATENAME,"nn",cmd_state_n)
GLOBAL_STATE_TABLE.add_command(STATENAME,"bb",cmd_state_b)
GLOBAL_STATE_TABLE.add_command(STATENAME,"jj",cmd_state_j)
GLOBAL_STATE_TABLE.add_command(STATENAME,"pp",cmd_state_p)
GLOBAL_STATE_TABLE.add_command(STATENAME,"ss",cmd_state_s)
GLOBAL_STATE_TABLE.add_command(STATENAME,"cc",cmd_state_c)
GLOBAL_STATE_TABLE.add_command(STATENAME,"ll",cmd_state_l)
GLOBAL_STATE_TABLE.add_command(STATENAME,"rr",cmd_state_r)
GLOBAL_STATE_TABLE.add_command(STATENAME,"rrr",cmd_state_rr)
GLOBAL_STATE_TABLE.add_command(STATENAME,"hh",cmd_state_h)
GLOBAL_STATE_TABLE.add_command(STATENAME,"qq",cmd_state_q)
GLOBAL_STATE_TABLE.add_command(STATENAME,"nn",cmd_state_nn)
GLOBAL_STATE_TABLE.add_command(STATENAME,"nl",cmd_state_nl)
GLOBAL_STATE_TABLE.add_command(STATENAME,"bb",cmd_state_bb)
GLOBAL_STATE_TABLE.add_command(STATENAME,"bl",cmd_state_bl)
GLOBAL_STATE_TABLE.add_command(STATENAME,"jj",cmd_state_jj)
GLOBAL_STATE_TABLE.add_command(STATENAME,"jl",cmd_state_jl)
GLOBAL_STATE_TABLE.add_command(STATENAME,"pp",cmd_state_pp)
GLOBAL_STATE_TABLE.add_command(STATENAME,"ss",cmd_state_ss)
GLOBAL_STATE_TABLE.add_command(STATENAME,"sl",cmd_state_sl)
GLOBAL_STATE_TABLE.add_command(STATENAME,"cc",cmd_state_cc)
GLOBAL_STATE_TABLE.add_command(STATENAME,"ll",cmd_state_ll)
GLOBAL_STATE_TABLE.add_command(STATENAME,"rr",cmd_state_rr)
GLOBAL_STATE_TABLE.add_command(STATENAME,"rrr",cmd_state_rrr)
GLOBAL_STATE_TABLE.add_command(STATENAME,"hh",cmd_state_hh)
GLOBAL_STATE_TABLE.add_command(STATENAME,"qq",cmd_state_qq)

View file

@ -1,26 +1,22 @@
"""
Comsys command module.
"""
import time
from django.conf import settings
from src import comsys
from src.channels.models import CommChannelMembership, CommChannel
from src import defines_global
from src import ansi
from src.util import functions_general
from src.objects.models import Object
from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_addcom(command):
"""
addcom
addcom - join a channel with alias
Usage:
addcom [alias=] <channel>
Joins a channel. Allows adding an alias for it to make it
easier and faster to use. Subsequent calls of this command
can be used to add multiple aliases.
Allows adding an alias for a channel to make is easier and
faster to use. Subsequent calls of this command can
be used to add multiple aliases.
"""
source_object = command.source_object
command_argument = command.command_argument
@ -81,11 +77,11 @@ def cmd_addcom(command):
except CommChannel.DoesNotExist:
# Failed to match iexact on channel's 'name' attribute.
source_object.emit_to("Could not find channel %s." % chan_name)
GLOBAL_CMD_TABLE.add_command("addcom", cmd_addcom)
GLOBAL_CMD_TABLE.add_command("addcom", cmd_addcom, help_category="Comms")
def cmd_delcom(command):
"""
delcom
delcom - remove a channel alias
Usage:
delcom <alias>
@ -113,10 +109,15 @@ def cmd_delcom(command):
leave_msg = "%s has left the channel." % \
(source_object.get_name(show_dbref=False),)
comsys.send_cmessage(chan_name, leave_msg)
GLOBAL_CMD_TABLE.add_command("delcom", cmd_delcom),
GLOBAL_CMD_TABLE.add_command("delcom", cmd_delcom,help_category="Comms")
def cmd_comlist(command):
"""
comlist - list channel memberships
Usage:
comlist
Lists the channels a user is subscribed to.
"""
source_object = command.source_object
@ -137,11 +138,14 @@ def cmd_comlist(command):
chan.get_name(), chan_on)
s = s[:-1]
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("comlist", cmd_comlist)
GLOBAL_CMD_TABLE.add_command("comlist", cmd_comlist,help_category="Comms")
def cmd_allcom(command):
"""
allcom [on|off|who|clear]
allcom - operate on all channels
Usage:
allcom [on | off | who | clear]
Allows the user to universally turn off or on all channels they are on,
as well as perform a 'who' for all channels they are on. Clear deletes
@ -197,14 +201,18 @@ def cmd_allcom(command):
s = s[:-2] + "\n"
s = s[:-1]
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("allcom", cmd_allcom)
GLOBAL_CMD_TABLE.add_command("allcom", cmd_allcom, help_category="Comms")
def cmd_clearcom(command):
"""
clearcom
clearcom - removes all channels
Effectively runs delcom on all channels the user is on. It will remove their aliases,
remove them from the channel, and clear any titles they have set.
Usage:
clearcom
Effectively runs delcom on all channels the user is on. It will remove
their aliases, remove them from the channel, and clear any titles they
have set.
"""
source_object = command.source_object
#get aall subscribed channel memberships
@ -227,7 +235,10 @@ def cmd_clist(command):
"""
@clist
Lists all available channels on the game.
Usage:
@clist
Lists all available channels in the game.
"""
session = command.session
source_object = command.source_object
@ -248,13 +259,17 @@ def cmd_clist(command):
s = s[:-1]
#s += "** End of Channel List **"
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("@clist", cmd_clist),
GLOBAL_CMD_TABLE.add_command("@clist", cmd_clist, help_category="Comms")
def cmd_cdestroy(command):
"""
@cdestroy
Destroys a channel.
Usage:
@cdestroy <channel>
Destroys a channel that you control.
"""
source_object = command.source_object
cname = command.command_argument
@ -275,7 +290,7 @@ def cmd_cdestroy(command):
else:
source_object.emit_to("Permission denied.")
return
GLOBAL_CMD_TABLE.add_command("@cdestroy", cmd_cdestroy)
GLOBAL_CMD_TABLE.add_command("@cdestroy", cmd_cdestroy, help_category="Comms")
def cmd_cset(command):
"""
@ -297,9 +312,12 @@ def cmd_ccharge(command):
def cmd_cboot(command):
"""
@cboot[/quiet] <channel>=<object>
@cboot
Kicks a player or object from the channel
Usage:
@cboot[/quiet] <channel> = <player or object>
Kicks a player or object from a channel you control.
"""
source_object = command.source_object
args = command.command_argument
@ -352,14 +370,17 @@ def cmd_cboot(command):
for mship in membership:
comsys.plr_del_channel(bootobj, mship.user_alias)
GLOBAL_CMD_TABLE.add_command("@cboot", cmd_cboot)
GLOBAL_CMD_TABLE.add_command("@cboot", cmd_cboot, help_category="Comms")
def cmd_cemit(command):
"""
@cemit <channel>=<message>
@cemit/noheader <channel>=<message>
@cemit/sendername <channel>=<message>
@cemit - send a message to channel
Usage:
@cemit <channel>=<message>
@cemit/noheader <channel>=<message>
@cemit/sendername <channel>=<message>
Allows the user to send a message over a channel as long as
they own or control it. It does not show the user's name unless they
@ -425,12 +446,12 @@ def cmd_cemit(command):
#pipe to external channels (IRC, IMC) eventually mapped to this channel
comsys.send_cexternal(cname_parsed, cmessage, caller=source_object)
GLOBAL_CMD_TABLE.add_command("@cemit", cmd_cemit,priv_tuple=("channels.emit_commchannel",))
GLOBAL_CMD_TABLE.add_command("@cemit", cmd_cemit,priv_tuple=("channels.emit_commchannel",),
help_category="Comms")
def cmd_cwho(command):
"""
@cwho
list
Usage:
@cwho channel[/all]
@ -468,15 +489,17 @@ 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),
GLOBAL_CMD_TABLE.add_command("@cwho", cmd_cwho, help_category="Comms")
def cmd_ccreate(command):
"""
@ccreate
Creates a new channel with the invoker being the default owner.
Usage:
@ccreate <new channel>
Creates a new channel owned by you.
"""
# TODO: Implement cmd_ccreate
source_object = command.source_object
cname = command.command_argument
@ -496,11 +519,14 @@ def cmd_ccreate(command):
# Create and set the object up.
new_chan = 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)
GLOBAL_CMD_TABLE.add_command("@ccreate", cmd_ccreate, help_category="Comms")
def cmd_cchown(command):
"""
@cchown <channel>=<player>
@cchown
Usage:
@cchown <channel> = <player>
Changes the owner of a channel.
"""
@ -535,4 +561,4 @@ def cmd_cchown(command):
channel.set_owner(new_owner)
source_object.emit_to("Owner of %s changed from %s to %s." % (cname, old_pname, pname))
new_owner.emit_to("%s transfered ownership of channel '%s' to you." % (old_pname, cname))
GLOBAL_CMD_TABLE.add_command("@cchown", cmd_cchown)
GLOBAL_CMD_TABLE.add_command("@cchown", cmd_cchown, help_category="Comms")

View file

@ -7,17 +7,19 @@ from django.contrib.auth.models import User
from src.config.models import ConfigValue
from src.helpsys.models import HelpEntry
from src.ansi import ANSITable
from src import defines_global
from src import session_mgr
from src.util import functions_general
import src.helpsys.management.commands.edit_helpfiles as edit_help
from src.helpsys import helpsystem
from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_password(command):
"""
Changes your own password.
@password <Oldpass>=<Newpass>
@password - set your password
Usage:
@paassword <old password> = <new password>
Changes your password. Make sure to pick a safe one.
"""
source_object = command.source_object
@ -54,18 +56,27 @@ def cmd_password(command):
uaccount.set_password(newpass)
uaccount.save()
source_object.emit_to("Password changed.")
GLOBAL_CMD_TABLE.add_command("@password", cmd_password)
GLOBAL_CMD_TABLE.add_command("@password", cmd_password, help_category="System")
def cmd_pemit(command):
"""
@pemit
Emits something to a player.
(Not yet implemented)
"""
# TODO: Implement cmd_pemit
#GLOBAL_CMD_TABLE.add_command("@pemit", cmd_pemit)
def cmd_emit(command):
"""
Emits something to your location.
@emit
Usage:
@emit <message>
Emits a message to your immediate surroundings.
"""
message = command.command_argument
@ -74,10 +85,15 @@ def cmd_emit(command):
else:
command.source_object.emit_to("Emit what?")
GLOBAL_CMD_TABLE.add_command("@emit", cmd_emit,
priv_tuple=("genperms.announce")),
priv_tuple=("genperms.announce",),help_category="Comms"),
def cmd_wall(command):
"""
@wall
Usage:
@wall <message>
Announces a message to all connected players.
"""
wallstring = command.command_argument
@ -90,18 +106,29 @@ def cmd_wall(command):
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"))
priv_tuple=("genperms.announce",),help_category="Comms")
def cmd_idle(command):
"""
Returns nothing, this lets the player set an idle timer without spamming
his screen.
idle
Usage:
idle
Returns and does nothing. You can use this to send idle
messages to the game, in order to avoid getting timed out.
"""
pass
GLOBAL_CMD_TABLE.add_command("idle", cmd_idle)
GLOBAL_CMD_TABLE.add_command("idle", cmd_idle, help_category="System")
def cmd_inventory(command):
"""
inventory
Usage:
inventory
inv
Shows a player's inventory.
"""
source_object = command.source_object
@ -121,7 +148,13 @@ GLOBAL_CMD_TABLE.add_command("inventory", cmd_inventory)
def cmd_look(command):
"""
Handle looking at objects.
look
Usage:
look
look <obj>
Observers your location or objects in your vicinity.
"""
source_object = command.source_object
@ -144,7 +177,13 @@ GLOBAL_CMD_TABLE.add_command("look", cmd_look)
def cmd_get(command):
"""
Get an object and put it in a player's inventory.
get
Usage:
get <obj>
Picks up an object from your location and puts it in
your inventory.
"""
source_object = command.source_object
obj_is_staff = source_object.is_staff()
@ -193,11 +232,15 @@ GLOBAL_CMD_TABLE.add_command("get", cmd_get)
def cmd_drop(command):
"""
Drop an object from a player's inventory into their current location.
drop
Usage:
drop <obj>
Has you drop an object from your inventory into the
location you are currently in.
"""
source_object = command.source_object
obj_is_staff = source_object.is_staff()
if not command.command_argument:
source_object.emit_to("Drop what?")
return
@ -219,153 +262,40 @@ def cmd_drop(command):
target_obj.get_name(show_dbref=False)),
exclude=source_object)
# SCRIPT: Call the object's script's a_drop() method.
# SCRIPT: Call the object script's a_drop() method.
target_obj.scriptlink.at_drop(source_object)
GLOBAL_CMD_TABLE.add_command("drop", cmd_drop),
def cmd_examine(command):
"""
Detailed object examine command
"""
source_object = command.source_object
attr_search = False
if not command.command_argument:
# If no arguments are provided, examine the invoker's location.
target_obj = source_object.get_location()
else:
# Look for a slash in the input, indicating an attribute search.
attr_split = command.command_argument.split("/", 1)
# If the splitting by the "/" character returns a list with more than 1
# entry, it's an attribute match.
if len(attr_split) > 1:
attr_search = True
# Strip the object search string from the input with the
# object/attribute pair.
obj_searchstr = attr_split[0]
attr_searchstr = attr_split[1].strip()
# Protect against stuff like: ex me/
if attr_searchstr == '':
source_object.emit_to('No attribute name provided.')
return
else:
# No slash in argument, just examine an object.
obj_searchstr = command.command_argument
# Resolve the target object.
target_obj = source_object.search_for_object(obj_searchstr)
# Use search_for_object to handle duplicate/nonexistant results.
if not target_obj:
return
# If the user doesn't control the object, just look at it instead.
if not source_object.controls_other(target_obj, builder_override=True):
command.command_string = 'look'
cmd_look(command)
return
if attr_search:
"""
Player did something like: examine me/* or examine me/TE*. Return
each matching attribute with its value.
"""
attr_matches = target_obj.attribute_namesearch(attr_searchstr)
if attr_matches:
for attribute in attr_matches:
source_object.emit_to(attribute.get_attrline())
else:
source_object.emit_to("No matching attributes found.")
else:
"""
Player is examining an object. Return a full readout of attributes,
along with detailed information about said object.
"""
s = ""
newl = "\r\n"
# Format the examine header area with general flag/type info.
s += str(target_obj.get_name(fullname=True)) + newl
s += str("Type: %s Flags: %s" % (target_obj.get_type(),
target_obj.get_flags())) + newl
s += str("Owner: %s " % target_obj.get_owner()) + newl
s += str("Zone: %s" % target_obj.get_zone()) + newl
s += str("Parent: %s " % target_obj.get_script_parent()) + newl
locks = target_obj.get_attribute_value("LOCKS")
if locks and "%s" % locks:
s += str("Locks: %s" % locks) + newl
# Contents container lists for sorting by type.
con_players = []
con_things = []
con_exits = []
# Break each object out into their own list.
for obj in target_obj.get_contents():
if obj.is_player():
con_players.append(obj)
elif obj.is_exit():
con_exits.append(obj)
elif obj.is_thing():
con_things.append(obj)
# Render the object's home or destination (for exits).
if not target_obj.is_room():
if target_obj.is_exit():
# The Home attribute on an exit is really its destination.
s += str("Destination: %s" % target_obj.get_home()) + newl
else:
# For everything else, home is home.
s += str("Home: %s" % target_obj.get_home()) + newl
# This obviously isn't valid for rooms.
s += str("Location: %s" % target_obj.get_location()) + newl
# Render other attributes
for attribute in target_obj.get_all_attributes():
s += str(attribute.get_attrline()) + newl
# Render Contents display.
if con_players or con_things:
s += str("%sContents:%s" % (ANSITable.ansi["hilite"],
ANSITable.ansi["normal"]))
for player in con_players:
s += str(' %s' % newl + player.get_name(fullname=True))
for thing in con_things:
s += str(' %s' % newl + thing.get_name(fullname=True))
# Render Exists display.
if con_exits:
s += str("%sExits:%s" % (newl + ANSITable.ansi["hilite"],
ANSITable.ansi["normal"]))
for exit in con_exits:
s += str(' %s' % newl + exit.get_name(fullname=True))
# Send it all
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("examine", cmd_examine,priv_tuple=("objects.info",))
def cmd_quit(command):
"""
Gracefully disconnect the user as per his own request.
quit
Usage:
quit
Gracefully disconnect from the game.
"""
if command.session:
session = command.session
session.msg("Quitting. Hope to see you soon again.")
session.handle_close()
GLOBAL_CMD_TABLE.add_command("quit", cmd_quit)
GLOBAL_CMD_TABLE.add_command("quit", cmd_quit, help_category="System")
def cmd_who(command):
"""
Generic WHO command.
who
Usage:
who
Shows who is currently online.
"""
session_list = session_mgr.get_session_list()
source_object = command.source_object
# 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:
if command.extra_vars and \
command.extra_vars.get("show_session_data", None) == False:
show_session_data = False
else:
show_session_data = source_object.has_perm("genperms.see_session_data")
@ -412,12 +342,17 @@ def cmd_who(command):
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)
extra_vals={"show_session_data": False}, help_category="System")
GLOBAL_CMD_TABLE.add_command("who", cmd_who,help_category="System")
def cmd_say(command):
"""
Room-based speech command.
say
Usage:
say <message>
Talk to those in your current location.
"""
source_object = command.source_object
@ -441,7 +376,18 @@ GLOBAL_CMD_TABLE.add_command("say", cmd_say)
def cmd_pose(command):
"""
Pose/emote command.
pose - strike a pose
Usage:
pose <pose text>
Example:
pose is standing by the wall, smiling.
-> others will see:
Tom is standing by the wall, smiling.
Describe an action being taken. The pose text will
automatically begin with your name.
"""
source_object = command.source_object
@ -464,189 +410,134 @@ def cmd_pose(command):
GLOBAL_CMD_TABLE.add_command("pose", cmd_pose)
def cmd_group(command):
"""@group
"""
@group - show your groups
Usage:
@group
This command shows you which user permission groups you are a member of, if any.
This command shows you which user permission groups
you are a member of, if any.
"""
source_object = command.source_object
user = User.objects.get(username=source_object.get_name(show_dbref=False,no_ansi=True))
s = ""
user = User.objects.get(username=source_object.get_name(show_dbref=False, no_ansi=True))
string = ""
if source_object.is_superuser():
s += "\n This is a SUPERUSER account! Group membership does not matter."
string += "\n This is a SUPERUSER account! Group membership does not matter."
if not user.is_active:
s += "\n ACCOUNT NOT ACTIVE."
for g in user.groups.all():
s += "\n -- %s" % g
for p in g.permissions.all():
s += "\n --- %s" % p.name
if not s:
s = "You are not a member of any groups." % source_object.get_name(show_dbref=False)
string += "\n ACCOUNT NOT ACTIVE."
for group in user.groups.all():
string += "\n -- %s" % group
for perm in group.permissions.all():
string += "\n --- %s" % perm.name
if not string:
string = "You are not a member of any groups." % source_object.get_name(show_dbref=False)
else:
s = "\nYour (%s's) group memberships: %s" % (source_object.get_name(show_dbref=False),s)
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("@group", cmd_group,auto_help=True)
string = "\nYour (%s's) group memberships: %s" % (source_object.get_name(show_dbref=False), string)
source_object.emit_to(string)
GLOBAL_CMD_TABLE.add_command("@group", cmd_group)
GLOBAL_CMD_TABLE.add_command("@groups", cmd_group, help_category="System")
def cmd_help(command):
"""
Help command
Usage: help <topic>
help - view help database
Usage:
help <topic>
Examples: help index
help topic
help 2
help 345
Shows the available help on <topic>. Use without <topic> to
get the help index. If more than one topic match your query, you will get a
Shows the available help on <topic>. Use without <topic> to get the help
index. If more than one topic match your query, you will get a
list of topics to choose between. You can also supply a help entry number
directly if you know it.
<<TOPIC:STAFF:help_staff>>
Help command extra functions for staff:
help index - the normal index
help index_staff - show only help files unique to staff
help index_player - show only help files visible to all players
The help command has a range of staff-only switches for manipulating the
help data base:
help/add <topic>:<text> - add/replace help topic with text (staff only)
help/append <topic>:<text> - add text to the end of a topic (staff only)
(use the /newline switch to add a new paragraph
to your help entry.)
help/delete <topic> - delete help topic (staff only)
Note: further switches are /force and /staff. /force is used together with /add to
always create a help entry, also when they partially match a previous entry. /staff
makes the help file visible to staff only. The /append switch can be used to change the
/staff setting of an existing help file if required.
The <text> entry supports markup to automatically divide the help text into
sub-entries. These are started by the markup < <TOPIC:MyTopic> > (with no spaces
between the << >>), which will create a new subsectioned entry 'MyTopic' for all
text to follow it. All subsections to be added this way are automatically
referred to in the footer of each help entry. Normally the subsections inherit the
staff_only flag from the main entry (so if this is a staff-only help, all subentries
will also be staff-only and vice versa). You can override this behaviour using the
alternate forms < <TOPIC:STAFF:MyTopic> > and < <TOPIC:ALL:MyTopic> >.
"""
source_object = command.source_object
topicstr = command.command_argument
switches = command.command_switches
topicstr = command.command_argument
if not command.command_argument:
#display topic index if just help command is given
if not switches:
topicstr = "topic"
else:
#avoid applying things to "topic" by mistake
source_object.emit_to("You have to supply a topic.")
return
elif len(topicstr) < 2 and not topicstr.isdigit():
topicstr = "index"
if len(topicstr) < 2 and not topicstr.isdigit():
#check valid query
source_object.emit_to("Your search query must be at least two letters long.")
return
#speciel help index names. These entries are dynamically
#created upon request.
if topicstr == 'index':
#the normal index, affected by permissions
edit_help.get_help_index(source_object)
# speciel help index names. These entries are dynamically
# created upon request.
if topicstr in ['topic','topics']:
# the full index, affected by permissions
text = helpsystem.viewhelp.index_full(source_object)
text = " \nHELP TOPICS (By Category):\n\r%s" % text
source_object.emit_to(text)
return
elif topicstr == 'index_staff':
#allows staff to view only staff-specific help
edit_help.get_help_index(source_object,filter='staff')
return
elif topicstr == 'index_player':
#allows staff to view only the help files a player sees
edit_help.get_help_index(source_object,filter='player')
return
#handle special switches
force_create = 'for' in switches or 'force' in switches
staff_only = 'sta' in switches or 'staff' in switches
elif 'index' in topicstr:
# view the category index
text = helpsystem.viewhelp.index_categories()
text = " \nHELP CATEGORIES (try 'help <category>' or 'help topics'):\n\r\n\r%s" % text
source_object.emit_to(text)
return
if 'add' in switches:
#try to add/replace help text for a command
if not source_object.has_perm("helpsys.add_help"):
source_object.emit_to(defines_global.NOPERMS_MSG)
return
spl = (topicstr.split(':',1))
if len(spl) != 2:
source_object.emit_to("Format is help/add <topic>:<helptext>")
return
topicstr = spl[0]
text = spl[1]
topics = edit_help.add_help(topicstr,text,staff_only,force_create,source_object)
if not topics:
source_object.emit_to("No topic(s) added due to errors. Check syntax and that you don't have duplicate subtopics with the same name defined.")
# not a special help index entry. Do a search for the help entry.
topics = HelpEntry.objects.find_topicmatch(source_object, topicstr)
# display help entry or handle no/multiple matches
string = ""
if not topics:
# no matches.
# try to see if it is matching the name of a category. If so,
# show the topics for this category.
text = helpsystem.viewhelp.index_category(source_object, topicstr)
if text:
# We have category matches, display the index and exit.
string = "\n%s%s%s\n\r\n\r%s" % ("---", " Help topics in category %s: " % \
topicstr.capitalize(), "-"* (30-len(topicstr)), text)
source_object.emit_to(string)
return
elif len(topics)>1:
source_object.emit_to("Added or replaced multiple help entries.")
# at this point we just give a not-found error and give suggestions.
topics = HelpEntry.objects.find_topicsuggestions(source_object,
topicstr)
if topics:
if len(topics) > 3:
topics = topics[:3]
string += "\n\rMatching similarly named topics (use name or number to refine search):"
for entry in topics:
string += "\n %i.%s" % (entry.id, entry.topicname)
else:
source_object.emit_to("Added or replaced help entry for %s." % topicstr )
string += "No matching topics found, please refine your search."
elif 'append' in switches or 'app' in switches:
#append text to a help entry
if not source_object.has_perm("helpsys.add_help"):
source_object.emit_to(defines_global.NOPERMS_MSG)
return
spl = (topicstr.split(':',1))
if len(spl) != 2:
source_object.emit_to("""Format is help/append <topic>:<text to add>
Use the /newline switch to make a new paragraph.""")
return
topicstr = spl[0]
text = spl[1]
topics = HelpEntry.objects.find_topicmatch(source_object, topicstr)
if len(topics) == 1:
newtext = topics[0].get_entrytext_ingame()
if 'newl' in switches or 'newline' in switches:
newtext += "\n\r\n\r%s" % text
else:
newtext += "\n\r%s" % text
topics = edit_help.add_help(topicstr,newtext,staff_only,force_create,source_object)
if topics:
source_object.emit_to("Appended text to help entry for %s." % topicstr)
elif 'del' in switches or 'delete' in switches:
#delete a help entry
if not source_object.has_perm("helpsys.del_help"):
source_object.emit_to(defines_global.NOPERMS_MSG)
return
topics = edit_help.del_help(source_object,topicstr)
if type(topics) != type(list()):
source_object.emit_to("Help entry '%s' deleted." % topicstr)
return
else:
#no switch; just try to get the help as normal
topics = HelpEntry.objects.find_topicmatch(source_object, topicstr)
#display help entry or handle no/multiple matches
if len(topics) == 0:
source_object.emit_to("No matching topics found, please refine your search.")
suggestions = HelpEntry.objects.find_topicsuggestions(source_object,
topicstr)
if len(suggestions) > 0:
source_object.emit_to("Matching similarly named topics:")
for result in suggestions:
source_object.emit_to(" %s" % (result,))
source_object.emit_to("You may type 'help <#>' to see any of these topics.")
elif len(topics) > 1:
source_object.emit_to("More than one match found:")
# multiple matches found
string += "More than one match found:"
for result in topics:
source_object.emit_to(" %3d. %s" % (result.id, result.get_topicname()))
source_object.emit_to("You may type 'help <#>' to see any of these topics.")
string += " %3d. %s" % (result.id, result.get_topicname())
else:
# a single match found
topic = topics[0]
source_object.emit_to("\n\r "+ topic.get_entrytext_ingame())
GLOBAL_CMD_TABLE.add_command("help", cmd_help, auto_help=True)
header = "--- Help entry for '%s' (%s category) " % (topic.get_topicname(),
topic.get_category())
header = "%s%s" % (header, "-" * (80-len(header)))
string += "\n\r%s\n\r\n\r%s" % (header, topic.get_entrytext_ingame())
# add the 'See also:' footer
topics = HelpEntry.objects.find_topicsuggestions(source_object,
topicstr)
if topics:
if len(topics) > 5:
topics = topics[:5]
topics = [str(topic.topicname) for topic in topics ]
string += "\n\r\n\r" + " " * helpsystem.viewhelp.indent + \
"See also: " + ", ".join(topics)
source_object.emit_to(string)
GLOBAL_CMD_TABLE.add_command("help", cmd_help)

View file

@ -1,14 +1,8 @@
"""
IMC2 user and administrative commands.
"""
from time import time
from django.conf import settings
from src.config.models import ConfigValue
from src.objects.models import Object
from src import defines_global
from src import ansi
from src import comsys
from src.util import functions_general
from src.cmdtable import GLOBAL_CMD_TABLE
from src.ansi import parse_ansi
from src.imc2.imc_ansi import IMCANSIParser
@ -20,7 +14,12 @@ from src.channels.models import CommChannel
def cmd_imcwhois(command):
"""
Shows a player's inventory.
imcwhois
Usage:
imcwhois
IMC2 command. Shows a player's inventory.
"""
source_object = command.source_object
if not command.command_argument:
@ -30,10 +29,15 @@ def cmd_imcwhois(command):
source_object.emit_to("Sending IMC whois request. If you receive no response, no matches were found.")
packet = IMC2PacketWhois(source_object, command.command_argument)
imc2_conn.IMC2_PROTOCOL_INSTANCE.send_packet(packet)
GLOBAL_CMD_TABLE.add_command("imcwhois", cmd_imcwhois)
GLOBAL_CMD_TABLE.add_command("imcwhois", cmd_imcwhois, help_category="Comms")
def cmd_imcansi(command):
"""
imcansi
Usage:
imcansi <string>
Test IMC ANSI conversion.
"""
source_object = command.source_object
@ -43,20 +47,30 @@ def cmd_imcansi(command):
else:
retval = parse_ansi(command.command_argument, parser=IMCANSIParser())
source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("imcansi", cmd_imcansi)
GLOBAL_CMD_TABLE.add_command("imcansi", cmd_imcansi, help_category="Comms")
def cmd_imcicerefresh(command):
"""
Semds an ice-refresh packet.
imcicerefresh
Usage:
imcicerefresh
IMC2: Semds an ice-refresh packet.
"""
source_object = command.source_object
packet = IMC2PacketIceRefresh()
imc2_conn.IMC2_PROTOCOL_INSTANCE.send_packet(packet)
source_object.emit_to("Sent")
GLOBAL_CMD_TABLE.add_command("imcicerefresh", cmd_imcicerefresh)
GLOBAL_CMD_TABLE.add_command("imcicerefresh", cmd_imcicerefresh, help_category="Comms")
def cmd_imcchanlist(command):
"""
imcchanlist
Usage:
imcchanlist
Shows the list of cached channels from the IMC2 Channel list.
"""
source_object = command.source_object
@ -73,10 +87,15 @@ def cmd_imcchanlist(command):
channel.policy)
retval += '%s channels found.' % len(IMC2_CHANLIST.chan_list)
source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("imcchanlist", cmd_imcchanlist)
GLOBAL_CMD_TABLE.add_command("imcchanlist", cmd_imcchanlist, help_category="Comms")
def cmd_imclist(command):
"""
imclist
Usage:
imclist
Shows the list of cached games from the IMC2 Mud list.
"""
source_object = command.source_object
@ -88,10 +107,15 @@ def cmd_imclist(command):
retval += '%s\n\r' % mudline[:78]
retval += '%s active MUDs found.' % len(IMC2_MUDLIST.mud_list)
source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("imclist", cmd_imclist)
GLOBAL_CMD_TABLE.add_command("imclist", cmd_imclist, help_category="Comms")
def cmd_imcstatus(command):
"""
imcstatus
Usage:
imcstatus
Shows some status information for your IMC2 connection.
"""
source_object = command.source_object
@ -118,21 +142,24 @@ def cmd_imcstatus(command):
source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("imcstatus", cmd_imcstatus,
priv_tuple=('imc2.admin_imc_channels',))
priv_tuple=('imc2.admin_imc_channels',), help_category="Comms")
def cmd_IMC2chan(command):
"""
@imc2chan IMCServer:IMCchannel channel
@imc2chan
Links an IMC channel to an existing
evennia channel. You can link as many existing
Usage:
@imc2chan <IMCServer> : <IMCchannel> <channel>
Links an IMC channel to an existing evennia
channel. You can link as many existing
evennia channels as you like to the
IMC channel this way. Running the command with an
existing mapping will re-map the channels.
Use 'imcchanlist' to get a list of IMC channels and servers.
Note that both are case sensitive.
Use 'imcchanlist' to get a list of IMC channels and
servers. Note that both are case sensitive.
"""
source_object = command.source_object
if not settings.IMC2_ENABLED:
@ -179,6 +206,6 @@ def cmd_IMC2chan(command):
outstring += "Mapping set: %s." % mapping
source_object.emit_to(outstring)
GLOBAL_CMD_TABLE.add_command("@imc2chan",cmd_IMC2chan,auto_help=True,staff_help=True,
priv_tuple=("imc2.admin_imc_channels",))
GLOBAL_CMD_TABLE.add_command("@imc2chan",cmd_IMC2chan,
priv_tuple=("imc2.admin_imc_channels",), help_category="Comms")

View file

@ -17,25 +17,41 @@ from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_version(command):
"""
Version info command.
@version - game version
Usage:
@version
Display the game version info
"""
retval = "-"*50 +"\n\r"
retval += " Evennia %s\n\r" % (defines_global.EVENNIA_VERSION,)
retval += " Django %s\n\r" % (django.get_version())
retval += "-"*50
command.source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("version", cmd_version),
GLOBAL_CMD_TABLE.add_command("@version", cmd_version, help_category="Admin"),
def cmd_time(command):
"""
@time
Usage:
@time
Server local time.
"""
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),
GLOBAL_CMD_TABLE.add_command("@time", cmd_time, priv_tuple=("genperms.game_info",),
help_category="Admin")
def cmd_uptime(command):
"""
@uptime
Usage:
@uptime
Server uptime and stats.
"""
source_object = command.source_object
@ -54,11 +70,18 @@ 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),
GLOBAL_CMD_TABLE.add_command("@uptime", cmd_uptime, priv_tuple=("genperms.game_info",),
help_category="Admin")
def cmd_list(command):
"""
Shows some game related information.
"""
@list - list info
Usage:
@list commands | flags | process
Shows game related information depending
on which argument is given.
"""
server = command.session.server
source_object = command.source_object
@ -99,10 +122,15 @@ 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,priv_tuple=("genperms.game_info",)),
GLOBAL_CMD_TABLE.add_command("@list", cmd_list,priv_tuple=("genperms.game_info",), help_category="Admin")
def cmd_ps(command):
"""
@ps - list processes
Usage
@ps
Shows the process/event table.
"""
source_object = command.source_object
@ -115,13 +143,23 @@ def cmd_ps(command):
event.description))
source_object.emit_to("Totals: %d interval events" % (len(scheduler.schedule),))
GLOBAL_CMD_TABLE.add_command("@ps", cmd_ps,
priv_tuple=("genperms.process_control")),
priv_tuple=("genperms.process_control",), help_category="Admin")
def cmd_stats(command):
"""
@stats - show object stats
Usage:
@stats
Example:
@stats
->
4012 objects = 144 rooms, 212 exits, 613 things, 1878 players. (1165 garbage)
Shows stats about the database.
4012 objects = 144 rooms, 212 exits, 613 things, 1878 players. (1165 garbage)
"""
stats_dict = Object.objects.object_totals()
command.source_object.emit_to(
"%d objects = %d rooms, %d exits, %d things, %d players. (%d garbage)" %
@ -131,4 +169,4 @@ def cmd_stats(command):
stats_dict["things"],
stats_dict["players"],
stats_dict["garbage"]))
GLOBAL_CMD_TABLE.add_command("@stats", cmd_stats, priv_tuple=("genperms.game_info",)),
GLOBAL_CMD_TABLE.add_command("@stats", cmd_stats, priv_tuple=("genperms.game_info",), help_category="Admin"),

View file

@ -11,7 +11,10 @@ from src.channels.models import CommChannel
def cmd_IRC2chan(command):
"""
@irc2chan IRCchannel channel
@irc2chan - link irc to ingame channel
Usage:
@irc2chan <#IRCchannel> <local channel>
Links an IRC channel (including #) to an existing
evennia channel. You can link as many existing
@ -55,12 +58,16 @@ def cmd_IRC2chan(command):
outstring += "Mapping set: %s." % mapping
source_object.emit_to(outstring)
GLOBAL_CMD_TABLE.add_command("@irc2chan",cmd_IRC2chan,auto_help=True,staff_help=True,
priv_tuple=("irc.admin_irc_channels",))
GLOBAL_CMD_TABLE.add_command("@irc2chan",cmd_IRC2chan,
priv_tuple=("irc.admin_irc_channels",),
help_category="Comms")
def cmd_IRCjoin(command):
"""
@ircjoin IRCchannel
@ircjoin - join a new irc channel
Usage:
@ircjoin <#IRCchannel>
Attempts to connect a bot to a new IRC channel (don't forget that
IRC channels begin with a #).
@ -99,19 +106,25 @@ def cmd_IRCjoin(command):
# irc.setName("%s:%s" % ("IRC",channel))
# irc.setServiceParent(mud_service.service_collection)
GLOBAL_CMD_TABLE.add_command("@ircjoin",cmd_IRCjoin,auto_help=True,
staff_help=True,
priv_tuple=("irc.admin_irc_channels",))
GLOBAL_CMD_TABLE.add_command("@ircjoin",cmd_IRCjoin,
priv_tuple=("irc.admin_irc_channels",),
help_category="Comms")
def cmd_IRCchanlist(command):
"""
ircchanlist
Usage:
ircchanlist
Lists all externally available IRC channels.
"""
source_object = command.source_object
s = "Available IRC channels:"
for c in IRC_CHANNELS:
s += "\n %s \t(nick '%s') on %s" % (c.factory.channel,c.factory.nickname,c.factory.network,)
s += "\n %s \t(nick '%s') on %s" % (c.factory.channel,
c.factory.nickname,
c.factory.network,)
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("ircchanlist", cmd_IRCchanlist, auto_help=True)
GLOBAL_CMD_TABLE.add_command("ircchanlist", cmd_IRCchanlist,
help_category="Comms")

View file

@ -9,10 +9,21 @@ from src import locks
from src import ansi
from src.cmdtable import GLOBAL_CMD_TABLE
from src import defines_global
from src.ansi import ANSITable
def cmd_teleport(command):
"""
Teleports an object somewhere.
teleport
Usage:
teleport/switch [<object> = <location>]
Switches:
quiet - don't inform the source and target
locations about the move.
Teleports an object somewhere. If no object is
given we are teleporting ourselves.
"""
source_object = command.source_object
@ -66,10 +77,15 @@ def cmd_teleport(command):
source_object.move_to(target_obj, quiet=tel_quietly)
GLOBAL_CMD_TABLE.add_command("@teleport", cmd_teleport,
priv_tuple=("objects.teleport",))
priv_tuple=("objects.teleport",), help_category="Building")
def cmd_alias(command):
"""
@alias
Usage:
@alias <player> = <alias>
Assigns an alias to a player object for ease of paging, etc.
"""
source_object = command.source_object
@ -118,8 +134,17 @@ GLOBAL_CMD_TABLE.add_command("@alias", cmd_alias)
def cmd_wipe(command):
"""
Wipes an object's attributes, or optionally only those matching a search
string.
@wipe - clears attributes
Usage:
@wipe <object> [/attribute-wildcard]
Example:
@wipe box
@wipe box/colour
Wipes all of an object's attributes, or optionally only those
matching the given attribute-wildcard search string.
"""
source_object = command.source_object
attr_search = False
@ -166,11 +191,21 @@ 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,priv_tuple=("objects.wipe",))
GLOBAL_CMD_TABLE.add_command("@wipe", cmd_wipe,priv_tuple=("objects.wipe",),
help_category="Building")
def cmd_set(command):
"""
Sets flags or attributes on objects.
@set - set attributes and flags
Usage:
@set <obj> = <flag>
@set <obj> = <attr> : <value>
@set <obj> = !<flag>
@set <obj> = <attr> :
Sets flags or attributes on objects. The two last forms
above unsets the flag and clears the attribute, respectively.
"""
source_object = command.source_object
args = command.command_argument
@ -251,16 +286,26 @@ def cmd_set(command):
s += '\nFlag %s=%s set.' % (target_name, flag.upper())
target.set_flag(flag, True)
source_object.emit_to(s[1:])
GLOBAL_CMD_TABLE.add_command("@set", cmd_set, priv_tuple=("objects.modify_attributes",))
GLOBAL_CMD_TABLE.add_command("@set", cmd_set, priv_tuple=("objects.modify_attributes",),
help_category="Building")
def cmd_cpattr(command):
"""
copy an attribute to another object
@cpattr <obj>/<attr> = <obj1>/<attr1> [,<obj2>/<attr2>,<obj3>/<attr3>,...]
@cpattr <obj>/<attr> = <obj1> [,<obj2>,<obj3>,...]
@cpattr <attr> = <obj1>/<attr1> [,<obj2>/<attr2>,<obj3>/<attr3>,...]
@cpattr <attr> = <obj1>[,<obj2>,<obj3>,...]
@cpattr - copy attributes
Usage:
@cpattr <obj>/<attr> = <obj1>/<attr1> [,<obj2>/<attr2>,<obj3>/<attr3>,...]
@cpattr <obj>/<attr> = <obj1> [,<obj2>,<obj3>,...]
@cpattr <attr> = <obj1>/<attr1> [,<obj2>/<attr2>,<obj3>/<attr3>,...]
@cpattr <attr> = <obj1>[,<obj2>,<obj3>,...]
Example:
@cpattr coolness = Anna/chillout, Anna/nicety, Tom/nicety
->
copies the coolness attribute (defined on yourself), to attributes
on Anna and Tom.
Copy the attribute one object to one or more attributes on another object.
"""
source_object = command.source_object
args = command.command_argument
@ -333,14 +378,17 @@ def cmd_cpattr(command):
to_objname, to_attr)
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("@cpattr", cmd_cpattr,
priv_tuple=("objects.modify_attributes",))
priv_tuple=("objects.modify_attributes",), help_category="Building")
def cmd_mvattr(command):
"""
@mvattr <object>=<old>,<new>[,<copy1>[, <copy2 ...]]
@mvattr - move attributes
Move attributes around on an object
Usage:
@mvattr <object>=<old>,<new>[,<copy1>[, <copy2 ...]]
Move attributes around on the same object.
"""
source_object = command.source_object
arg = command.command_argument
@ -395,10 +443,16 @@ def cmd_mvattr(command):
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("@mvattr", cmd_mvattr,
priv_tuple=("objects.modify_attributes",))
priv_tuple=("objects.modify_attributes",),
help_category="Building")
def cmd_find(command):
"""
find
Usage:
find <searchname>
Searches for an object of a particular name.
"""
source_object = command.source_object
@ -421,13 +475,14 @@ def cmd_find(command):
else:
source_object.emit_to("No name matches found for: %s" % (searchstring,))
GLOBAL_CMD_TABLE.add_command("@find", cmd_find,
priv_tuple=("objects.info",))
priv_tuple=("objects.info",), help_category="Building")
def cmd_create(command):
"""
@create
@create - create new objects
Usage: @create[/drop] objname [:parent]
Usage:
@create[/drop] objname [:parent]
switch:
drop - automatically drop the new object into your current location (this is not echoed)
@ -477,15 +532,20 @@ def cmd_create(command):
GLOBAL_CMD_TABLE.add_command("@create", cmd_create,
priv_tuple=("objects.create",),auto_help=True,staff_help=True)
priv_tuple=("objects.create",),
help_category="Building")
def cmd_copy(command):
"""Usage:
@copy[/reset] <original obj> [new_name] [, new_location]
"""
@copy - copy objects
Usage:
@copy[/reset] <original obj> [new_name] [, new_location]
switch:
reset - make a 'clean' copy, without any changes that might have happened to the
original since it was first created.
reset - make a 'clean' copy off the object's script parent, thus
removing any changes that might have been made to the original
since it was first created.
Create an identical copy of an object.
"""
@ -542,12 +602,13 @@ def cmd_copy(command):
reset_text = " (using default attrs/flags)"
source_object.emit_to("Copied object '%s'%s%s%s." % (objname,name_text,loc_text,reset_text))
GLOBAL_CMD_TABLE.add_command("@copy", cmd_copy,
priv_tuple=("objects.create",),auto_help=True,staff_help=True)
priv_tuple=("objects.create",), help_category="Building")
def cmd_nextfree(command):
"""Usage:
"""
@nextfree
Usage:
@nextfree
Returns the next free object number.
@ -555,10 +616,12 @@ def cmd_nextfree(command):
nextfree = Object.objects.get_nextfree_dbnum()
command.source_object.emit_to("Next free object number: #%s" % nextfree)
GLOBAL_CMD_TABLE.add_command("@nextfree", cmd_nextfree,
priv_tuple=("objects.info",),auto_help=True,staff_help=True)
priv_tuple=("objects.info",), help_category="Building")
def cmd_open(command):
"""@open
"""
@open - create new exit
Usage:
@open <new exit> [:parent] [= <destination> [,<return exit> [:parent]]]
@ -670,15 +733,17 @@ def cmd_open(command):
source_object.emit_to("Created exit%s back from %s named %s." % \
(ptext, destination, new_object))
GLOBAL_CMD_TABLE.add_command("@open", cmd_open,
priv_tuple=("objects.dig",),auto_help=True,staff_help=True)
priv_tuple=("objects.dig",), help_category="Building")
def cmd_chown(command):
"""
Changes the ownership of an object. The new owner specified must be a
player object.
@chown - change ownerships
Forms:
@chown <Object>=<NewOwner>
Usage:
@chown <Object> = <NewOwner>
Changes the ownership of an object. The new owner specified must be a
player object.
"""
source_object = command.source_object
@ -721,15 +786,19 @@ 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, priv_tuple=("objects.modify_attributes","objects.admin_ownership"))
GLOBAL_CMD_TABLE.add_command("@chown", cmd_chown, priv_tuple=("objects.modify_attributes",
"objects.admin_ownership"),
help_category="Building" )
def cmd_chzone(command):
"""
@chzone - set zones
Usage:
@chzone <Object> = <NewZone>
Changes an object's zone. The specified zone may be of any object type, but
will typically be a THING.
Forms:
@chzone <Object>=<NewZone>
"""
source_object = command.source_object
@ -773,10 +842,13 @@ 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, priv_tuple=("objects.dig",))
GLOBAL_CMD_TABLE.add_command("@chzone", cmd_chzone, priv_tuple=("objects.dig",),
help_category="Building" )
def cmd_link(command):
"""@link
"""
@link - connect objects
Usage:
@link <object> = <target>
@link <object> =
@ -864,13 +936,17 @@ def cmd_link(command):
else:
source_object.emit_to("You set the home location of %s to %s%s." % (obj, destination, ohome_text))
GLOBAL_CMD_TABLE.add_command("@link", cmd_link,
priv_tuple=("objects.dig",), auto_help=True, staff_help=True)
priv_tuple=("objects.dig",), help_category="Building")
def cmd_unlink(command):
"""
Unlinks an object.
@unlink <Object>
@unlink - unconnect objects
Usage:
@unlink <Object>
Unlinks an object, for example an exit, disconnecting
it from whatever it was connected to.
"""
source_object = command.source_object
@ -890,15 +966,19 @@ def cmd_unlink(command):
target_obj.set_home(None)
source_object.emit_to("You have unlinked %s." % target_obj.get_name())
GLOBAL_CMD_TABLE.add_command("@unlink", cmd_unlink,
priv_tuple=("objects.dig",))
priv_tuple=("objects.dig",), help_category="Building")
def cmd_dig(command):
"""@dig
"""
@dig - build and connect new rooms
Usage:
@dig[/switches] roomname [:parent] [= exit_to_there [: parent][;alias]] [, exit_to_here [: parent][;alias]]
switches:
Switches:
teleport - move yourself to the new room
example:
Example:
@dig kitchen = north; n, south; s
This command is a convenient way to build rooms quickly; it creates the new room and you can optionally
@ -1018,13 +1098,16 @@ def cmd_dig(command):
source_object.move_to(new_room)
GLOBAL_CMD_TABLE.add_command("@dig", cmd_dig,
priv_tuple=("objects.dig",), auto_help=True, staff_help=True)
priv_tuple=("objects.dig",), help_category="Building")
def cmd_name(command):
"""
Handle naming an object.
@name <Object>=<Value>
@name - name objects
Usage:
@name <Object> = <Value>
Handle naming an object.
"""
source_object = command.source_object
@ -1060,10 +1143,16 @@ 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)
GLOBAL_CMD_TABLE.add_command("@name", cmd_name, priv_tuple=("objects.create",),
help_category="Building")
def cmd_description(command):
"""
@desc
Usage:
@desc [obj =] <descriptive text>
Set an object's description.
"""
source_object = command.source_object
@ -1099,20 +1188,21 @@ def cmd_description(command):
else:
source_object.emit_to("%s - description set." % target_obj)
target_obj.set_attribute('desc', new_desc)
GLOBAL_CMD_TABLE.add_command("@describe", cmd_description)
GLOBAL_CMD_TABLE.add_command("@describe", cmd_description, priv_tuple=("objects.create",),
help_category="Building")
def cmd_recover(command):
"""
@recover
Recovers @destroyed non-player objects.
@recover - undo object deletion
Usage:
@recover[/switches] [obj [,obj2, ...]]
@recover[/switches] [obj [,obj2, ...]]
switches:
ROOM - recover as ROOM type instead of THING
EXIT - recover as EXIT type instead of THING
ROOM - recover as ROOM type instead of THING
EXIT - recover as EXIT type instead of THING
Recovers @destroyed non-player objects.
If no argument is given, a list of all recoverable objects will be given.
@ -1165,14 +1255,12 @@ def cmd_recover(command):
GLOBAL_CMD_TABLE.add_command("@recover", cmd_recover,
priv_tuple=("objects.create",),auto_help=True,staff_help=True)
priv_tuple=("objects.create",), help_category="Building")
def cmd_destroy(command):
"""
@destroy
Destroys one or many objects.
@destroy - send objects to trashbin
Usage:
@destroy[/<switches>] obj [,obj2, obj3, ...]
@ -1182,6 +1270,7 @@ def cmd_destroy(command):
switch overrides this safety.
instant|now - Destroy the object immediately, without delay.
Destroys one or many objects.
The objects are set to GOING and will be permanently destroyed next time the system
does cleanup. Until then non-player objects can still be saved by using the
@recover command. The contents of a room will be moved out before it is destroyed,
@ -1244,19 +1333,23 @@ def cmd_destroy(command):
source_object.emit_to("You schedule %s for destruction." % target_obj.get_name())
GLOBAL_CMD_TABLE.add_command("@destroy", cmd_destroy,
priv_tuple=("objects.create",),auto_help=True,staff_help=True)
priv_tuple=("objects.create",), help_category="Building")
def cmd_lock(command):
"""@lock
"""
@lock - limit use of objects
Usage:
@lock[/switch] <obj> [:type] [= <key>[,key2,key3,...]]
switches:
Switches:
add - add a lock (default) from object
del - remove a lock from object
list - view all locks on object (default)
type:
DefaultLock - the default lock type (default)
UseLock - prevents usage of objects' commands
EnterLock - blocking objects from entering the object
Locks an object for everyone except those matching the keys.
The keys can be of the following types (and searched in this order):
@ -1433,4 +1526,137 @@ def cmd_lock(command):
source_object.emit_to("Added lock '%s' to %s with keys%s." % (ltype, obj.get_name(), kstring))
obj.set_attribute("LOCKS",obj_locks)
GLOBAL_CMD_TABLE.add_command("@lock", cmd_lock, priv_tuple=("objects.create",),auto_help=True, staff_help=True)
GLOBAL_CMD_TABLE.add_command("@lock", cmd_lock, priv_tuple=("objects.create",), help_category="Building")
def cmd_examine(command):
"""
examine - detailed info on objects
Usage:
examine [<object>]
The examine command shows detailed game info about an
object; which attributes/flags it has and what it
contains. If object is not specified, the current
location is examined.
"""
source_object = command.source_object
attr_search = False
if not command.command_argument:
# If no arguments are provided, examine the invoker's location.
target_obj = source_object.get_location()
else:
# Look for a slash in the input, indicating an attribute search.
attr_split = command.command_argument.split("/", 1)
# If the splitting by the "/" character returns a list with more than 1
# entry, it's an attribute match.
if len(attr_split) > 1:
attr_search = True
# Strip the object search string from the input with the
# object/attribute pair.
obj_searchstr = attr_split[0]
attr_searchstr = attr_split[1].strip()
# Protect against stuff like: ex me/
if attr_searchstr == '':
source_object.emit_to('No attribute name provided.')
return
else:
# No slash in argument, just examine an object.
obj_searchstr = command.command_argument
# Resolve the target object.
target_obj = source_object.search_for_object(obj_searchstr)
# Use search_for_object to handle duplicate/nonexistant results.
if not target_obj:
return
# If the user doesn't control the object, just look at it instead.
if not source_object.controls_other(target_obj, builder_override=True):
command.command_string = 'look'
cmd_look(command)
return
if attr_search:
# Player did something like: examine me/* or examine me/TE*. Return
# each matching attribute with its value.
attr_matches = target_obj.attribute_namesearch(attr_searchstr)
if attr_matches:
for attribute in attr_matches:
source_object.emit_to(attribute.get_attrline())
else:
source_object.emit_to("No matching attributes found.")
else:
# Player is examining an object. Return a full readout of attributes,
# along with detailed information about said object.
string = ""
newl = "\r\n"
# Format the examine header area with general flag/type info.
string += str(target_obj.get_name(fullname=True)) + newl
string += str("Type: %s Flags: %s" % (target_obj.get_type(),
target_obj.get_flags())) + newl
string += str("Owner: %s " % target_obj.get_owner()) + newl
string += str("Zone: %s" % target_obj.get_zone()) + newl
string += str("Parent: %s " % target_obj.get_script_parent()) + newl
locks = target_obj.get_attribute_value("LOCKS")
if locks and "%s" % locks:
string += str("Locks: %s" % locks) + newl
# Contents container lists for sorting by type.
con_players = []
con_things = []
con_exits = []
# Break each object out into their own list.
for obj in target_obj.get_contents():
if obj.is_player():
con_players.append(obj)
elif obj.is_exit():
con_exits.append(obj)
elif obj.is_thing():
con_things.append(obj)
# Render the object's home or destination (for exits).
if not target_obj.is_room():
if target_obj.is_exit():
# The Home attribute on an exit is really its destination.
string += str("Destination: %s" % target_obj.get_home()) + newl
else:
# For everything else, home is home.
string += str("Home: %s" % target_obj.get_home()) + newl
# This obviously isn't valid for rooms.
string += str("Location: %s" % target_obj.get_location()) + newl
# Render other attributes
for attribute in target_obj.get_all_attributes():
string += str(attribute.get_attrline()) + newl
# Render Contents display.
if con_players or con_things:
string += str("%sContents:%s" % (ANSITable.ansi["hilite"],
ANSITable.ansi["normal"]))
for player in con_players:
string += str(' %s' % newl + player.get_name(fullname=True))
for thing in con_things:
string += str(' %s' % newl + thing.get_name(fullname=True))
# Render Exists display.
if con_exits:
string += str("%sExits:%s" % (newl + ANSITable.ansi["hilite"],
ANSITable.ansi["normal"]))
for exit in con_exits:
string += str(' %s' % newl + exit.get_name(fullname=True))
# Send it all
source_object.emit_to(string)
GLOBAL_CMD_TABLE.add_command("examine", cmd_examine, priv_tuple=("objects.info",))

View file

@ -2,7 +2,6 @@
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):
@ -31,7 +30,14 @@ def get_last_paged_objects(source_object):
def cmd_page(command):
"""
Send a message to target user (if online).
page - send private message
Usage:
page [<user> = <message>]
Send a message to target user (if online). If no
argument is given, you will instead see who was the last
person you paged to.
"""
source_object = command.source_object
# Get the last paged person(s)
@ -127,4 +133,4 @@ def cmd_page(command):
# Now set the LASTPAGED attribute
source_object.set_attribute("LASTPAGED", ','.join(
["#%d" % (x.id) for x in targets]))
GLOBAL_CMD_TABLE.add_command("page", cmd_page, priv_tuple=('channels.page',))
GLOBAL_CMD_TABLE.add_command("page", cmd_page, priv_tuple=('channels.page',), help_category="Comms")

View file

@ -2,10 +2,14 @@
Contains commands for managing script parents.
"""
from src import scripthandler
from src import defines_global
from src.cmdtable import GLOBAL_CMD_TABLE
def cmd_scriptcache(command):
"""Usage
"""
@scriptcache
Usage
@scriptcache
Shows the contents of the script cache.
@ -20,12 +24,21 @@ def cmd_scriptcache(command):
retval += "%d cached parents" % len(cache_dict)
command.source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("@scriptcache", cmd_scriptcache,
priv_tuple=("genperms.builder"),
auto_help=True,staff_help=True)
priv_tuple=("genperms.builder",), help_category="Admin")
def cmd_parent(command):
"""
Sets an object's script parent.
@parent - set script parent
Usage:
@parent <object> = <parent>
Example:
@parent button = examples.red_button
Sets an object's script parent. The parent must be identified
by its location using dot-notation pointing to the script
parent module.
"""
source_object = command.source_object
@ -80,5 +93,5 @@ def cmd_parent(command):
(target_obj,current_parent))
GLOBAL_CMD_TABLE.add_command("@parent", cmd_parent,
priv_tuple=("genperms.builder"))
priv_tuple=("genperms.builder",), help_category="Building" )

View file

@ -3,21 +3,30 @@ This file contains commands that require special permissions to use. These
are generally @-prefixed commands, but there are exceptions.
"""
from django.contrib.auth.models import Permission, Group, User
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission, Group
from django.conf import settings
from src.objects.models import Object
from src import defines_global
from src import ansi
from src import session_mgr
from src import comsys
from src.scripthandler import rebuild_cache
from src.util import functions_general
from src.cmdtable import GLOBAL_CMD_TABLE
from src.helpsys.models import HelpEntry
from src.helpsys import helpsystem
def cmd_reload(command):
"""
Reloads all modules.
@reload - reload game subsystems
Usage:
@reload/switches
Switches:
aliases - alias definitions
commands - the command modules
scripts, parents - the script parent modules
all
Reloads all the identified subsystems.
"""
source_object = command.source_object
switches = command.command_switches
@ -44,12 +53,17 @@ def cmd_reload(command):
comsys.cemit_mudinfo("... all Command modules were reloaded.")
GLOBAL_CMD_TABLE.add_command("@reload", cmd_reload,
priv_tuple=("genperms.process_control",)),
priv_tuple=("genperms.process_control",), help_category="Admin")
GLOBAL_CMD_TABLE.add_command("@restart", cmd_reload,
priv_tuple=("genperms.process_control",)),
priv_tuple=("genperms.process_control",), help_category="Admin")
def cmd_boot(command):
"""
@boot
Usage
@boot <player obj>
Boot a player object from the server.
"""
source_object = command.source_object
@ -119,10 +133,16 @@ def cmd_boot(command):
session_mgr.remove_session(boot)
return
GLOBAL_CMD_TABLE.add_command("@boot", cmd_boot,
priv_tuple=("genperms.manage_players",))
priv_tuple=("genperms.manage_players",),
help_category="Admin")
def cmd_newpassword(command):
"""
@newpassword
Usage:
@newpassword <user obj> = <new password>
Set a player's password.
"""
source_object = command.source_object
@ -157,10 +177,16 @@ def cmd_newpassword(command):
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",))
priv_tuple=("genperms.manage_players",),
help_category="Admin")
def cmd_home(command):
"""
home
Usage:
home
Teleport the player to their home.
"""
pobject = command.source_object
@ -174,8 +200,18 @@ GLOBAL_CMD_TABLE.add_command("home", cmd_home,
def cmd_service(command):
"""
Service management system. Allows for the listing, starting, and stopping
of services.
@service - manage services
Usage:
@service[/switch] <service>
Switches:
start - activates a service
stop - stops a service
list - shows all available services
Service management system. Allows for the listing,
starting, and stopping of services.
"""
source_object = command.source_object
switches = command.command_switches
@ -242,17 +278,25 @@ def cmd_service(command):
return
GLOBAL_CMD_TABLE.add_command("@service", cmd_service,
priv_tuple=("genperms.process_control",))
priv_tuple=("genperms.process_control",),
help_category="Admin")
def cmd_shutdown(command):
"""
Shut the server down gracefully.
@shutdown
Usage:
@shutdown
Shut the game server down gracefully.
"""
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",))
priv_tuple=("genperms.process_control",),
help_category="Admin")
# permission administration
@ -260,6 +304,7 @@ GLOBAL_CMD_TABLE.add_command("@shutdown", cmd_shutdown,
# mess with, but which are not very useful from inside the game. While these
# permissions are ok to use, we only show the permissions that we have defined
# in our settings file in order to give better control.
APPS_NOSHOW = ("news","admin","auth","config","contentypes",
"flatpages","news","sessions","sites")
SETTINGS_PERM_NAMES = []
@ -268,7 +313,9 @@ for apps in settings.PERM_ALL_DEFAULTS + settings.PERM_ALL_CUSTOM:
SETTINGS_PERM_NAMES.append(permtuples[1])
def cmd_setperm(command):
"""@setperm
"""
@setperm - set permissions
Usage:
@setperm[/switch] [<user>] = [<permission>]
@ -277,9 +324,9 @@ def cmd_setperm(command):
del : delete a permission from <user>
list : list all permissions, or those set on <user>
This command sets/clears individual permission bits on a user.
Use /list without any arguments to see all available permissions or those
defined on the <user> argument.
This command sets/clears individual permission bits on a user.
Use /list without any arguments to see all available permissions or those
defined on the <user> argument.
"""
source_object = command.source_object
args = command.command_argument
@ -380,17 +427,21 @@ def cmd_setperm(command):
obj.emit_to("%s removed your permission '%s'." % (source_object.get_name(show_dbref=False,no_ansi=True),
permission.name))
GLOBAL_CMD_TABLE.add_command("@setperm", cmd_setperm,
priv_tuple=("auth.change_permission","genperms.admin_perm"), auto_help=True, staff_help=True)
priv_tuple=("auth.change_permission",
"genperms.admin_perm"),
help_category="Admin")
def cmd_setgroup(command):
"""@setgroup
"""
@setgroup - manage group memberships
Usage:
@setgroup[/switch] [<user>] [= <group>]
switches
add : add user to a group
del : remove user from a group
list : list all groups a user is part of, or list all available groups if no user is given
Switches:
add - add user to a group
del - remove user from a group
list - list all groups a user is part of, or list all available groups if no user is given
Changes and views the group membership of a user.
"""
@ -410,7 +461,8 @@ def cmd_setgroup(command):
for p in g.permissions.all():
app = p.content_type.app_label
if app not in APPS_NOSHOW:
s += "\n --- %s.%s%s\t%s" % (app, p.codename, (35 - len(app) - len(p.codename)) * " ", p.name)
s += "\n --- %s.%s%s\t%s" % (app, p.codename,
(35 - len(app) - len(p.codename)) * " ", p.name)
source_object.emit_to(s)
return
#we have command arguments.
@ -484,5 +536,155 @@ def cmd_setgroup(command):
obj.emit_to("%s removed you from group '%s'." % (source_object.get_name(show_dbref=False,no_ansi=True),
group.name))
GLOBAL_CMD_TABLE.add_command("@setgroup", cmd_setgroup,
priv_tuple=("auth.change_group","genperms.admin_group"), auto_help=True, staff_help=True)
priv_tuple=("auth.change_group",
"genperms.admin_group"),
help_category="Admin")
def cmd_sethelp(command):
"""
@sethelp - edit the help database
Usage:
@sethelp[/switches] <topic>[,category][(permissions)][:<text>]
Switches:
add - add or replace a new topic with text.
append - add text to the end of topic.
delete - remove help topic.
force - (used with add) create help topic also if the topic
already exists.
newl - (used with append) add a newline between the old
text and the appended text.
Examples:
@sethelp/add throw : This throws something at ...
@sethelp/add throw, General (genperms.throwing) : This throws ...
@sethelp/add throw : 1st help entry
[[@sethelp_markup]]
@sethelp Help markup
The <text> entry in @sethelp supports markup to automatically divide the help text into
several sub-entries. The beginning of each new entry is marked in the form
[ [Title, category, (privtuple)] ] (with no spaces between the square brackets)
In the markup header, Title is mandatory, the other parts are optional. A new
help entry named Title will be created for each occurence. It is recommended
that the help entries should begin similarly since the system will then identify
them and better handle a list of recommended topics.
"""
source_object = command.source_object
arg = command.command_argument
switches = command.command_switches
if not arg or not switches:
source_object.emit_to("Usage: @sethelp/[add|del|append] <topic>[,category][:<text>]")
return
topicstr = ""
category = ""
text = ""
permtuple = ()
# analyze the argument
arg = arg.split(':', 1)
if len(arg) < 2:
# no : detected; this means we are deleting something.
topicstr = arg[0].strip()
else:
text = arg[1].strip()
# we have 4 possibilities:
# topicstr
# topicstr, category
# topicstr (perm1,perm2,...)
# topicstr, category, (perm1,perm2,...)
arg = arg[0].split('(',1)
if len(arg) > 1:
# we have a perm tuple
arg, permtuple = arg
try:
permtuple = permtuple.strip()[:-1] # cut last ')'
except IndexError:
source_object.emit_to("Malformed permission tuple. %s" % permtuple)
return
permtuple = tuple(permtuple.split(','))
else:
# no perm tuple
arg = arg[0]
arg = arg.split(',', 1)
if len(arg) > 1:
# we have a category
category = arg[1].strip()
topicstr = arg[0].strip()
if 'add' in switches:
# add a new help entry.
if not topicstr or not text:
source_object.emit_to("Usage: @sethelp/add <topic>[,category]:<text>")
return
force_create = ('for' in switches) or ('force' in switches)
topics = helpsystem.edithelp.add_help_manual(source_object, topicstr,
category, text,
permissions=permtuple,
force=force_create)
if not topics:
return
if len(topics) == 1:
string = "The topic already exists. Use /force to overwrite it."
elif len(topics)>1:
string = "The following results are similar to '%s'."
string += " Make sure you are not misspelling, then "
string += "use the /force flag to create a new entry."
string += "\n ".join(topics)
source_object.emit_to(string)
elif 'append' in switches or 'app' in switches:
# add text to the end of a help topic
if not topicstr or not text:
source_object.emit_to("Usage: @sethelp/append <topic>:<text>")
return
# find the topic to append to
topics = HelpEntry.objects.find_topicmatch(source_object, topicstr)
if not topics:
source_object.emit_to("Help topic '%s' not found." % topicstr)
elif len(topics) > 1:
string = "Multiple matches to this topic. Refine your search."
string += "\n ".join(topics)
else:
# we have exactly one match. Extract all info from it,
# append the text and feed it back into the system.
newtext = topics[0].get_entrytext_ingame()
category = topics[0].category
perm_tuple = topics[0].canview
if perm_tuple:
perm_tuple = tuple(perm for perm in perm_tuple.split(','))
newl = "\n"
if 'newl' in switches or 'newline' in switches:
newl = "\n\n"
newtext += "%s%s" % (newl, text)
topics = helpsystem.edithelp.add_help_manual(source_object,
topicstr,
category,
newtext,
perm_tuple,
force=True)
elif 'del' in switches or 'delete' in switches:
#delete a help entry
topics = helpsystem.edithelp.del_help_manual(source_object, topicstr)
if not topics:
return
else:
string = "Multiple matches for '%s'. Please specify:" % topicstr
string += "\n ".join(topics)
GLOBAL_CMD_TABLE.add_command("@sethelp", cmd_sethelp,
priv_tuple=("helpsys.add_help",
"helpsys.del_help",
"helpsys.admin_heelp"),
help_category="Admin")

View file

@ -146,6 +146,11 @@ def build_query(source_object, search_query, search_player, search_type,
def cmd_search(command):
"""
search
Usage:
search <name>
Searches for owned objects as per MUX2.
"""
source_object = command.source_object
@ -232,4 +237,5 @@ def cmd_search(command):
display_results(source_object, search_query)
GLOBAL_CMD_TABLE.add_command("@search", cmd_search,
priv_tuple=("objects.info")),
priv_tuple=("objects.info",),
help_category="Building")

View file

@ -3,7 +3,7 @@ Commands that are available from the connect screen.
"""
import traceback
from django.contrib.auth.models import User
from src.objects.models import Attribute, Object
from src.objects.models import Object
from src import defines_global
from src.util import functions_general
from src.cmdtable import GLOBAL_UNCON_CMD_TABLE
@ -47,7 +47,7 @@ def cmd_connect(command):
else:
uname = user.username
session.login(user)
GLOBAL_UNCON_CMD_TABLE.add_command("connect", cmd_connect)
GLOBAL_UNCON_CMD_TABLE.add_command("connect", cmd_connect, auto_help_override=False)
def cmd_create(command):
"""
@ -113,7 +113,7 @@ def cmd_create(command):
log_errmsg(traceback.format_exc())
raise
GLOBAL_UNCON_CMD_TABLE.add_command("create", cmd_create)
GLOBAL_UNCON_CMD_TABLE.add_command("create", cmd_create, auto_help_override=False)
def cmd_quit(command):
"""
@ -124,4 +124,4 @@ def cmd_quit(command):
session = command.session
session.msg("Good bye! Disconnecting ...")
session.handle_close()
GLOBAL_UNCON_CMD_TABLE.add_command("quit", cmd_quit)
GLOBAL_UNCON_CMD_TABLE.add_command("quit", cmd_quit, auto_help_override=False)