Howto to Talk with GoogleTalk in Python

I guess everybody know GoogleTalk right now. Linux users like me knows that it ’s only a Jabber server with SIP extension. Like a lot of people seems to use this, I decided to switch from MSN(suxTm) to this Jabber server, beside it lacks a lot of Jabber features (like offline messaging )

But, how can I send a message to my Gmail Talk in less 10 lines of code. I decided to look at xmpppy .. Ok I get a strange issue w/ secure login ..

As I already use gajim, I decided to look at this code.. Hum, look strange it has the same xmpp module, with the same API, but this one is working.

import xmpp

login = 'Your.Login' # @gmail.com
pwd   = 'YourPassword'

cnx = xmpp.Client('gmail.com')
cnx.connect( server=('talk.google.com',5223) )

cnx.auth(login,pwd, 'botty')

cnx.send( xmpp.Message( "YourFriend@gmail.com" ,"Hello World form Python" ) )

As you can see this is small and simple :) The only issue is to find the right module, and hope the xmpppy will fix that soon.

(In fact gajim team seems to fork the xmpp code due to lack of support. This bug already exists in the xmpppy bug list )

Related posts :

admin August 31st, 2005

13 Responses to “Howto to Talk with GoogleTalk in Python”

  1. philon 31 Aug 2005 at 9:06 am

    GTalk doesn’t support SIP yet. See the GTalk developer info page

  2. Jkxon 31 Aug 2005 at 10:02 am

    On yes, it’s Jabber + InDoor_Not_Public_Yet_P2P_VOIP, you’re right.. But anyways, I guess not a lot of people will use this VOIP provider right now.

  3. Swaroopon 31 Aug 2005 at 10:41 am

    Interesting.

    Is it this easy to write a spimbot for GTalk?

  4. zgodaon 31 Aug 2005 at 11:48 am

    The most complete XMPP/Jabber library currently in the wild is PyXMPP (http://pyxmpp.jabberstudio.org/). Unfortunately, it is currently supported only on linux platform, though some work is underway to port it to Windows.

  5. Jkxon 31 Aug 2005 at 1:29 pm

    Perhaps it’s time to merge no ? 3 modules w/ quite the same API..

    As usual in Python world, divide to loose :(

  6. Nikos Kouremenoson 31 Aug 2005 at 3:05 pm

    dev of xmpppy does have time/interest to maintain it anymore. Hopefully someone else will go to apply our (as in Gajim) patches as eventhough we were asking him to do so when we were commiting he thought our patches were something like testing for his stable (!) xmpppy..

    apart from PyXMPP there is also xmpp in twisted but it lives in 2000

  7. Jonon 31 Aug 2005 at 7:34 pm

    Nice … very useful little snippet.  Thanks!



    Jon - jon_edwards@spanners4us.com

  8. nikos kouremenoson 02 Sep 2005 at 11:26 am

    in fact, he wants to maintain the library but he doesn’t have the time and he hopes he sometime later or someone else will apply our patches to cvs. he doesn’t plan to release anytime soon neither unfortunately.

  9. Alexey Nezhdanovon 02 Sep 2005 at 11:29 am

    Hello. I’m the maintainer of xmpppy library. I was out for holidays so probably feeled quite unresponsive.
    I’ll patch this bug.
    What for words of Nikos - I have never said about stopping maintaing library. Last 6 months I had not wrote any new code but was regularly fixing bugs and intending to do that in future.

  10. Ricon 15 Sep 2005 at 4:15 pm

    J’en pense rien
    C’est juste un test

    ++

  11. Cerinon 06 Oct 2005 at 6:27 am

    Better example code might have been something that works. Your code errors with:

      File “/usr/lib/python2.4/site-packages/xmpp/auth.py”, line 139, in FeaturesHandler

        sasl_data=’%sx00%sx00%s’%(self.username+’@'+self._owner.Server,self.username,self.password)

    AttributeError: SASL instance has no attribute ‘username’

    Indeed, xmpppy appears so riddled with bugs, none of its “sample” scripts work either. I can see why the dev abandoned it. After several minutes trying to fix its bugs, I quickly discovered a having root-canal would be more fun. Please developers, ensure your code from CVS works before releasing it.

  12. Richieon 19 Jul 2007 at 12:39 am

    Two years old. Still very useful :)

  13. LKRaideron 03 May 2008 at 6:47 am

    Can’t get it to work :(

    Is there a better jabber lib for python?

Comments RSS

Leave a Reply