Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xmpp,string,re,BeautifulSoup,urllib
- jid = 'assholefuck@jabber.ru';
- password = 'fdaa';
- room = 'touhouchan@conference.jabber.ru';
- resource = 'tds';
- admin = 'xfsz'
- def urlp(url):
- try:
- soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(url));
- title = soup.title.string;
- if title.strip() != '':
- title = 'Title: '+unicode(title.strip());
- cl.send(xmpp.Message(to=room,typ='groupchat',body=title));
- except:
- error = 'Name or service not known';
- print error;
- def msgCB(cl,msg):
- text = unicode(msg.getBody());
- user = unicode(msg.getFrom());
- cmd = text.split(' ');
- if msg.getType() == 'groupchat' and user != room:
- urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', text);
- map(urlp, urls);
- exit;
- if user == '%s/%s'%(room,admin) and cmd[0] == '!nick':
- chg_nick = xmpp.Presence(frm='%s/%s'%(jid,jid.getResource()),to='%s/%s'%(room,text[6:]));
- cl.send(chg_nick);
- exit;
- if msg.getType() == 'chat' and not msg.getTag('x') and cmd[0] == '!say':
- cl.send(xmpp.Message(to=room,typ='groupchat',body=text[5:]));
- jid = xmpp.protocol.JID(jid);
- cl = xmpp.Client(jid.getDomain());
- cl.connect();
- cl.RegisterHandler('message',msgCB);
- cl.auth(jid.getNode(),password,jid.getResource());
- presence = xmpp.Presence(to='%s/%s'%(room,resource));
- presence.setTag('x',namespace = xmpp.NS_MUC);
- presence.getTag('x').addChild('history',{'maxchars':'0','maxstanzas':'0'});
- cl.send(presence);
- while 1:
- cl.Process(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement