Fix traceback from public channel with chars and ircbot. Expand msg from_obj to accept lists. Resolves #1397.
This commit is contained in:
parent
f68674fea9
commit
604b36fb4e
3 changed files with 23 additions and 16 deletions
|
|
@ -392,8 +392,8 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text (str, optional): text data to send
|
text (str, optional): text data to send
|
||||||
from_obj (Object or Account, optional): Object sending. If given,
|
from_obj (Object or Account or list, optional): Object sending. If given, its
|
||||||
its at_msg_send() hook will be called.
|
at_msg_send() hook will be called. If iterable, call on all entities.
|
||||||
session (Session or list, optional): Session object or a list of
|
session (Session or list, optional): Session object or a list of
|
||||||
Sessions to receive this send. If given, overrules the
|
Sessions to receive this send. If given, overrules the
|
||||||
default send behavior for the current
|
default send behavior for the current
|
||||||
|
|
@ -405,11 +405,12 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
|
||||||
"""
|
"""
|
||||||
if from_obj:
|
if from_obj:
|
||||||
# call hook
|
# call hook
|
||||||
|
for obj in make_iter(from_obj):
|
||||||
try:
|
try:
|
||||||
from_obj.at_msg_send(text=text, to_obj=self, **kwargs)
|
obj.at_msg_send(text=text, to_obj=self, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
# this may not be assigned.
|
# this may not be assigned.
|
||||||
pass
|
logger.log_trace()
|
||||||
try:
|
try:
|
||||||
if not self.at_msg_receive(text=text, **kwargs):
|
if not self.at_msg_receive(text=text, **kwargs):
|
||||||
# abort message to this account
|
# abort message to this account
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,10 @@ class IRCBot(Bot):
|
||||||
"ssl": self.db.irc_ssl}
|
"ssl": self.db.irc_ssl}
|
||||||
_SESSIONS.start_bot_session("evennia.server.portal.irc.IRCBotFactory", configdict)
|
_SESSIONS.start_bot_session("evennia.server.portal.irc.IRCBotFactory", configdict)
|
||||||
|
|
||||||
|
def at_msg_send(self, **kwargs):
|
||||||
|
"Shortcut here or we can end up in infinite loop"
|
||||||
|
pass
|
||||||
|
|
||||||
def get_nicklist(self, caller):
|
def get_nicklist(self, caller):
|
||||||
"""
|
"""
|
||||||
Retrive the nick list from the connected channel.
|
Retrive the nick list from the connected channel.
|
||||||
|
|
@ -256,7 +260,7 @@ class IRCBot(Bot):
|
||||||
Kwargs:
|
Kwargs:
|
||||||
options (dict): Options dict with the following allowed keys:
|
options (dict): Options dict with the following allowed keys:
|
||||||
- from_channel (str): dbid of a channel this text originated from.
|
- from_channel (str): dbid of a channel this text originated from.
|
||||||
- from_obj (list): list of objects this text.
|
- from_obj (list): list of objects sending this text.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from_obj = kwargs.get("from_obj", None)
|
from_obj = kwargs.get("from_obj", None)
|
||||||
|
|
@ -265,7 +269,7 @@ class IRCBot(Bot):
|
||||||
# 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 options and text and self.ndb.ev_channel.dbid == options["from_channel"]:
|
if "from_channel" in options and text and self.ndb.ev_channel.dbid == options["from_channel"]:
|
||||||
if not from_obj or from_obj != [self.id]:
|
if not from_obj or from_obj != [self]:
|
||||||
super(IRCBot, self).msg(channel=text)
|
super(IRCBot, self).msg(channel=text)
|
||||||
|
|
||||||
def execute_cmd(self, session=None, txt=None, **kwargs):
|
def execute_cmd(self, session=None, txt=None, **kwargs):
|
||||||
|
|
@ -346,7 +350,7 @@ class IRCBot(Bot):
|
||||||
# cache channel lookup
|
# cache channel lookup
|
||||||
self.ndb.ev_channel = self.db.ev_channel
|
self.ndb.ev_channel = self.db.ev_channel
|
||||||
if self.ndb.ev_channel:
|
if self.ndb.ev_channel:
|
||||||
self.ndb.ev_channel.msg(text, senders=self.id)
|
self.ndb.ev_channel.msg(text, senders=self)
|
||||||
|
|
||||||
#
|
#
|
||||||
# RSS
|
# RSS
|
||||||
|
|
|
||||||
|
|
@ -487,9 +487,10 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
is treated internally like any send-command, so its
|
is treated internally like any send-command, so its
|
||||||
value can be a tuple if sending multiple arguments to
|
value can be a tuple if sending multiple arguments to
|
||||||
the `text` oob command.
|
the `text` oob command.
|
||||||
from_obj (obj, optional): object that is sending. If
|
from_obj (obj or list, optional): object that is sending. If
|
||||||
given, at_msg_send will be called. This value will be
|
given, at_msg_send will be called. This value will be
|
||||||
passed on to the protocol.
|
passed on to the protocol. If iterable, will execute hook
|
||||||
|
on all entities in it.
|
||||||
session (Session or list, optional): Session or list of
|
session (Session or list, optional): Session or list of
|
||||||
Sessions to relay data to, if any. If set, will force send
|
Sessions to relay data to, if any. If set, will force send
|
||||||
to these sessions. If unset, who receives the message
|
to these sessions. If unset, who receives the message
|
||||||
|
|
@ -508,8 +509,9 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
"""
|
"""
|
||||||
# try send hooks
|
# try send hooks
|
||||||
if from_obj:
|
if from_obj:
|
||||||
|
for obj in make_iter(from_obj):
|
||||||
try:
|
try:
|
||||||
from_obj.at_msg_send(text=text, to_obj=self, **kwargs)
|
obj.at_msg_send(text=text, to_obj=self, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue