diff src/plugins/plugin_misc_text_commands.py @ 1082:246712d2e7bc

plugin XEP-0045, text_commands: add some commands: - handle generic failure in text_commands - fix command /leave and a logging message - add commands /kick /ban /affiliate
author souliane <souliane@mailoo.org>
date Mon, 23 Jun 2014 15:42:56 +0200
parents e88bff4c8b77
children 0abce7f17782
line wrap: on
line diff
--- a/src/plugins/plugin_misc_text_commands.py	Thu Jun 19 20:33:42 2014 +0200
+++ b/src/plugins/plugin_misc_text_commands.py	Mon Jun 23 15:42:56 2014 +0200
@@ -131,13 +131,19 @@
                     log.debug("text commands took over")
                     raise failure.Failure(exceptions.CancelError())
 
+            def genericErrback(failure):
+                self.feedBack("Command failed with condition '%s'" % failure.value.condition, mess_data, profile)
+                return False
+
             try:
                 mess_data["unparsed"] = msg[1 + len(command):]  # part not yet parsed of the message
                 d = defer.maybeDeferred(self._commands[command], mess_data, profile)
+                d.addCallbacks(lambda ret: ret, genericErrback)  # XXX: dummy callback is needed
                 d.addCallback(retHandling)
+
             except KeyError:
                 self.feedBack(_("Unknown command /%s. ") % command + self.HELP_SUGGESTION, mess_data, profile)
-                self.debug("text commands took over")
+                log.debug("text commands took over")
                 raise failure.Failure(exceptions.CancelError())
 
         return d or mess_data  # if a command is detected, we should have a deferred, else we send the message normally