Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- from xmpp import *
- from time import sleep
- from Queue import LifoQueue
- from sys import argv
- username = ''
- password = ''
- server = 'jabber.ru'
- q = LifoQueue()
- name = argv[1]
- process = True
- cl = Client(server, debug = [])
- cl.connect()
- cl.auth(username, password)
- def disco(conn, iq):
- global q, process
- if iq.getID() == 'disco1':
- for x in iq.getTag('query').getTags('item'): q.put(Iq(to = x.getAttr('jid'), typ = 'get', queryNS = NS_DISCO_ITEMS))
- else:
- if name in [x.getAttr('name') for x in iq.getTag('query').getTags('item')]: print iq.getFrom()
- if q.empty(): process = False
- cl.RegisterHandler('iq', disco, NS_DISCO_ITEMS)
- cl.send(Iq(to = 'conference.jabber.ru', typ = 'get', queryNS = NS_DISCO_ITEMS, attrs = {'id': 'disco1'}))
- print 'Ищем `%s\'' % argv[1]
- while process:
- sleep(0.1)
- cl.Process()
- if not q.empty(): cl.send(q.get())
Add Comment
Please, Sign In to add comment