Skip to content

Commit

Permalink
[isup] Use our own web stuff to see if sites are up, rather than scra…
Browse files Browse the repository at this point in the history
…ping isup.me
  • Loading branch information
embolalia committed Jan 17, 2013
1 parent 2e57a26 commit ecbf753
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions isup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ def isup(willie, trigger):
site = trigger.group(2)
if not site:
return willie.reply("What site do you want to check?")
uri = 'http://www.isup.me/' + site

if site[:6] != 'http://' and site[:7] != 'https://':
if '://' in site:
protocol = site.split('://')[0] + '://'
return willie.reply("Try it again without the %s" % protocol)
else:
site = 'http://' + site
try:
response = web.get(uri)
response = web.get(site)
except Exception as e:
willie.say(site + ' is ' + str(e))
willie.say(site + ' looks down from here.')
return
result = re.search('(?:<title>)(http://\S* Is )(Down|Up)',\
response)
if result:
willie.say(site + ' is ' + result.group(2))

if response:
willie.say(site + ' looks fine to me.')
else:
willie.say('Couldn\'t read the result from isup.me -- sorry!')
willie.say(site + ' is down from here.')
isup.commands = ['isup']

0 comments on commit ecbf753

Please sign in to comment.