Skip to content

Commit

Permalink
Rename 'Discord' if used in server label - restricted term for discor…
Browse files Browse the repository at this point in the history
…d msg titles.
  • Loading branch information
petersem committed Nov 5, 2024
1 parent 1faa0b9 commit cdd720f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const LABEL_ENABLE = process.env.LABEL_ENABLE || 'false';
const ONLY_OFFLINE_STATES = process.env.ONLY_OFFLINE_STATES || 'false';
const EXCLUDE_EXITED = process.env.EXCLUDE_EXITED || 'false';
const SHA = process.env.SHA || 'false';

// Default to 10 seconds if less than 10, blank or undefined.
if(process.env.PERIOD == "" || process.env.PERIOD === undefined || process.env.PERIOD < 10) {process.env.PERIOD = 10;}
const PERIOD = process.env.PERIOD;
Expand Down Expand Up @@ -102,6 +103,10 @@ console.log(`Settings
- Disable Startup Messages: ` + DISABLE_STARTUP_MSG.toLowerCase() + `
- Display SHA ID: ` + SHA);
console.log("---------------------------------------------------");

// send warning message if platform discord and label contains discord.
if(MESSAGE_PLATFORM.includes('discord') && SERVER_LABEL.toLowerCase().includes("discord")){ console.log("**'Discord' is restricted in msg titles: renaming")}

console.log(" ");
console.log('Monitoring started');

Expand Down Expand Up @@ -156,6 +161,9 @@ async function sendPushover(title, message) {
}

async function sendDiscord(title, message) {
// fix title if it contains the restricted word Discord.
title = title.replace("discord","Ðiscord").replace("Discord","Ðiscord");

try {
const hook = new Webhook(msgDetails[1]);
hook.setUsername(title);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monocker",
"version": "2.13.6",
"version": "2.13.7",
"description": "Monitors and alerts for docker containers state changes",
"type": "module",
"main": "index.js",
Expand Down

0 comments on commit cdd720f

Please sign in to comment.