bitbot-3.11-fork/modules/isup.py

21 lines
594 B
Python
Raw Normal View History

2019-07-15 13:59:37 +00:00
from src import ModuleManager, utils
class Module(ModuleManager.BaseModule):
2019-07-16 16:25:46 +00:00
_name = "isup"
2019-07-15 13:59:37 +00:00
@utils.hook("received.command.isup")
@utils.kwarg("min_args", 1)
@utils.kwarg("help", "Check if a given URL is up or not")
@utils.kwarg("usage", "<url>")
def isup(self, event):
url = event["args_split"][0]
response = None
try:
response = utils.http.request(url)
except:
raise utils.EventError("%s looks down to me" % url)
event["stdout"].write("%s looks up to me (HTTP %d)" %
(url, response.code))