From 995bb643f347214552c096ecbef8117db0aa074c Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Thu, 23 Feb 2017 21:35:03 -0600 Subject: [PATCH] attempt to have outbound recursion same logic as replacing [subcommand] with the output of subcommand, but on the outbound side, via {subcommand}. this lets you do something like, say: !echo {!facts buh} and that won't get interpreted until '{!facts buh}' is on its way out of the bot. thus, you could also put '{!facts buh}' into the output of some other command, like a countdown reminder --- ircbot/bot.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ircbot/bot.py b/ircbot/bot.py index c6cb81c..bddb10a 100644 --- a/ircbot/bot.py +++ b/ircbot/bot.py @@ -888,6 +888,19 @@ class IRCBot(irc.client.SimpleIRCClient): if recursing: return replystr else: + # try doing outbound recursion + log.debug("old replystr: %s", replystr) + if event: + fake_event = copy.deepcopy(event) + fake_event.arguments[0] = copy.deepcopy(replystr).replace('{', '[').replace('}', ']') + else: + fake_event = irc.client.Event(type='pubmsg', source='fake', target='fake') + fake_event.arguments.append(copy.deepcopy(replystr).replace('{', '[').replace('}', ']')) + log.debug("hacked replystr: %s", fake_event.arguments[0]) + self.connection.reactor.try_recursion(self.connection, fake_event) + replystr = fake_event.arguments[0] + log.debug("final replystr: %s", replystr) + lines = 0 replies = replystr.split('\n') for reply in replies: