From cbc0e81fb3cf0afd7796f2e268efbae63654748b Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 10 Jan 2019 22:14:40 +0000 Subject: Send a notice to a channel when a new webhook registration is received (github.py) --- modules/github.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/github.py b/modules/github.py index 1ed558a4..ce7896bd 100644 --- a/modules/github.py +++ b/modules/github.py @@ -11,6 +11,7 @@ API_ISSUE_URL = "https://api.github.com/repos/%s/%s/issues/%s" API_PULL_URL = "https://api.github.com/repos/%s/%s/pulls/%s" DEFAULT_EVENTS = [ + "ping", "push", "commit_comment", "pull_request", @@ -124,8 +125,6 @@ class Module(ModuleManager.BaseModule): data = json.loads(payload) github_event = event["headers"]["X-GitHub-Event"] - if github_event == "ping": - return "" full_name = data["repository"]["full_name"] repo_username, repo_name = full_name.split("/", 1) @@ -174,6 +173,8 @@ class Module(ModuleManager.BaseModule): outputs = self.status(event, full_name, data) elif github_event == "fork": outputs = self.fork(event, full_name, data) + elif github_event == "ping": + outputs = self.ping(event, full_name, data) if outputs: for server, channel in targets: @@ -194,6 +195,9 @@ class Module(ModuleManager.BaseModule): except utils.http.HTTPTimeoutException: return url + def ping(self, event, full_name, data): + return ["Received new webhook for %s" % full_name] + def _change_count(self, n, symbol, color): return utils.irc.color("%s%d" % (symbol, n), color)+utils.irc.bold("") def _added(self, n): -- cgit v1.3.1-10-gc9f91