aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-01-16 22:13:14 +0000
committerGravatar jesopo2019-01-16 22:13:14 +0000
commite49389232e07a1dca995cc8adf259d0a9dcae747 (patch)
tree1686f5c02af991bc6ad1128f3c2b0b4bd1802681 /modules
parentoutput of `len()` needs to have a `-1` on it when matching it against indexes (diff)
signature
Support github events only related to an organisation, not a repo (github.py)
Diffstat (limited to 'modules')
-rw-r--r--modules/github.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/modules/github.py b/modules/github.py
index 42ffb97b..cb7acc3d 100644
--- a/modules/github.py
+++ b/modules/github.py
@@ -127,7 +127,14 @@ class Module(ModuleManager.BaseModule):
github_event = event["headers"]["X-GitHub-Event"]
- full_name = data["repository"]["full_name"]
+ full_name = None
+ if "respository" in data:
+ full_name = data["repository"]["full_name"]
+
+ organisation = None
+ if "organization" in data:
+ organisation = data["organization"]["login"]
+
repo_username, repo_name = full_name.split("/", 1)
hooks = self.bot.database.channel_settings.find_by_setting(
"github-hook")
@@ -136,7 +143,9 @@ class Module(ModuleManager.BaseModule):
repo_hooked = False
for i, (server_id, channel_name, hooked_repos) in list(
enumerate(hooks))[::-1]:
- if repo_username in hooked_repos or full_name in hooked_repos:
+ if (repo_username in hooked_repos or
+ full_name in hooked_repos or
+ organisation in hooked_repos):
repo_hooked = True
server = self.bot.get_server(server_id)
if server and channel_name in server.channels:
@@ -180,7 +189,8 @@ class Module(ModuleManager.BaseModule):
if outputs:
for server, channel in targets:
for output in outputs:
- output = "(%s) %s" % (full_name, output)
+ source = full_name or organisation
+ output = "(%s) %s" % (source, output)
self.events.on("send.stdout").call(target=channel,
module_name="Github", server=server, message=output,
hide_prefix=channel.get_setting(