1
# gozerbot/utils/xmpp.py
5
from xml.etree import cElementTree as ET
8
def make_presence(xml):
9
pres = {'subject': '', 'to': '', 'message': '', 'name': '', 'resource': '', 'jid': ''}
10
if type(xml) == types.DictType:
14
pres.update(et[0].items())
17
pres['name'] = pres['from'].split('@')[0]
18
pres['resource'] = pres['from'].split('/')[1]
19
pres['jid'] = pres['from'].split('/')[0]
24
def make_message(xml):
25
msg = {'subject': '', 'to': '', 'txt': '', 'message': '', 'from': '', 'jid': '', 'name': '', 'resource': ''}
26
if type(xml) == types.DictType:
30
msg.update(et[0].items())
32
msg['message'] = unicode(xml.findtext('body'))
33
msg['name'] = msg['from'].split('@')[0]
34
msg['resource'] = msg['from'].split('/')[1]
35
msg['jid'] = msg['from'].split('/')[0]