Ejemplo n.º 1
0
 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())
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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())