Add a !ghwebhook subcommand to list all registered web hooks (github)
This commit is contained in:
parent
88407b2055
commit
be772cb730
1 changed files with 9 additions and 4 deletions
|
@ -147,6 +147,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
"""
|
"""
|
||||||
:help: Add/remove/modify a github webhook
|
:help: Add/remove/modify a github webhook
|
||||||
:require_mode: high
|
:require_mode: high
|
||||||
|
:usage: list
|
||||||
:usage: add <hook>
|
:usage: add <hook>
|
||||||
:usage: remove <hook>
|
:usage: remove <hook>
|
||||||
:usage: events <hook> [category [category ...]]
|
:usage: events <hook> [category [category ...]]
|
||||||
|
@ -160,7 +161,11 @@ class Module(ModuleManager.BaseModule):
|
||||||
existing_hook = existing_hook_name
|
existing_hook = existing_hook_name
|
||||||
break
|
break
|
||||||
|
|
||||||
if event["args_split"][0] == "add":
|
subcommand = event["args_split"][0].lower9)
|
||||||
|
if subcommand == "list":
|
||||||
|
event["stdout"].write("Registered web hooks: %s" %
|
||||||
|
", ".join(all_hooks.keys()))
|
||||||
|
elif subcommand == "add":
|
||||||
if existing_hook:
|
if existing_hook:
|
||||||
event["stderr"].write("There's already a hook for %s" % hook)
|
event["stderr"].write("There's already a hook for %s" % hook)
|
||||||
return
|
return
|
||||||
|
@ -171,7 +176,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
}
|
}
|
||||||
event["target"].set_setting("github-hooks", all_hooks)
|
event["target"].set_setting("github-hooks", all_hooks)
|
||||||
event["stdout"].write("Added hook for %s" % hook)
|
event["stdout"].write("Added hook for %s" % hook)
|
||||||
elif event["args_split"][0] == "remove":
|
elif subcommand == "remove":
|
||||||
if not existing_hook:
|
if not existing_hook:
|
||||||
event["stderr"].write("No hook found for %s" % hook)
|
event["stderr"].write("No hook found for %s" % hook)
|
||||||
return
|
return
|
||||||
|
@ -181,7 +186,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
else:
|
else:
|
||||||
event["target"].del_setting("github-hooks")
|
event["target"].del_setting("github-hooks")
|
||||||
event["stdout"].write("Removed hook for %s" % hook)
|
event["stdout"].write("Removed hook for %s" % hook)
|
||||||
elif event["args_split"][0] == "events":
|
elif subcommand == "events":
|
||||||
if not existing_hook:
|
if not existing_hook:
|
||||||
event["stderr"].write("No hook found for %s" % hook)
|
event["stderr"].write("No hook found for %s" % hook)
|
||||||
return
|
return
|
||||||
|
@ -194,7 +199,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
all_hooks[existing_hook]["events"] = new_events
|
all_hooks[existing_hook]["events"] = new_events
|
||||||
event["target"].set_setting("github-hooks", all_hooks)
|
event["target"].set_setting("github-hooks", all_hooks)
|
||||||
event["stdout"].write("Updated events for hook %s" % hook)
|
event["stdout"].write("Updated events for hook %s" % hook)
|
||||||
elif event["args_split"][0] == "branches":
|
elif subcommand == "branches":
|
||||||
if not existing_hook:
|
if not existing_hook:
|
||||||
event["stderr"].write("No hook found for %s" % hook)
|
event["stderr"].write("No hook found for %s" % hook)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue