DrBotIRC: fix an !alias add thinko with event handling ordering
before, !alias commands were handled via an on_pubmsg() in DrBotIRC, which meant they happened (due to refactoring) after alias and recursion scanning happened in a more low-level routine. thus, if you were trying to add an alias that had recursion in it, your alias would be the outcome of that recursion, not the command to recurse. oops
This commit is contained in:
parent
9ec73c4aa6
commit
be4763f6a5
25
DrBotIRC.py
25
DrBotIRC.py
@ -99,14 +99,12 @@ class DrBotIRC(irclib.IRC):
|
|||||||
self.server = DrBotServerConnection(self)
|
self.server = DrBotServerConnection(self)
|
||||||
self.connections.append(self.server)
|
self.connections.append(self.server)
|
||||||
|
|
||||||
self.server.add_global_handler('pubmsg', self.on_pubmsg, 1)
|
|
||||||
self.server.add_global_handler('privmsg', self.on_pubmsg, 1)
|
|
||||||
|
|
||||||
return self.server
|
return self.server
|
||||||
|
|
||||||
def _handle_event(self, connection, event):
|
def _handle_event(self, connection, event):
|
||||||
"""Override event handler to do recursion."""
|
"""Override event handler to do recursion."""
|
||||||
|
|
||||||
|
self.try_alias_cmds(connection, event)
|
||||||
self.try_recursion(connection, event)
|
self.try_recursion(connection, event)
|
||||||
self.try_alias(connection, event)
|
self.try_alias(connection, event)
|
||||||
|
|
||||||
@ -133,15 +131,24 @@ class DrBotIRC(irclib.IRC):
|
|||||||
if len(replies):
|
if len(replies):
|
||||||
event.arguments()[0] = '\n'.join(replies)
|
event.arguments()[0] = '\n'.join(replies)
|
||||||
|
|
||||||
def on_pubmsg(self, connection, event):
|
def try_alias_cmds(self, connection, event):
|
||||||
"""See if there is an alias ("!command") in the text, and if so, translate it into
|
"""See if there is an alias ("!command") in the text, and if so
|
||||||
an internal bot command and run it.
|
do alias manipulation before any other recursion or aliasing.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
nick = irclib.nm_to_n(event.source())
|
try:
|
||||||
userhost = irclib.nm_to_uh(event.source())
|
nick = irclib.nm_to_n(event.source())
|
||||||
|
except (IndexError, AttributeError):
|
||||||
|
nick = ''
|
||||||
|
try:
|
||||||
|
userhost = irclib.nm_to_uh(event.source())
|
||||||
|
except (IndexError, AttributeError):
|
||||||
|
userhost = ''
|
||||||
replypath = event.target()
|
replypath = event.target()
|
||||||
what = event.arguments()[0]
|
try:
|
||||||
|
what = event.arguments()[0]
|
||||||
|
except (IndexError, AttributeError):
|
||||||
|
what = ''
|
||||||
admin_unlocked = False
|
admin_unlocked = False
|
||||||
|
|
||||||
# privmsg
|
# privmsg
|
||||||
|
Loading…
Reference in New Issue
Block a user