diff options
| author | 2019-01-16 22:26:31 +0000 | |
|---|---|---|
| committer | 2019-01-16 22:26:31 +0000 | |
| commit | a342f82f408edba5ea0a00ef0a0780fe03773546 (patch) | |
| tree | 30a83231d33822794702607b7685672a1d8eb620 | |
| parent | Correct order of string formatting for github membership events (github.py) (diff) | |
| signature | ||
Do filtering of github events based on categories of events (github.py)
| -rw-r--r-- | modules/github.py | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/modules/github.py b/modules/github.py index 849adaa2..7b4a48e6 100644 --- a/modules/github.py +++ b/modules/github.py @@ -10,20 +10,18 @@ CREATE_URL = "https://github.com/%s/tree/%s" 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", - "pull_request_review", - "pull_request_review_comment", - "issue_comment", - "issues", - "create", - "delete", - "release", - "fork" +DEFAULT_EVENT_CATEGORIES = [ + "ping", "code", "pr", "issue", "repo" ] +EVENT_CATEGORIES = { + "ping": ["ping"], + "code": ["push", "commit_comment"], + "pr": ["pull_request", "pull_request_review", + "pull_request_review_commend"], + "issue": ["issue", "issue_comment"], + "repo": ["create", "delete", "release", "fork"], + "team": ["membership"] +} COMMENT_ACTIONS = { "created": "commented", @@ -150,8 +148,12 @@ class Module(ModuleManager.BaseModule): server = self.bot.get_server(server_id) if server and channel_name in server.channels: channel = server.channels.get(channel_name) - github_events = channel.get_setting("github-events", - DEFAULT_EVENTS) + + event_categories = channel.get_setting( + "github-events", DEFAULT_EVENT_CATEGORIES) + github_events = list(itertools.chain( + *[EVENT_CATEGORIES[c] for c in event_categories])) + if github_event in github_events: targets.append([server, channel]) |
