· 8 years ago · Jun 03, 2018, 07:40 AM
1#gtalk.py
2#Based on script written by "Tha.Suresh" (sent to ILUGC mailing list)
3#modified by Ashish Bhatia
4
5import xmpp
6import getpass
7
8# Google Talk
9FROM_GMAIL_ID = raw_input("Enter gmail ID:")
10GMAIL_PASS = getpass.getpass("Enter Password:")
11GTALK_SERVER = "gmail.com"
12
13jid=xmpp.protocol.JID(FROM_GMAIL_ID)
14C=xmpp.Client(jid.getDomain(),debug=[])
15
16if not C.connect((GTALK_SERVER,5222)):
17 raise IOError('Can not connect to server.')
18if not C.auth(jid.getNode(),GMAIL_PASS):
19 raise IOError('Can not auth with server.')
20
21C.sendInitPresence(requestRoster=1)
22
23def myPresenceHandler(con, event):
24 if event.getType() == 'unavailable':
25 print event.getFrom().getStripped()
26
27C.RegisterHandler('presence', myPresenceHandler)
28while C.Process(1):
29 pass