Converted msg-arguments to options

This commit is contained in:
Griatch 2016-02-12 17:51:07 +01:00
parent cd8651c740
commit 8448b513e1
6 changed files with 25 additions and 21 deletions

View file

@ -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)