Add url quote instead of subs dict

This commit is contained in:
Nick Krichevsky 2015-09-06 01:26:19 -04:00
parent 3d2139fd8f
commit 4d6f08d62a
1 changed files with 2 additions and 30 deletions

View File

@ -6,6 +6,7 @@
.. moduleauthor::Nick Krichevsky <nick@ollien.com>
"""
import urllib.parse
from pyircbot.modulebase import ModuleBase, ModuleHook
BASE_URL = "http://lmgtfy.com/?q="
@ -30,36 +31,7 @@ class LMGTFY(ModuleBase):
message = message.split(" ")
for word in message:
subs = {
"@": "%40",
"#": "%23",
"$": "%24",
"%": "%25",
"^": "%26",
"=": "%3D",
"+": "%2B",
"\\": "%5C",
"/": "%2F",
":": "%3A",
";": "%3B",
"'": "%27",
"\"": "%28",
",": "%2C",
"?": "%3F",
"<": "%3C",
">": "%3E",
"[": "%5B",
"]": "%5D",
"{": "%7B",
"}": "%7D",
"|": "%7C",
"`": "%60"
}
if word in subs:
word = subs[word]
finalUrl+=word
finalUrl += urllib.parse.quote(word)
if word != message[-1]:
finalUrl+="+"