diff --git a/plugins/down.py b/plugins/down.py new file mode 100644 index 0000000..7293051 --- /dev/null +++ b/plugins/down.py @@ -0,0 +1,24 @@ +import urllib2 + +from util import hook + +@hook.command +def down(inp): + '''.down -- checks to see if the site is down''' + inp = inp.strip() + + if not inp: + return down.__doc__ + + if 'http://' not in inp: + inp = 'http://' + inp + + # http://mail.python.org/pipermail/python-list/2006-December/589854.html + try: + request = urllib2.Request(inp) + request.get_method = lambda: "HEAD" + http_file = urllib2.urlopen(request, timeout=10) + head = http_file.headers + return 'it seems to be up' + except urllib2.URLError: + return 'it seems to be down' diff --git a/plugins/downforeveryoneorjustme.py b/plugins/downforeveryoneorjustme.py deleted file mode 100644 index 662df54..0000000 --- a/plugins/downforeveryoneorjustme.py +++ /dev/null @@ -1,16 +0,0 @@ -from lxml import html -from util import hook -import urllib - -@hook.command -def down(inp): - '''.down -- checks http://downforeveryoneorjustme.com to see if the site is down''' - - url = 'http://downforeveryoneorjustme.com/' + urllib.quote(inp.strip(), safe='') - page = html.parse(url) - status = page.xpath("//title")[0].text_content() - - return status - -#local testing -#print down("googlelakj.com") \ No newline at end of file