From 0dcf5df6d0197635ee3a6c837c21022e630f657f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 14 Dec 2022 17:19:10 +0100 Subject: Add Webhook notifications. --- views/profile.pug | 11 +++++++++++ views/webhook.pug | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 views/webhook.pug (limited to 'views') diff --git a/views/profile.pug b/views/profile.pug index 7ed8eff..99c8f16 100644 --- a/views/profile.pug +++ b/views/profile.pug @@ -28,6 +28,17 @@ html br | Delete account + if !user.webhook + p Configure webhook + else if user.webhook.error + dl + dt Configure webhook + dd.error ERROR: #{user.webhook.error} + else + dl + dt Configure webhook + dd= new URL(user.webhook.url).hostname + p Chat log p diff --git a/views/webhook.pug b/views/webhook.pug new file mode 100644 index 0000000..bf7673f --- /dev/null +++ b/views/webhook.pug @@ -0,0 +1,46 @@ +//- vim:ts=4:sw=4: +doctype html +html(lang="en") + head + include head + title Webhook + body + include header + article + + h1 Webhook + + - var url = webhook && webhook.url || "" + - var prefix = webhook && webhook.prefix || "" + + form(action="/update-webhook" method="post") + if webhook && webhook.error + p.error ERROR: #{webhook.error} + p Webhook URL: + br + input#url(type="text" name="url" size=120 placeholder="https://discord.com/api/webhooks/..." value=url required) + p Message prefix: + br + input#prefix(type="text" name="prefix" size=40 placeholder="<@123456789>" value=prefix) + + if webhook + button(type="submit") Update + else + button(type="submit") Create + + if webhook + form(action="/delete-webhook" method="post") + button(type="submit") Delete + + h2 Discord Notifications + + p You can send notifications to a given channel on a Discord server. + + ol + li Create your own server or use an existing server where you have administrator privileges. + li Get the webhook URL for the Discord channel where you want notifications to be sent. Enter it into the Webhook URL field. + li Find your Discord User ID. Enter it into the Message prefix field as "<@UserID>" + + h2 Custom Notifications + + p You can integrate with any server that accepts inbound webhooks by setting the webhook URL to the appropriate endpoint. The webhook payload is a JSON object with a "content" property containing the notification message. -- cgit v1.2.3