Merge branch 'develop' of git://github.com/lukeroge/CloudBot into develop

This commit is contained in:
neersighted 2012-02-29 00:44:43 -08:00
commit 66e2aa4820

View file

@ -8,24 +8,6 @@ ignored_urls = ["http://google.com", "http://youtube.com",
"http://pastebin.com", "http://mibpaste.com", "http://pastebin.com", "http://mibpaste.com",
"http://fpaste.com", "http://git.io"] "http://fpaste.com", "http://git.io"]
wordDic = {
'"': '"',
''': '\'',
'&': '&',
'&#60;': '<',
'&#62;': '>',
'&#171;': '«',
'&quot;': '"',
'&apos;': '\'',
'&amp;': '&',
'&lt;': '<',
'&gt;': '>',
'&laquo;': '«',
'&#33;': '!',
'&#036;': '$',
' ': ' '}
def parse(match): def parse(match):
url = urlnorm.normalize(match.encode('utf-8')) url = urlnorm.normalize(match.encode('utf-8'))
if url not in ignored_urls: if url not in ignored_urls:
@ -36,15 +18,6 @@ def parse(match):
except: except:
return "fail" return "fail"
def multiwordReplace(text, wordDic):
rc = re.compile('|'.join(map(re.escape, wordDic)))
def translate(match):
return wordDic[match.group(0)]
return rc.sub(translate, text)
@hook.regex(r'([a-zA-Z]://|www\.)?[^ ]+(\.[a-z]+)+') @hook.regex(r'([a-zA-Z]://|www\.)?[^ ]+(\.[a-z]+)+')
def urlparser(match, say=None): def urlparser(match, say=None):
url = urlnorm.normalize(match.group().encode('utf-8')) url = urlnorm.normalize(match.group().encode('utf-8'))
@ -57,7 +30,7 @@ def urlparser(match, say=None):
title = parse(url) title = parse(url)
if title == "fail": if title == "fail":
return return
title = multiwordReplace(title, wordDic) title = http.unescape(title)
realurl = http.get_url(url) realurl = http.get_url(url)
if realurl == url: if realurl == url:
say("(Link) %s" % title) say("(Link) %s" % title)