Sunday, August 29, 2010

How to catch your invisible friends on GTalk

If you have a Google account then you might have experienced Google chat which is integrated with GMail and it can also accessed via XMPP. if you have used it then you may know that so many people don't like to go online so they make themselves invisible. today in this post i am going to explain a simple way to find out who are the invisible buddies.
in this post i have used python and python-xmpp library and i have tested this on Linux but i suppose this will work on Windows as well.
since i did this on Linux(Ubuntu) i am writing the steps for Debian based operating systems which normally comes with python. type this in  you terminal

sudo apt-get install python-xmpp python-dnspython

enter your super user password and wait till it installed. then open your favorite text editor in this case i am using gedit. copy and paste this code :
import xmpp

FROM_GMAIL_ID = "kesh.jboy@gmail.com"
GMAIL_PASS = ":Pthisisnotmyrealpassword:P"
GTALK_SERVER = "gmail.com"

jid=xmpp.protocol.JID(FROM_GMAIL_ID)
C=xmpp.Client(jid.getDomain(),debug=[])

if not C.connect((GTALK_SERVER,5222)):
    raise IOError('Can not connect to server.')
if not C.auth(jid.getNode(),GMAIL_PASS):
    raise IOError('Authentication error.')

C.sendInitPresence(requestRoster=1)

def myPresenceHandler(con, event):
   if event.getType() == 'unavailable':
     print event.getFrom().getStripped()

C.RegisterHandler('presence', myPresenceHandler)
while C.Process(1):
  pass

right !!! save this file as mygtalk.py and simply type

python mygtalk.py


in terminal...... wow you can see all your invisible buddies just give them a wink... have fun..

Cheers !
Kesh,