Skip to content
Snippets Groups Projects
Commit b72a1e19 authored by Svetlana Tkachenko's avatar Svetlana Tkachenko
Browse files

fixes issue #17, units in s, minor cleanup (thanks msemper)

parent 6b205139
No related branches found
No related tags found
No related merge requests found
......@@ -44,14 +44,15 @@ class IsItUp(object):
url = args[0][8:]
else:
url = args[0]
if url.endswith("/"): #check if URL has a trailing slash
url = url[:-1] #and remove it if needed
url = "http://isitup.org/" +url + ".json"
req = Request(url,headers={'User-Agent': 'guppy/'+self.server.config["version"]})
code = "".join(urlopen(req).read().decode('utf8'))
# print(code)
arr = json.loads(code)
arr['up'] = 'up' if arr['status_code'] == 1 else 'not up'
if arr['up'] == 'up':
self.server.doMessage(channel, user + ': %(domain)s:%(port)s is %(up)s. Got HTTP status code %(response_'
'code)03d from %(response_ip)s in %(response_time)f ms.' % arr)
'code)03d from %(response_ip)s in %(response_time)f s.' % arr)
else:
self.server.doMessage(channel, user + ': %s is not up.' % arr['domain'])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment