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 )
GTalk doesn’t support SIP yet. See the GTalk developer info page
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.
Interesting.
Is it this easy to write a spimbot for GTalk?
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.
Perhaps it’s time to merge no ? 3 modules w/ quite the same API..
As usual in Python world, divide to loose :(
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
Nice … very useful little snippet. Thanks!
—
Jon – jon_edwards@spanners4us.com
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.
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.
J’en pense rien
C’est juste un test
++
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.
Two years old. Still very useful :)
Can’t get it to work :(
Is there a better jabber lib for python?
How can I use this to get my domain (domain.com for the sake of security) hosted at google gtalk account working? I’ve tried to no avail –
import xmpp
login = ‘user@domain.com’ # @gmail.com
pwd = ‘password’
cnx = xmpp.Client(‘domain.com’)
cnx.connect( server=(‘talk.google.com’,5223) )
cnx.auth(login,pwd, ‘botty’)
cnx.send( xmpp.Message( “paul@domain.com” ,”Hello World form Python” ) )
@ Paul Pasika:
Try this:
import xmpp
login = ‘user’ #no @ domain.com
pwd = ‘pass’
connection = xmpp.Client(‘Domain.com’)
connection.connect(server=(‘talk.google.com’,5222))
connection.auth(login,pwd,”Bot”)
Hi,
Nice example. I’m getting duplicate messages on my Motorola Droid when I use this method. I’m not sure whether it is the Android Gtalk Client or this method or some interaction of the two. When I send messages using xmpppy they are not duplicated in the Windows Gtalk Window. Messages are not duplicated when they are not sent with xmpppy. Just wondering if anyone had any idea what was going on. This is my first interaction with xmpp.
Thanks,
Roger
I’ve discovered that when no resource identifier is provided for the sender, I receive double message with the Android client. When I use the resource identifier of my phone, which I obtained with Pidgin, I receive single posts as I should. So that is a work around if anyone stumbles on to the same problem.
Hi , very very tanx buT how to send a message to response ?????????????? :O
Hi,
Checkout http://www.miglu.com
Its a service which allows low cost international calls directly from your phone.
It also has a xmpp bot. Add gomiglu@gmail.com to your friends list and try :)
Regards
Miglu
hello friends, this is very awsome, i tested it under python 2.0.0 on my nokia n97 mini and it works awsome.
hope will figure how to develop more advanced application.:D
best regards and thanx for this
wook
For some reason this code didn’t work for me – this one did the trick:
http://www.sakibiqbal.com/2011/programming/sending-google-talk-im-using-python/
Thanks all the same!
Hi,
This code works. But how can i get incoming messages from gtalk?