From 8448b513e1f97dd787fc2bab4f3139b83e3d7827 Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 12 Feb 2016 17:51:07 +0100 Subject: [PATCH] Converted msg-arguments to options --- evennia/commands/cmdhandler.py | 6 +++--- evennia/commands/default/building.py | 2 +- evennia/commands/default/system.py | 8 ++++---- evennia/comms/comms.py | 2 +- evennia/players/bots.py | 20 ++++++++++++-------- evennia/utils/eveditor.py | 8 ++++---- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/evennia/commands/cmdhandler.py b/evennia/commands/cmdhandler.py index f7cd7d002b..d89452c3a9 100644 --- a/evennia/commands/cmdhandler.py +++ b/evennia/commands/cmdhandler.py @@ -114,7 +114,7 @@ def _msg_err(receiver, string): string (str): string which will be shown to the user. """ - receiver.msg(string.format(_nomulti=True, timestamp=logger.timeformat()).strip()) + receiver.msg(string.format(timestamp=logger.timeformat()).strip()) # custom Exceptions @@ -570,12 +570,12 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess returnValue(ret) elif sysarg: # return system arg - error_to.msg(exc.sysarg, _nomulti=True) + error_to.msg(exc.sysarg) except NoCmdSets: # Critical error. logger.log_err("No cmdsets found: %s" % caller) - error_to.msg(_ERROR_NOCMDSETS, _nomulti=True) + error_to.msg(_ERROR_NOCMDSETS) except Exception: # We should not end up here. If we do, it's a programming bug. diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 5b65758d21..2ba7211c7a 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -1512,7 +1512,7 @@ class CmdSetAttribute(ObjManipCommand): continue string += self.view_attr(obj, attr) # we view it without parsing markup. - self.caller.msg(string.strip(), raw=True) + self.caller.msg(string.strip(), options={"raw":True}) return else: # deleting the attribute(s) diff --git a/evennia/commands/default/system.py b/evennia/commands/default/system.py index 64f8dac04b..4eabe9f816 100644 --- a/evennia/commands/default/system.py +++ b/evennia/commands/default/system.py @@ -176,9 +176,9 @@ class CmdPy(MuxCommand): 'inherits_from': utils.inherits_from} try: - self.msg(">>> %s" % pycode, raw=True, session=self.session) + self.msg(">>> %s" % pycode, session=self.session, options={"raw":True}) except TypeError: - self.msg(">>> %s" % pycode, raw=True) + self.msg(">>> %s" % pycode, options={"raw":True}) mode = "eval" try: @@ -207,9 +207,9 @@ class CmdPy(MuxCommand): ret = "\n".join("%s" % line for line in errlist if line) try: - self.msg(ret, session=self.session, raw=True) + self.msg(ret, session=self.session, options={"raw":True}) except TypeError: - self.msg(ret, raw=True) + self.msg(ret, options={"raw":True}) # helper function. Kept outside so it can be imported and run diff --git a/evennia/comms/comms.py b/evennia/comms/comms.py index 614edcd9bd..08b1df99c8 100644 --- a/evennia/comms/comms.py +++ b/evennia/comms/comms.py @@ -198,7 +198,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)): try: # note our addition of the from_channel keyword here. This could be checked # by a custom player.msg() to treat channel-receives differently. - entity.msg(msg.message, from_obj=msg.senders, from_channel=self.id) + entity.msg(msg.message, from_obj=msg.senders, options={"from_channel":self.id}) except AttributeError as e: logger.log_trace("%s\nCannot send msg to '%s'." % (e, entity)) diff --git a/evennia/players/bots.py b/evennia/players/bots.py index 327354bbce..396597951d 100644 --- a/evennia/players/bots.py +++ b/evennia/players/bots.py @@ -228,15 +228,17 @@ class IRCBot(Bot): text (str, optional): Incoming text from channel. Kwargs: - from_channel (str): dbid of a channel this text originated from. - from_obj (str): dbid of an object sending this text. + options (dict): Options dict with the following allowed keys: + - from_channel (str): dbid of a channel this text originated from. + - from_obj (str): dbid of an object sending this text. """ + options = kwargs.get("options", {}) if not self.ndb.ev_channel and self.db.ev_channel: # cache channel lookup self.ndb.ev_channel = self.db.ev_channel - if "from_channel" in kwargs and text and self.ndb.ev_channel.dbid == kwargs["from_channel"]: - if "from_obj" not in kwargs or kwargs["from_obj"] != [self.id]: + if "from_channel" in options and text and self.ndb.ev_channel.dbid == options["from_channel"]: + if "from_obj" not in options or options["from_obj"] != [self.id]: text = "bot_data_out %s" % text super(IRCBot, self).msg(text=text) @@ -378,15 +380,17 @@ class IMC2Bot(Bot): text (str): Message from channel. Kwargs: - from_channel (str): dbid of a channel this text originated from. - from_obj (str): dbid of an object sending this text. + options (dict): Option dict with these allowed keys: + - from_channel (str): dbid of a channel this text originated from. + - from_obj (str): dbid of an object sending this text. """ + options = kwargs.get("options", {}) if not self.ndb.ev_channel and self.db.ev_channel: # cache channel lookup self.ndb.ev_channel = self.db.ev_channel - if "from_channel" in kwargs and text and self.ndb.ev_channel.dbid == kwargs["from_channel"]: - if "from_obj" not in kwargs or kwargs["from_obj"] != [self.id]: + if "from_channel" in options and text and self.ndb.ev_channel.dbid == options["from_channel"]: + if "from_obj" not in options or options["from_obj"] != [self.id]: text = "bot_data_out %s" % text self.msg(text=text) diff --git a/evennia/utils/eveditor.py b/evennia/utils/eveditor.py index d293577e1e..3f1230bc4e 100644 --- a/evennia/utils/eveditor.py +++ b/evennia/utils/eveditor.py @@ -347,9 +347,9 @@ class CmdEditorGroup(CmdEditorBase): buf = linebuffer[lstart:lend] editor.display_buffer(buf=buf, offset=lstart, - linenums=False, raw=True) + linenums=False, options={"raw":True}) else: - editor.display_buffer(linenums=False, raw=True) + editor.display_buffer(linenums=False, {options={"raw":True}) elif cmd == ":::": # Insert single colon alone on a line editor.update_buffer(editor.buffer + "\n:") @@ -717,7 +717,7 @@ class EvEditor(object): self._undo_buffer = self._undo_buffer[:self._undo_pos + 1] + [self._buffer] self._undo_pos = len(self._undo_buffer) - 1 - def display_buffer(self, buf=None, offset=0, linenums=True, raw=False): + def display_buffer(self, buf=None, offset=0, linenums=True, options={"raw":False}): """ This displays the line editor buffer, or selected parts of it. @@ -750,7 +750,7 @@ class EvEditor(object): else: main = "\n".join(lines) string = "%s\n%s\n%s" % (header, main, footer) - self._caller.msg(string, raw=raw) + self._caller.msg(string, options={"raw":raw}) def display_help(self): """