comparison 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
comparison
equal deleted inserted replaced
1081:5d89fecdf667 1082:246712d2e7bc
129 return mess_data 129 return mess_data
130 else: 130 else:
131 log.debug("text commands took over") 131 log.debug("text commands took over")
132 raise failure.Failure(exceptions.CancelError()) 132 raise failure.Failure(exceptions.CancelError())
133 133
134 def genericErrback(failure):
135 self.feedBack("Command failed with condition '%s'" % failure.value.condition, mess_data, profile)
136 return False
137
134 try: 138 try:
135 mess_data["unparsed"] = msg[1 + len(command):] # part not yet parsed of the message 139 mess_data["unparsed"] = msg[1 + len(command):] # part not yet parsed of the message
136 d = defer.maybeDeferred(self._commands[command], mess_data, profile) 140 d = defer.maybeDeferred(self._commands[command], mess_data, profile)
141 d.addCallbacks(lambda ret: ret, genericErrback) # XXX: dummy callback is needed
137 d.addCallback(retHandling) 142 d.addCallback(retHandling)
143
138 except KeyError: 144 except KeyError:
139 self.feedBack(_("Unknown command /%s. ") % command + self.HELP_SUGGESTION, mess_data, profile) 145 self.feedBack(_("Unknown command /%s. ") % command + self.HELP_SUGGESTION, mess_data, profile)
140 self.debug("text commands took over") 146 log.debug("text commands took over")
141 raise failure.Failure(exceptions.CancelError()) 147 raise failure.Failure(exceptions.CancelError())
142 148
143 return d or mess_data # if a command is detected, we should have a deferred, else we send the message normally 149 return d or mess_data # if a command is detected, we should have a deferred, else we send the message normally
144 150
145 def getRoomJID(self, arg, service_jid): 151 def getRoomJID(self, arg, service_jid):