def test_XMPP_participant_jid_from_MUC_message_hipchat(self): # Real message from Hipchat MUC msg_txt = """ <message xmlns="jabber:client" to="[email protected]/HipchatBot" type="groupchat" from="[email protected]/Guillaume BINET"> <body>test</body> <x xmlns="http://hipchat.com"><sender>[email protected]</sender></x> </message>""" message = Message(node=msg_txt) self.assertEqual(str(get_jid_from_message(message)), "*****@*****.**")
def test(): client = Client('localhost') def message_handler(conn, mess_node): client.send(Message('tim@localhost', 'reponse!')) if not client.connect(server=('127.0.0.1', 5222)): raise IOError('Can not connect to server.') if not client.auth('abitbol', 'abitbol', 'abitbol'): raise IOError('Can not auth with server.') client.RegisterHandler('message', message_handler) client.sendInitPresence() client.send(Message('tim@localhost', 'Test message')) while 1: client.Process(1)
def message_handler(conn, mess_node): client.send(Message('tim@localhost', 'reponse!'))
def send(self, destination, action): self.client.send(Message('tim@localhost', str(action)))