add isup.py
This commit is contained in:
parent
304fcdaebb
commit
5be7626fb4
1 changed files with 18 additions and 0 deletions
18
modules/isup.py
Normal file
18
modules/isup.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from src import ModuleManager, utils
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@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))
|
Loading…
Reference in a new issue