Gtalk 的 Xmpp 实现。更改状态 这可能会对您有所帮助。
导入 xmpp
导入 dns
类 Gtalk():
def __init__(self,bot_id,bot_pwd): 
    self.bot_id = bot_id
    self.bot_pwd = bot_pwd
def connect(self):                           
    self.jid = xmpp.protocol.JID(self.bot_id)
    self.presnc = xmpp.protocol.Presence()
    self.conn = xmpp.Client(self.jid.getDomain(),debug=[])
    if self.conn.connect():
        print 'connected..'
        self.auth()
    else:
        print 'err to connect'
def auth(self): 
    if self.conn.auth(self.jid.getNode(),self.bot_pwd):
        self.conn.sendInitPresence()
        print 'Authenticated..'
    else:
        print 'err to authenticate'
def setStatus(self,value):
    self.conn.send(xmpp.protocol.Presence(status=value))
def invisible(self,username):
    self.conn.send(xmpp.protocol.Presence(username,typ='unavailable'))
def visible(slef,username):
    self.conn.send(xmpp.protocol.Presence(username,typ=None))
def disconnect(self):
    self.conn.disconnect()