-
Notifications
You must be signed in to change notification settings - Fork 4
/
isup.py
41 lines (33 loc) · 1.03 KB
/
isup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# coding=utf-8
"""
isup.py - Simple website status check with isup.me
Author: Edward Powell http://embolalia.net
About: http://sopel.dftba.net
This allows users to check if a website is up through isup.me.
"""
from __future__ import unicode_literals
from sopel import web
from sopel.module import commands
@commands('isup')
def isup(bot, trigger):
"""isup.me website status checker"""
site = trigger.group(2)
if not site:
return bot.reply("What site do you want to check?")
if site[:6] != 'http://' and site[:7] != 'https://':
if '://' in site:
protocol = site.split('://')[0] + '://'
return bot.reply("Try it again without the %s" % protocol)
else:
site = 'http://' + site
if not '.' in site:
site += ".com"
try:
response = web.get(site)
except Exception:
bot.say(site + ' looks down from here.')
return
if response:
bot.say(site + ' looks fine to me.')
else:
bot.say(site + ' is down from here.')