aboutsummaryrefslogtreecommitdiff
path: root/modules/github.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-10-05 23:29:59 +0100
committerGravatar jesopo2018-10-05 23:29:59 +0100
commitd817ec98324c75af263708367d8b3c064183534e (patch)
treea5acb18177f00332eba5c44b340b726cce663553 /modules/github.py
parentRequire modules/rest_api.py has tls cert/key (diff)
signature
Add the basics of a github webhook in modules/github.py
Diffstat (limited to 'modules/github.py')
-rw-r--r--modules/github.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/github.py b/modules/github.py
new file mode 100644
index 00000000..e0305d69
--- /dev/null
+++ b/modules/github.py
@@ -0,0 +1,27 @@
+import json
+from src import ModuleManager, utils
+
+class Module(ModuleManager.BaseModule):
+ @utils.hook("api.post.github")
+ def github(self, event):
+ data = event["data"]
+ try:
+ data = json.loads(data)
+ except:
+ return
+
+ if "commits" in data:
+ full_name = data["repository"]["full_name"]
+
+ for commit in data["commits"]:
+ id = command["id"]
+ message = commit["message"]
+ author = "%s <%s>" % (commit["author"]["username"],
+ commit["author"]["email])
+ modified_count = len(commit["modified"])
+ added_count = len(commit["added"])
+ removed_count = len(commit["removed"])
+
+ print("(%s) [%d/%d/%d mod/add/del] commit by %s: %s" % (
+ full_name, modified_count, added_count, removed_count,
+ author, message))