YCC module: fix too many « Bad URL »

This commit is contained in:
Némunaire 2012-06-28 19:39:00 +02:00
parent 907a655732
commit 2fdd629ccf

View File

@ -23,7 +23,7 @@ class Tinyfier(threading.Thread):
def run(self):
(status, page) = getPage("ycc.fr", "/redirection/create/" + self.url)
if status == http.client.OK:
if status == http.client.OK and len(page) < 100:
srv = re.match(".*((ht|f)tps?://|www.)([^/ ]+).*", self.url)
if srv is None:
self.msg.send_chn("Mauvaise URL : %s" % (self.url))
@ -31,6 +31,7 @@ class Tinyfier(threading.Thread):
self.msg.send_chn("URL pour %s : %s" % (srv.group(3), page.decode()))
else:
print ("ERROR: ycc.fr seem down?")
self.msg.send_chn("La situation est embarassante, il semblerait que YCC soit down :(")
def parseanswer(msg):
global LAST_URLS
@ -48,7 +49,7 @@ def parseanswer(msg):
t = Tinyfier(url, msg)
t.start()
else:
msg.send_chn("%s: je ne peux pas reduire autant d'URL d'un seul coup." % msg.sender)
msg.send_chn("%s: je ne peux pas réduire autant d'URL d'un seul coup." % msg.sender)
return True
else:
return False