Merge branch 'develop' of git://github.com/lukeroge/CloudBot into develop
This commit is contained in:
commit
66e2aa4820
|
@ -8,24 +8,6 @@ ignored_urls = ["http://google.com", "http://youtube.com",
|
|||
"http://pastebin.com", "http://mibpaste.com",
|
||||
"http://fpaste.com", "http://git.io"]
|
||||
|
||||
wordDic = {
|
||||
'"': '"',
|
||||
''': '\'',
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'«': '«',
|
||||
'"': '"',
|
||||
''': '\'',
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'«': '«',
|
||||
'!': '!',
|
||||
'$': '$',
|
||||
' ': ' '}
|
||||
|
||||
|
||||
def parse(match):
|
||||
url = urlnorm.normalize(match.encode('utf-8'))
|
||||
if url not in ignored_urls:
|
||||
|
@ -36,15 +18,6 @@ def parse(match):
|
|||
except:
|
||||
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]+)+')
|
||||
def urlparser(match, say=None):
|
||||
url = urlnorm.normalize(match.group().encode('utf-8'))
|
||||
|
@ -57,7 +30,7 @@ def urlparser(match, say=None):
|
|||
title = parse(url)
|
||||
if title == "fail":
|
||||
return
|
||||
title = multiwordReplace(title, wordDic)
|
||||
title = http.unescape(title)
|
||||
realurl = http.get_url(url)
|
||||
if realurl == url:
|
||||
say("(Link) %s" % title)
|
||||
|
|
Reference in a new issue