Cleaned up worst instability. Test suite does validate yet.

This commit is contained in:
Griatch 2013-09-21 17:33:48 +02:00
parent fa93c70e7f
commit e36c7d5cc1
24 changed files with 134 additions and 300 deletions

View file

@ -343,11 +343,11 @@ def cmdhandler(called_on, raw_string, testing=False, callertype="session", sessi
cmd.cmdstring = cmdname
cmd.args = args
cmd.cmdset = cmdset
cmd.sessid = session.sessid if session else sessid
cmd.session = session
cmd.player = player
#cmd.obj # set via command handler
cmd.sessid = session.sessid if session else sessid
cmd.raw_string = unformatted_raw_string
#cmd.obj # set via command handler
if hasattr(cmd, 'obj') and hasattr(cmd.obj, 'scripts'):
# cmd.obj is automatically made available by the cmdhandler.

View file

@ -206,7 +206,7 @@ class Command(object):
"""
return self.lockhandler.check(srcobj, access_type, default=default)
def msg(self, msg="", to_obj=None, from_obj=None, data=None, sessid=None, all_sessions=False):
def msg(self, msg="", to_obj=None, from_obj=None, sessid=None, all_sessions=False, **kwargs):
"""
This is a shortcut instad of calling msg() directly on an object - it will
detect if caller is an Object or a Player and also appends self.sessid
@ -234,7 +234,7 @@ class Command(object):
# if to_obj is a different Player, all their sessions
# will be notified unless sessid was given specifically
sessid = None
to_obj.msg(msg, from_obj=from_obj, data=data, sessid=sessid)
to_obj.msg(msg, from_obj=from_obj, sessid=sessid, **kwargs)
# Common Command hooks

View file

@ -416,9 +416,8 @@ class CmdEmit(MuxCommand):
continue
if obj.access(caller, 'tell'):
obj.msg(message)
if send_to_contents:
for content in obj.contents:
content.msg(message)
if send_to_contents and hasattr(obj, "msg_contents"):
obj.msg_contents(message)
caller.msg("Emitted to %s and its contents." % objname)
else:
caller.msg("Emitted to %s." % objname)

View file

@ -155,7 +155,7 @@ class CmdDelCom(MuxPlayerCommand):
return
else:
# we are removing a channel nick
channame = caller.nicks.get_replace(key=ostring, category="channel")
channame = caller.nicks.get(key=ostring, category="channel")
channel = find_channel(caller, channame, silent=True)
if not channel:
self.msg("No channel with alias '%s' was found." % ostring)
@ -949,7 +949,7 @@ class CmdIMCInfo(MuxCommand):
return
from src.comms.imc2 import IMC2_CLIENT
self.msg("Sending IMC whois request. If you receive no response, no matches were found.")
IMC2_CLIENT.msg_imc2(None, from_obj=self.caller, packet_type="imcwhois", data={"target":self.args})
IMC2_CLIENT.msg_imc2(None, from_obj=self.caller, packet_type="imcwhois", target=self.args)
elif not self.switches or "channels" in self.switches or self.cmdstring == "@imcchanlist":
# show channels
@ -1007,7 +1007,7 @@ class CmdIMCTell(MuxCommand):
data = {"target":target, "destination":destination}
# send to imc2
IMC2_CLIENT.msg_imc2(message, from_obj=self.caller, packet_type="imctell", data=data)
IMC2_CLIENT.msg_imc2(message, from_obj=self.caller, packet_type="imctell", **data)
self.msg("You paged {c%s@%s{n (over IMC): '%s'." % (target, destination, message))

View file

@ -628,10 +628,10 @@ class CmdQuell(MuxPlayerCommand):
player.attributes.remove('_quell')
self.msg("Player permissions%s restored." % permstr)
else:
if player.get('_quell'):
if player.attributes.get('_quell'):
self.msg("Already quelling Player%s permissions." % permstr)
return
player.add('_quell', True)
player.attributes.add('_quell', True)
self.msg("Quelling Player permissions%s. Use @unquell to get them back." % permstr)
self._recache_locks(player)

View file

@ -163,9 +163,9 @@ class CmdPy(MuxCommand):
'inherits_from':utils.inherits_from}
try:
self.msg(">>> %s" % pycode, data={"raw":True}, sessid=self.sessid)
self.msg(">>> %s" % pycode, raw=True, sessid=self.sessid)
except TypeError:
self.msg(">>> %s" % pycode, data={"raw":True})
self.msg(">>> %s" % pycode, raw=True)
mode = "eval"

View file

@ -78,9 +78,11 @@ class CommandTest(TestCase):
cmdobj.cmdstring = cmdobj.key
cmdobj.args = args
cmdobj.cmdset = cmdset
cmdobj.sessid = 1
cmdobj.session = None
cmdobj.player = self.player
cmdobj.raw_string = cmdobj.key + " " + args
cmdobj.obj = self.char1
cmdobj.sessid = 1
# test
self.char1.player.ndb.stored_msg = []
cmdobj.at_pre_cmd()