bot: don't strip []s if no replacement happened
This commit is contained in:
parent
c4714d3691
commit
6f9bbd304f
@ -244,15 +244,15 @@ class DrReactor(irc.client.Reactor):
|
|||||||
# modules can do something with it. this calls the same
|
# modules can do something with it. this calls the same
|
||||||
# event handlers in the same way as if this were a native
|
# event handlers in the same way as if this were a native
|
||||||
# event.
|
# event.
|
||||||
self.try_to_replace_event_text_with_module_text(connection, newevent)
|
replacements = self.try_to_replace_event_text_with_module_text(connection, newevent)
|
||||||
|
if replacements:
|
||||||
# we have done all we can do with the sub-event. whatever
|
# we have done all we can do with the sub-event. whatever
|
||||||
# the text of that event now is, we should replace the parent
|
# the text of that event now is, we should replace the parent
|
||||||
# event's [] section with it.
|
# event's [] section with it.
|
||||||
oldtext = event.arguments[0]
|
oldtext = event.arguments[0]
|
||||||
newtext = oldtext.replace('['+subcmd+']', newevent.arguments[0])
|
newtext = oldtext.replace('['+subcmd+']', newevent.arguments[0])
|
||||||
log.debug("oldtext: '%s' newtext: '%s'", oldtext, newtext)
|
log.debug("oldtext: '%s' newtext: '%s'", oldtext, newtext)
|
||||||
event.arguments[0] = newtext
|
event.arguments[0] = newtext
|
||||||
|
|
||||||
# we have now resolved the []. recursion will unfold, replacing
|
# we have now resolved the []. recursion will unfold, replacing
|
||||||
# it further and further, until we eventually get back to the
|
# it further and further, until we eventually get back to the
|
||||||
@ -275,6 +275,7 @@ class DrReactor(irc.client.Reactor):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
replacement = False
|
||||||
replies = []
|
replies = []
|
||||||
|
|
||||||
# only do aliasing for pubmsg/privmsg
|
# only do aliasing for pubmsg/privmsg
|
||||||
@ -306,6 +307,7 @@ class DrReactor(irc.client.Reactor):
|
|||||||
log.debug("result: %s", result)
|
log.debug("result: %s", result)
|
||||||
if result:
|
if result:
|
||||||
log.debug("appending %s to replies", result)
|
log.debug("appending %s to replies", result)
|
||||||
|
replacement = True
|
||||||
replies.append(result)
|
replies.append(result)
|
||||||
|
|
||||||
matching_handlers = sorted(
|
matching_handlers = sorted(
|
||||||
@ -318,11 +320,14 @@ class DrReactor(irc.client.Reactor):
|
|||||||
log.debug("result: %s", result)
|
log.debug("result: %s", result)
|
||||||
if result:
|
if result:
|
||||||
log.debug("appending %s to replies", result)
|
log.debug("appending %s to replies", result)
|
||||||
|
replacement = True
|
||||||
replies.append(result)
|
replies.append(result)
|
||||||
|
|
||||||
if len(replies):
|
if len(replies):
|
||||||
event.arguments[0] = '\n'.join(replies)
|
event.arguments[0] = '\n'.join(replies)
|
||||||
|
|
||||||
|
return replacement
|
||||||
|
|
||||||
|
|
||||||
class IRCBot(irc.client.SimpleIRCClient):
|
class IRCBot(irc.client.SimpleIRCClient):
|
||||||
"""A single-server IRC bot class."""
|
"""A single-server IRC bot class."""
|
||||||
|
Loading…
Reference in New Issue
Block a user