def onExecuteCommand(self, iq): 'Called when we receive a relevant iq' if self.testAuth: if not self.testAuth(jid.internJID(iq['from'])): pass # disallow node = iq.command['node'] if node not in self.commands: # shouldn't really happen ever self._entity._xmlstream.send(messageStanza(iq['from'], "no such command")) cmd = self.commands[node] # call the function specified newIq = cmd(self._entity._xmlstream, iq) if newIq: # send the resulting iq back self._entity._xmlstream.send(newIq)
def sendResponse(result, xmlstream, to): xmlstream.send(messageStanza(to, result))
def receiveAuthorizedCommand(self, msg): "Called when we receive a message from a whitelisted address.. override in your own class" m = messageStanza(msg['from'], 'whitelisted :)', 'normal') self._xmlstream.send(m)