This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/down.py

21 lines
487 B
Python
Raw Normal View History

2011-11-20 10:23:31 +01:00
import urlparse
from util import hook, http
@hook.command
def down(inp):
2012-02-28 03:03:43 +01:00
".down <url> -- Checks if the site at <url> is up or down."
2011-11-20 10:23:31 +01: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')
return inp + ' seems to be up'
except http.URLError:
return inp + ' seems to be down'