Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import xmpp,string,re,BeautifulSoup,urllib
  2.  
  3. jid = 'assholefuck@jabber.ru';
  4. password = 'fdaa';
  5. room = 'touhouchan@conference.jabber.ru';
  6. resource = 'tds';
  7. admin = 'xfsz'
  8.  
  9. def urlp(url):
  10. try:
  11. soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(url));
  12. title = soup.title.string;
  13. if title.strip() != '':
  14. title = 'Title: '+unicode(title.strip());
  15. cl.send(xmpp.Message(to=room,typ='groupchat',body=title));
  16. except:
  17. error = 'Name or service not known';
  18. print error;
  19.  
  20. def msgCB(cl,msg):
  21. text = unicode(msg.getBody());
  22. user = unicode(msg.getFrom());
  23. cmd = text.split(' ');
  24.  
  25. if msg.getType() == 'groupchat' and user != room:
  26. urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', text);
  27. map(urlp, urls);
  28. exit;
  29. if user == '%s/%s'%(room,admin) and cmd[0] == '!nick':
  30. chg_nick = xmpp.Presence(frm='%s/%s'%(jid,jid.getResource()),to='%s/%s'%(room,text[6:]));
  31. cl.send(chg_nick);
  32. exit;
  33. if msg.getType() == 'chat' and not msg.getTag('x') and cmd[0] == '!say':
  34. cl.send(xmpp.Message(to=room,typ='groupchat',body=text[5:]));
  35.  
  36. jid = xmpp.protocol.JID(jid);
  37. cl = xmpp.Client(jid.getDomain());
  38. cl.connect();
  39. cl.RegisterHandler('message',msgCB);
  40. cl.auth(jid.getNode(),password,jid.getResource());
  41. presence = xmpp.Presence(to='%s/%s'%(room,resource));
  42. presence.setTag('x',namespace = xmpp.NS_MUC);
  43. presence.getTag('x').addChild('history',{'maxchars':'0','maxstanzas':'0'});
  44. cl.send(presence);
  45. while 1:
  46. cl.Process(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement