From 76e898a2a3bab94cf383bec61fbb2f947ccb33d3 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Thu, 2 Jun 2011 13:57:06 +0200 Subject: [PATCH] Allow custom_message_handler to return True Thanks to Wanja Chresta for the initial patch. --- jabberbot.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/jabberbot.py b/jabberbot.py index f239e59..ce218a7 100644 --- a/jabberbot.py +++ b/jabberbot.py @@ -440,6 +440,13 @@ class JabberBot(object): # Try the custom handler first. It can return None # if you want JabberBot to fall back to the default. reply = self.custom_message_handler(mess, text) + + # If your custom_message_handler returns True, it + # is assumed that the custom_message_handler has + # taken care of processing the message, so we do + # not process the message any further here. + if reply == True: + return else: reply = None @@ -453,8 +460,11 @@ class JabberBot(object): # In private chat, it's okay for the bot to always respond. # In group chat, the bot should silently ignore commands it # doesn't understand or aren't handled by unknown_command(). - default_reply = 'Unknown command: "%s". Type "help" for available commands.' % cmd - if type == "groupchat": default_reply = None + if type == 'groupchat': + default_reply = None + else: + default_reply = ('Unknown command: "%s". ' + \ + 'Type "help" for available commands.') % cmd reply = self.unknown_command(mess, cmd, args) if reply is None: reply = default_reply -- 2.11.4.GIT