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

@ -204,20 +204,29 @@ class IRCBot(irc.IRCClient, Session):
"""
self.sessionhandler.data_in(self, text=text, **kwargs)
def data_out(self, text=None, **kwargs):
def send_text(self, *args, **kwargs):
"""
Data from server-> IRC.
Send channel text to IRC
Args:
text (str): Outgoing text
Kwargs:
text (str): Outgoing text.
kwargs (any): Other data to protocol.
bot_data_out (bool): If True, echo to channel.
"""
if text.startswith("bot_data_out"):
text = text.split(" ", 1)[1]
text = args[0] if args else ""
if text and kwargs['options'].get("bot_data_out", False):
text = parse_irc_colors(text)
self.say(self.channel, text)
def send_default(self, *args, **kwargs):
"""
Ignore other types of sends.
"""
pass
class IRCBotFactory(protocol.ReconnectingClientFactory):
"""

View file

@ -152,7 +152,7 @@ class SessionHandler(dict):
applied.
"""
options = kwargs.get("options", None) or {}
options = kwargs.pop("options", None) or {}
raw = options.get("raw", False)
strip_inlinefunc = options.get("strip_inlinefunc", False)
@ -204,6 +204,7 @@ class SessionHandler(dict):
rkwargs[key] = [ _validate(data), {} ]
else:
rkwargs[key] = [ [_validate(data)], {} ]
rkwargs[key][1]["options"] = options
return rkwargs