This repository has been archived on 2023-04-13. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
CloudBot/disabled_stuff/down.py

21 lines
506 B
Python
Raw Normal View History

2011-11-20 22:23:31 +13:00
import urlparse
from util import hook, http
@hook.command
def down(inp):
2013-09-04 18:30:04 +08:00
"""down <url> -- Checks if the site at <url> is up or down."""
2011-11-20 22:23:31 +13:00
if 'http://' not in inp:
inp = 'http://' + inp
inp = 'http://' + urlparse.urlparse(inp).netloc
# http://mail.python.org/pipermail/python-list/2006-December/589854.html
try:
http.get(inp, get_method='HEAD')
2013-09-05 09:46:49 +08:00
return '{} seems to be up'.format(inp)
2011-11-20 22:23:31 +13:00
except http.URLError:
2013-09-05 09:46:49 +08:00
return '{} seems to be down'.format(inp)