mirror of
https://github.com/evennia/evennia.git
synced 2026-04-03 06:27:17 +02:00
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.
|
||||
|
||||
"""
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue