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
This commit is contained in:
Brian S. Stephan 2017-02-23 21:35:03 -06:00
parent b58b208f29
commit 995bb643f3

View File

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