From 26c199d1cc75303650562039811acda0a6be6654 Mon Sep 17 00:00:00 2001 From: KaneTW Date: Mon, 1 Dec 2014 23:11:07 +0100 Subject: [PATCH] Allow https, too Also a bit easier to extend down detection to more sophisticated methods. --- plugins/down.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/down.py b/plugins/down.py index 120205f..7044095 100644 --- a/plugins/down.py +++ b/plugins/down.py @@ -5,13 +5,15 @@ from util import hook, http @hook.command def down(inp): - '''.down -- checks to see if the site is down''' - - if 'http://' not in inp: - inp = 'http://' + inp - - inp = 'http://' + urlparse.urlparse(inp).netloc + '''.down -- checks to see if the website is down''' + urlp = urlparse.urlparse(inp, 'http') + + if urlp.scheme not in ('http', 'https'): + return inp + " is not a valid HTTP URL" + + inp = "%s://%s" % (urlp.scheme, urlp.netloc) + # http://mail.python.org/pipermail/python-list/2006-December/589854.html try: http.get(inp, get_method='HEAD')