19 lines
384 B
Python
19 lines
384 B
Python
import re
|
|
import urllib2
|
|
|
|
from util import hook
|
|
|
|
|
|
tinyurl_re = re.compile(r'http://(?:www\.)?tinyurl.com/([A-Za-z0-9\-]+)',
|
|
flags=re.IGNORECASE)
|
|
|
|
|
|
@hook.event('PRIVMSG')
|
|
def tinyurl(inp):
|
|
tumatch = tinyurl_re.search(inp)
|
|
if tumatch:
|
|
try:
|
|
return urllib2.urlopen(tumatch.group()).url.strip()
|
|
except urllib2.URLError:
|
|
pass
|