aboutsummaryrefslogtreecommitdiff
path: root/modules/github.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-11-17 22:32:44 +0000
committerGravatar jesopo2018-11-17 22:32:44 +0000
commitdc1a292a75c82b57ca241aa094e26e8cd9ee1681 (patch)
tree401cde6fbc4b2b6af1ee96e9aa67fd8bddbe5dcd /modules/github.py
parent'tag' -> 'tag_name' (github.py) (diff)
signature
Allow filtering by github event type
Diffstat (limited to 'modules/github.py')
-rw-r--r--modules/github.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/modules/github.py b/modules/github.py
index d24aa990..11a828e3 100644
--- a/modules/github.py
+++ b/modules/github.py
@@ -5,6 +5,19 @@ COMMIT_URL = "https://github.com/%s/commit/%s"
COMMIT_RANGE_URL = "https://github.com/%s/compare/%s...%s"
CREATE_URL = "https://github.com/%s/tree/%s"
+DEFAULT_EVENTS = [
+ "push",
+ "commit_comment",
+ "pull_request",
+ "pull_request_review",
+ "pull_request_review_comment",
+ "issue_comment",
+ "issues",
+ "create",
+ "delete",
+ "release"
+]
+
COMMENT_ACTIONS = {
"created": "commented",
"edited": "edited a comment",
@@ -29,11 +42,20 @@ class Module(ModuleManager.BaseModule):
full_name = data["repository"]["full_name"]
hooks = self.bot.database.channel_settings.find_by_setting(
"github-hook")
- for i, (server_id, channel_name, values) in list(
+ targets = []
+
+ for i, (server_id, channel_name, hooked_repos) in list(
enumerate(hooks))[::-1]:
- if not full_name in values:
- hooks.pop(i)
- if not hooks:
+ if full_name in hooked_repos:
+ server = self.bot.get_server(server_id)
+ if server and server.has_channel(channel_name):
+ channel = server.get_channel(channel_name)
+ github_events = channel.get_setting("github-events",
+ DEFAULT_EVENTS)
+ if github_event in github_events:
+ targets.append(server, channel)
+
+ if not targets:
return None
outputs = None