Converted msg-arguments to options
This commit is contained in:
parent
cd8651c740
commit
8448b513e1
6 changed files with 25 additions and 21 deletions
|
|
@ -114,7 +114,7 @@ def _msg_err(receiver, string):
|
||||||
string (str): string which will be shown to the user.
|
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
|
# custom Exceptions
|
||||||
|
|
@ -570,12 +570,12 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
|
||||||
returnValue(ret)
|
returnValue(ret)
|
||||||
elif sysarg:
|
elif sysarg:
|
||||||
# return system arg
|
# return system arg
|
||||||
error_to.msg(exc.sysarg, _nomulti=True)
|
error_to.msg(exc.sysarg)
|
||||||
|
|
||||||
except NoCmdSets:
|
except NoCmdSets:
|
||||||
# Critical error.
|
# Critical error.
|
||||||
logger.log_err("No cmdsets found: %s" % caller)
|
logger.log_err("No cmdsets found: %s" % caller)
|
||||||
error_to.msg(_ERROR_NOCMDSETS, _nomulti=True)
|
error_to.msg(_ERROR_NOCMDSETS)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# We should not end up here. If we do, it's a programming bug.
|
# We should not end up here. If we do, it's a programming bug.
|
||||||
|
|
|
||||||
|
|
@ -1512,7 +1512,7 @@ class CmdSetAttribute(ObjManipCommand):
|
||||||
continue
|
continue
|
||||||
string += self.view_attr(obj, attr)
|
string += self.view_attr(obj, attr)
|
||||||
# we view it without parsing markup.
|
# we view it without parsing markup.
|
||||||
self.caller.msg(string.strip(), raw=True)
|
self.caller.msg(string.strip(), options={"raw":True})
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
# deleting the attribute(s)
|
# deleting the attribute(s)
|
||||||
|
|
|
||||||
|
|
@ -176,9 +176,9 @@ class CmdPy(MuxCommand):
|
||||||
'inherits_from': utils.inherits_from}
|
'inherits_from': utils.inherits_from}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.msg(">>> %s" % pycode, raw=True, session=self.session)
|
self.msg(">>> %s" % pycode, session=self.session, options={"raw":True})
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.msg(">>> %s" % pycode, raw=True)
|
self.msg(">>> %s" % pycode, options={"raw":True})
|
||||||
|
|
||||||
mode = "eval"
|
mode = "eval"
|
||||||
try:
|
try:
|
||||||
|
|
@ -207,9 +207,9 @@ class CmdPy(MuxCommand):
|
||||||
ret = "\n".join("%s" % line for line in errlist if line)
|
ret = "\n".join("%s" % line for line in errlist if line)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.msg(ret, session=self.session, raw=True)
|
self.msg(ret, session=self.session, options={"raw":True})
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.msg(ret, raw=True)
|
self.msg(ret, options={"raw":True})
|
||||||
|
|
||||||
|
|
||||||
# helper function. Kept outside so it can be imported and run
|
# helper function. Kept outside so it can be imported and run
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
try:
|
try:
|
||||||
# note our addition of the from_channel keyword here. This could be checked
|
# note our addition of the from_channel keyword here. This could be checked
|
||||||
# by a custom player.msg() to treat channel-receives differently.
|
# 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:
|
except AttributeError as e:
|
||||||
logger.log_trace("%s\nCannot send msg to '%s'." % (e, entity))
|
logger.log_trace("%s\nCannot send msg to '%s'." % (e, entity))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -228,15 +228,17 @@ class IRCBot(Bot):
|
||||||
text (str, optional): Incoming text from channel.
|
text (str, optional): Incoming text from channel.
|
||||||
|
|
||||||
Kwargs:
|
Kwargs:
|
||||||
from_channel (str): dbid of a channel this text originated from.
|
options (dict): Options dict with the following allowed keys:
|
||||||
from_obj (str): dbid of an object sending this text.
|
- 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:
|
if not self.ndb.ev_channel and self.db.ev_channel:
|
||||||
# cache channel lookup
|
# cache channel lookup
|
||||||
self.ndb.ev_channel = self.db.ev_channel
|
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_channel" in options and text and self.ndb.ev_channel.dbid == options["from_channel"]:
|
||||||
if "from_obj" not in kwargs or kwargs["from_obj"] != [self.id]:
|
if "from_obj" not in options or options["from_obj"] != [self.id]:
|
||||||
text = "bot_data_out %s" % text
|
text = "bot_data_out %s" % text
|
||||||
super(IRCBot, self).msg(text=text)
|
super(IRCBot, self).msg(text=text)
|
||||||
|
|
||||||
|
|
@ -378,15 +380,17 @@ class IMC2Bot(Bot):
|
||||||
text (str): Message from channel.
|
text (str): Message from channel.
|
||||||
|
|
||||||
Kwargs:
|
Kwargs:
|
||||||
from_channel (str): dbid of a channel this text originated from.
|
options (dict): Option dict with these allowed keys:
|
||||||
from_obj (str): dbid of an object sending this text.
|
- 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:
|
if not self.ndb.ev_channel and self.db.ev_channel:
|
||||||
# cache channel lookup
|
# cache channel lookup
|
||||||
self.ndb.ev_channel = self.db.ev_channel
|
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_channel" in options and text and self.ndb.ev_channel.dbid == options["from_channel"]:
|
||||||
if "from_obj" not in kwargs or kwargs["from_obj"] != [self.id]:
|
if "from_obj" not in options or options["from_obj"] != [self.id]:
|
||||||
text = "bot_data_out %s" % text
|
text = "bot_data_out %s" % text
|
||||||
self.msg(text=text)
|
self.msg(text=text)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -347,9 +347,9 @@ class CmdEditorGroup(CmdEditorBase):
|
||||||
buf = linebuffer[lstart:lend]
|
buf = linebuffer[lstart:lend]
|
||||||
editor.display_buffer(buf=buf,
|
editor.display_buffer(buf=buf,
|
||||||
offset=lstart,
|
offset=lstart,
|
||||||
linenums=False, raw=True)
|
linenums=False, options={"raw":True})
|
||||||
else:
|
else:
|
||||||
editor.display_buffer(linenums=False, raw=True)
|
editor.display_buffer(linenums=False, {options={"raw":True})
|
||||||
elif cmd == ":::":
|
elif cmd == ":::":
|
||||||
# Insert single colon alone on a line
|
# Insert single colon alone on a line
|
||||||
editor.update_buffer(editor.buffer + "\n:")
|
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_buffer = self._undo_buffer[:self._undo_pos + 1] + [self._buffer]
|
||||||
self._undo_pos = len(self._undo_buffer) - 1
|
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.
|
This displays the line editor buffer, or selected parts of it.
|
||||||
|
|
||||||
|
|
@ -750,7 +750,7 @@ class EvEditor(object):
|
||||||
else:
|
else:
|
||||||
main = "\n".join(lines)
|
main = "\n".join(lines)
|
||||||
string = "%s\n%s\n%s" % (header, main, footer)
|
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):
|
def display_help(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue