def reply_message(self, message, body): """ Reply to message with body. """ response = Message(recipient=message.sender, sender=message.recipient, body=body) response.stanzaType = 'chat' self.send(response.toElement())
def handle_message(self, element): #print element.toXml() message = Message.fromElement(element) if message.stanzaType == 'chat': # print "From: %s To: %s\n%s" % (message.sender, # message.recipient, # message.body) # # parse command for (pattern, handler) in self.commands: match = re.search(pattern, message.body) if match: handler(message)
def on_hello(self, message): response = Message(recipient=message.sender, sender=message.recipient, body="Hi I'm the backyard irrigation controller.") response.stanzaType = 'chat' self.send(response.toElement())