DrBotIRC: have regex handler take list of events

forgot to commit the unhook part
This commit is contained in:
Brian S. Stephan 2014-03-16 15:09:40 -05:00
parent 0c7e4023ac
commit bda4b78564
1 changed files with 10 additions and 7 deletions

View File

@ -288,7 +288,7 @@ class DrBotIRC(irclib.IRC):
"""Removes a global regex handler function. """Removes a global regex handler function.
Args: Args:
event event type (a string), as in numeric_events event list of event type (a string), as in numeric_events
regex regex string that was used in matching regex regex string that was used in matching
handler callback function to remove handler callback function to remove
@ -297,13 +297,16 @@ class DrBotIRC(irclib.IRC):
""" """
if not event in self.regex_handlers: if type(event) != list:
return 0 event = [event]
for h in self.regex_handlers[event]: for ev in event:
if regex == h[1] and handler == h[2]: if not ev in self.regex_handlers:
self.regex_handlers[event].remove(h) continue
return 1
for h in self.regex_handlers[ev]:
if regex == h[1] and handler == h[2]:
self.regex_handlers[ev].remove(h)
def _handle_event(self, connection, event): def _handle_event(self, connection, event):
"""Override event handler to do recursion and regex checking. """Override event handler to do recursion and regex checking.