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
This commit is contained in:
parent
25382c9db6
commit
56ec86b8e5
1 changed files with 174 additions and 2 deletions
|
|
@ -131,13 +131,19 @@ class TextCommands(object):
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue