Some friend of mine asked me today if I can help him to communicate with google talk from python as he wants to send notifications about some network usage over the chat service. In fact, that was pretty interesting and it just inspired me with tons and zillions of ideas that you can do with that, things like getting security alters, usage logs, any simply feedback that you want to receive while being online and without being irritated with the fact that you have to refresh what you are monitoring every while.
It’s not a hard trick at all, but looks like all of the scripts on the internet are written wrong! and he have been trying to use all of them with no luck, so I helped him as I have some good experience with python-xmpp (xmpppy) module in python.
The idea is that we want to send a message to a Google Apps. User and use another account on the same domain to chat and here comes the trick about it and of course this script is released under the BSD License so you can do whatever you want to do with it
import xmpp
client = xmpp.Client('ahmedsoliman.com')
client.connect(server=('<a href="http://talk.google.com/" target="_blank">talk.google.com</a>', 5222))
client.auth(user='myUser', password='myPassword', resource='myResource', sasl=0)
client.send( xmpp.Message('anotherUser@ahmedsoliman.com', 'Hello World'))
Of course you can download the python-xmpp package manually or if you are using fedora, simply use the magical yum install python-xmpp