Created
June 24, 2016 07:18
-
-
Save nisegami/2854d82c0dc29c49cc4eb6b62ea7fe2d to your computer and use it in GitHub Desktop.
Site Checker For Slack Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isup(domain): | |
import re | |
import sys | |
from urllib import urlopen | |
#urllib3.disable_warnings() | |
resp = urlopen("http://www.isup.me/%s" % domain).read() | |
return True if re.search("It's just you.", resp, re.DOTALL) else False | |
def siteListBool(): | |
for siteData in getApps('sites'): | |
siteName, url = siteData.split(',') | |
siteName, url = siteName.strip(), url.strip() | |
if not isup(url): | |
return False | |
return True | |
def siteListMessage(): | |
message = "Your sites:\n" | |
for siteData in getApps('sites'): | |
siteName, url = siteData.split(',') | |
siteName, url = siteName.strip(), url.strip() | |
siteStatus = isup(url) | |
message += "`{}` is {}\n".format(siteName, ('*up*.' if siteStatus else '*down* :worried:.')) | |
return message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment