Guest User

Untitled

a guest
May 29th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from xmpp import *
  5. from time import sleep
  6. from Queue import LifoQueue
  7. from sys import argv
  8.  
  9. username = ''
  10. password = ''
  11. server = 'jabber.ru'
  12.  
  13. q = LifoQueue()
  14. name = argv[1]
  15. process = True
  16.  
  17. cl = Client(server, debug = [])
  18. cl.connect()
  19. cl.auth(username, password)
  20.  
  21. def disco(conn, iq):
  22. global q, process
  23.  
  24. if iq.getID() == 'disco1':
  25. for x in iq.getTag('query').getTags('item'): q.put(Iq(to = x.getAttr('jid'), typ = 'get', queryNS = NS_DISCO_ITEMS))
  26.  
  27. else:
  28. if name in [x.getAttr('name') for x in iq.getTag('query').getTags('item')]: print iq.getFrom()
  29. if q.empty(): process = False
  30.  
  31. cl.RegisterHandler('iq', disco, NS_DISCO_ITEMS)
  32.  
  33. cl.send(Iq(to = 'conference.jabber.ru', typ = 'get', queryNS = NS_DISCO_ITEMS, attrs = {'id': 'disco1'}))
  34.  
  35. print 'Ищем `%s\'' % argv[1]
  36.  
  37. while process:
  38. sleep(0.1)
  39. cl.Process()
  40. if not q.empty(): cl.send(q.get())
Add Comment
Please, Sign In to add comment