diff options
| author | 2018-10-05 23:29:59 +0100 | |
|---|---|---|
| committer | 2018-10-05 23:29:59 +0100 | |
| commit | d817ec98324c75af263708367d8b3c064183534e (patch) | |
| tree | a5acb18177f00332eba5c44b340b726cce663553 /modules/github.py | |
| parent | Require 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.py | 27 |
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)) |
