2009-05-22 00:12:35 +00:00
|
|
|
import re
|
2009-05-22 00:24:01 +00:00
|
|
|
import urllib2
|
2009-05-22 00:12:35 +00:00
|
|
|
|
2009-07-08 17:04:30 +00:00
|
|
|
from util import hook
|
2009-05-22 00:12:35 +00:00
|
|
|
|
|
|
|
|
2009-07-08 17:28:15 +00:00
|
|
|
tinyurl_re = re.compile(r'http://(?:www\.)?tinyurl.com/([A-Za-z0-9\-]+)',
|
|
|
|
flags=re.IGNORECASE)
|
2009-05-22 00:12:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
@hook.command(hook=r'(.*)', prefix=False)
|
|
|
|
def tinyurl(inp):
|
|
|
|
tumatch = tinyurl_re.search(inp)
|
2009-05-22 00:24:01 +00:00
|
|
|
if tumatch:
|
|
|
|
try:
|
|
|
|
return urllib2.urlopen(tumatch.group()).url.strip()
|
|
|
|
except urllib2.URLError:
|
|
|
|
pass
|