[framalink] Update regex, clean up code
This commit is contained in:
parent
1e36846265
commit
c6e1e9acb2
@ -21,8 +21,7 @@ def default_reducer(url, data):
|
|||||||
|
|
||||||
|
|
||||||
def ycc_reducer(url, data):
|
def ycc_reducer(url, data):
|
||||||
snd_url = url + quote(data, "/:%@&=?")
|
return "http://ycc.fr/%s" % default_reducer(url, data)
|
||||||
return "http://ycc.fr/%s" % web.getURLContent(snd_url)
|
|
||||||
|
|
||||||
def framalink_reducer(url, data):
|
def framalink_reducer(url, data):
|
||||||
json_data = json.loads(web.getURLContent(url, "lsturl=" + quote(data),
|
json_data = json.loads(web.getURLContent(url, "lsturl=" + quote(data),
|
||||||
@ -91,7 +90,7 @@ def parselisten(msg):
|
|||||||
def parseresponse(msg):
|
def parseresponse(msg):
|
||||||
global LAST_URLS
|
global LAST_URLS
|
||||||
if hasattr(msg, "text") and msg.text:
|
if hasattr(msg, "text") and msg.text:
|
||||||
urls = re.findall("([a-zA-Z0-9+.-]+:(?://)?[^ :]+)", msg.text)
|
urls = re.findall("([a-zA-Z0-9+.-]+:(?://)?(?:[^ :/]+:[0-9]+)?[^ :]+)", msg.text)
|
||||||
for url in urls:
|
for url in urls:
|
||||||
o = urlparse(web._getNormalizedURL(url), "http")
|
o = urlparse(web._getNormalizedURL(url), "http")
|
||||||
|
|
||||||
@ -112,7 +111,8 @@ def parseresponse(msg):
|
|||||||
@hook("cmd_hook", "framalink",
|
@hook("cmd_hook", "framalink",
|
||||||
help="Reduce any given URL",
|
help="Reduce any given URL",
|
||||||
help_usage={None: "Reduce the last URL said on the channel",
|
help_usage={None: "Reduce the last URL said on the channel",
|
||||||
"[@provider=framalink] URL [URL ...]": "Reduce the given URL(s) using thespecified shortner"})
|
"[@provider=framalink] URL [URL ...]": "Reduce the given "
|
||||||
|
"URL(s) using the specified shortner"})
|
||||||
def cmd_reduceurl(msg):
|
def cmd_reduceurl(msg):
|
||||||
minify = list()
|
minify = list()
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ def cmd_reduceurl(msg):
|
|||||||
raise IRCException("I have no more URL to reduce.")
|
raise IRCException("I have no more URL to reduce.")
|
||||||
|
|
||||||
if len(msg.args) > 4:
|
if len(msg.args) > 4:
|
||||||
raise IRCException("I cannot reduce as much URL at once.")
|
raise IRCException("I cannot reduce that maby URLs at once.")
|
||||||
else:
|
else:
|
||||||
minify += msg.args
|
minify += msg.args
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user