I’m trying to access my google talk contacts’ custom status messages with xmpppy. I’m made it this far:
import xmpp
import sys
userID = 'myname@gmail.com'
password = 'mypassword'
ressource = 'Script'
jid = xmpp.protocol.JID(userID)
jabber = xmpp.Client(jid.getDomain(), debug=[])
connection = jabber.connect(('talk.google.com',5222))
auth = jabber.auth(jid.getNode(), password, ressource)
jabber.sendInitPresence(requestRoster=1)
myroster = jabber.getRoster()
the roster object myroster now contains my contacts, but the custom status message is not included.
myroster.getStatus('oneofmyfriends@gmail.com')
returns None
looking at the ‘raw roster’, I can see that the resources dictionary is empty
u'oneofmyfriends@googlemail.com': {'ask': None, 'resources': {}, 'name': u'Some Name', 'groups': [], 'subscription': u'both'}
The weird thing is that I have gotten this to work today, but I the code might have been slightly different, but I can’t figure out what exactly I did differently…
Any help would be greatly appreciated!
Cheers,
Martin
It’s a timing issue. Add a handler with:
BEFORE connecting. Then make sure to call
jabber.Process()in a loop. The issue is that with your code, you’ll sometimes receive presence stanzas before you look at the roster object, and sometimes after.