From bda4b78564cf8e905a4a578b61674017a71c0e4e Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sun, 16 Mar 2014 15:09:40 -0500 Subject: [PATCH] DrBotIRC: have regex handler take list of events forgot to commit the unhook part --- ircbot/DrBotIRC.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ircbot/DrBotIRC.py b/ircbot/DrBotIRC.py index 1774b5f..b7d1abb 100644 --- a/ircbot/DrBotIRC.py +++ b/ircbot/DrBotIRC.py @@ -288,7 +288,7 @@ class DrBotIRC(irclib.IRC): """Removes a global regex handler function. 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 handler callback function to remove @@ -297,13 +297,16 @@ class DrBotIRC(irclib.IRC): """ - if not event in self.regex_handlers: - return 0 + if type(event) != list: + event = [event] - for h in self.regex_handlers[event]: - if regex == h[1] and handler == h[2]: - self.regex_handlers[event].remove(h) - return 1 + for ev in event: + if not ev in self.regex_handlers: + continue + + 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): """Override event handler to do recursion and regex checking.