Made IRC work with new send mechanism, as per #924.

This commit is contained in:
Griatch 2016-02-20 12:53:17 +01:00
parent 6782ff1333
commit ddb87d6aea
4 changed files with 32 additions and 15 deletions

View file

@ -135,12 +135,12 @@ class Bot(DefaultPlayer):
"""
pass
def msg(self, text=None, from_obj=None, session=None, **kwargs):
def msg(self, text=None, from_obj=None, session=None, options=None, **kwargs):
"""
Evennia -> outgoing protocol
"""
super(Bot, self).msg(text=text, from_obj=from_obj, session=session, **kwargs)
super(Bot, self).msg(text=text, from_obj=from_obj, session=session, options=options, **kwargs)
def execute_cmd(self, raw_string, session=None):
"""
@ -233,14 +233,14 @@ class IRCBot(Bot):
- from_obj (str): dbid of an object sending this text.
"""
options = kwargs.get("options", {})
from_obj = kwargs.get("from_obj", None)
options = kwargs.get("options", None) or {}
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 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)
if not from_obj or from_obj != [self.id]:
super(IRCBot, self).msg(text=text, options={"bot_data_out": True})
def execute_cmd(self, text=None, session=None):
"""
@ -391,8 +391,7 @@ class IMC2Bot(Bot):
self.ndb.ev_channel = self.db.ev_channel
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)
self.msg(text=text, options={"bot_data_out": True})
def execute_cmd(self, text=None, session=None):
"""

View file

@ -409,6 +409,14 @@ class DefaultPlayer(with_metaclass(TypeclassBase, PlayerDB)):
from_obj.at_msg_send(text=text, to_obj=self, **kwargs)
except Exception:
pass
try:
if not self.at_msg_receive(text=text, **kwargs):
# abort message to this player
return
except Exception:
pass
kwargs["options"] = options
# session relay
sessions = make_iter(session) if session else self.sessions.all()