Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import irclib
- import urllib2
- import re
- network = 'irc.redbrick.dcu.ie'
- port = 6667
- channel = '#lobby'
- nick = 'TinyURL'
- name = 'TinyURL'
- owner = 'lithium'
- apiurl = "http://tinyurl.com/api-create.php?url="
- irc = irclib.IRC()
- s = irc.server()
- s.connect(network, port, nick, ircname=name)
- s.join(channel)
- def handleTiny(connection, event):
- if event.arguments()[0].lower().find('http') == 0:
- line = event.arguments()[0]
- if len(line) > 90:
- u = re.match(r'http:\/\/([\w.]+\/?)\S*', line, re.M|re.I)
- url = u.group()
- tinyurl = urllib2.urlopen(apiurl + url).read()
- s.privmsg(channel, tinyurl)
- irc.add_global_handler('pubmsg', handleTiny)
- irc.process_forever()
Add Comment
Please, Sign In to add comment