commit 0481c45175d16f78cc7e4a49fb76187d46c1694e
parent ca56ef9fcf04d37e414234a9fa040a557d2cba17
Author: Demonstrandum <moi@knutsen.co>
Date: Thu, 28 May 2020 16:26:44 +0100
Use secret for some web-hooks.
Diffstat:
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -2,7 +2,6 @@
secrets.json
.env
export_secrets.sh
-console.rb
# Node / NPM / Yarn
node_modules/
diff --git a/console.rb b/console.rb
@@ -9,6 +9,7 @@ def send_message message
body = {
:console => true,
:message => message,
+ :secret => ENV['WEB_SECRET']
}
body[:guild] = $guild unless $guild == 'GLOBAL'
payload = JSON.dump body
diff --git a/lib/main.ts b/lib/main.ts
@@ -192,6 +192,7 @@ export class SimpOMatic {
.setThumbnail("https://raw.githubusercontent.com/Demonstrandum/Simp-O-Matic/master/lib/resources/banners/banner-notext.png")
.setAuthor(body.sender.login, body.sender.avatar_url);
+ // New commit.
if (body.head_commit) {
const push_embed = embed
.setTitle("Latest Commit")
@@ -199,13 +200,24 @@ export class SimpOMatic {
.setURL(body.head_commit.url);
system_message(client, push_embed);
-
+ // Star Added.
} else if (body.starred_at) {
const star_embed = embed
.setTitle("Star Added!");
system_message(client, star_embed);
+ // Pull Request.
+ } else if (body.pull_request) {
+ const pr = body.pull_request;
+ const pull_embed = embed
+ .setTitle("Pull Request")
+ .setURL(pr.url)
+ .setDescription(`“${pr.title}” (**#${pr.number}**)`
+ + ` was ${body.action}.`);
}
} else if (body.console === true) {
+ if (body.secret !== process.env["WEB_SECRET"]) {
+ return;
+ }
const send_message = (msg: string, guild?) => {
if (guild
&& GLOBAL_CONFIG.guilds.hasOwnProperty(guild)
@@ -225,6 +237,7 @@ export class SimpOMatic {
// TODO?
}
} else {
+ // For now, this won't be silent.
system_message(client, "Received unknown data:\n```json\n"
+ JSON.stringify(body, null, 4).slice(0, 1930)
+ "```");