aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ircbot/Sourcehut/plugin.py9
-rwxr-xr-xcontrib/ircbot/install-webhook.sh2
2 files changed, 10 insertions, 1 deletions
diff --git a/contrib/ircbot/Sourcehut/plugin.py b/contrib/ircbot/Sourcehut/plugin.py
index d66c1029..50128d79 100644
--- a/contrib/ircbot/Sourcehut/plugin.py
+++ b/contrib/ircbot/Sourcehut/plugin.py
@@ -8,6 +8,7 @@ class Sourcehut(callbacks.Plugin):
"""
Supybot plugin to receive Sourcehut webhooks
"""
+
def __init__(self, irc):
super().__init__(irc)
httpserver.hook("sourcehut", SourcehutServerCallback(self))
@@ -57,7 +58,13 @@ class SourcehutServerCallback(httpserver.SupyHTTPServerCallback):
raise ValueError("unknown list")
channel = f"#{patchset['list']['name']}"
channel = self.CHANS.get(channel, channel)
- submitter = patchset["submitter"]["canonicalName"]
+ try:
+ submitter = patchset["submitter"]["canonicalName"]
+ except KeyError:
+ try:
+ submitter = patchset["submitter"]["username"]
+ except KeyError:
+ submitter = patchset["submitter"]["email"]
msg = f"received {bold(subject)} from {italic(submitter)}: {underline(url)}"
self.plugin.announce(channel, msg)
handler.send_response(200)
diff --git a/contrib/ircbot/install-webhook.sh b/contrib/ircbot/install-webhook.sh
index 4d737f5b..3c0c5bcb 100755
--- a/contrib/ircbot/install-webhook.sh
+++ b/contrib/ircbot/install-webhook.sh
@@ -27,6 +27,8 @@ query {
submitter {
... on User {
canonicalName
+ username
+ email
}
}
}