From 8bec2e62a1e10fe40955c757d9c8a555cb45257e Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Fri, 7 Jan 2011 00:44:31 -0600 Subject: [PATCH] make it possible for a module to respond and tell irclib to stop calling other handlers. this works via Module.reply(). if it produces IRC output, it returns "NO MORE", which is returned by do(), which is returned by the handler, which instructs irclib to cease calling handlers. now all we need is some priorities for the modules (also supported by irclib) and we may be in business --- Module.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Module.py b/Module.py index 7102051..faff8ff 100644 --- a/Module.py +++ b/Module.py @@ -166,7 +166,7 @@ class Module(object): what = addressed_re.sub('', what) try: - self.do(connection, event, nick, userhost, replypath, what, admin_unlocked) + return self.do(connection, event, nick, userhost, replypath, what, admin_unlocked) except Exception as e: print('EXCEPTION: ' + str(e)) @@ -201,11 +201,11 @@ class Module(object): return try: - self.do(connection, event, nick, userhost, replypath, what, admin_unlocked) + return self.do(connection, event, nick, userhost, replypath, what, admin_unlocked) except Exception as e: print('EXCEPTION: ' + str(e)) - def reply(self, connection, replypath, replystr): + def reply(self, connection, replypath, replystr, stop_responding=True): """ Reply over IRC to replypath or return a string with the reply. Utility method to do the proper type of reply (either to IRC, or as a return @@ -220,6 +220,8 @@ class Module(object): return replystr else: connection.privmsg(replypath, replystr) + if stop_responding: + return "NO MORE" def remove_metaoptions(self, list): """Remove metaoptions from provided list, which was probably from a config file."""