Skip to content

Commit

Permalink
Cleaned up Discord notification
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicnessTwo committed Oct 6, 2023
1 parent 7da97f8 commit 20e590c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
13 changes: 8 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: '3'
services:
dualping:
build:
context: .
dockerfile: Dockerfile
image: ghcr.io/epicnesstwo/dualping:latest
# tty: true
# stdin_open: true
Expand All @@ -11,10 +14,10 @@ services:
environment:
- TTY_MODE=false
- LOCAL_ROUTER=10.0.0.1
- INTERNET_IP=1.1.1.1
- DISCORD_WEBHOOK_URL=https://discordapp.com/api/webhooks/xxx/yyy
- CALENDAR_ID=yourgooglecalendarlink@group.calendar.google.com
- LOCATION=New Location Test
- INTERNET_IP=8.8.8.8
- DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/1123333777033265332/zsHl_HeMlM9Uqw8asbkZr27YuqrwupwO3aaOudKUkuWhjQ3znoU7K1n-Ce9c-U2BT8oS
- CALENDAR_ID=53e479f321a380d2b6cb6e3de9395e39428ec0d284aa8ac44c0c7de41289c03c@group.calendar.google.com
- LOCATION=Development Build
- PING_COUNT=3
- DEBUG_MODE=false
- DEBUG_MODE=true
restart: unless-stopped
33 changes: 32 additions & 1 deletion run.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,38 @@ function logOutage() {
function sendDiscordNotification(start, end) {
const durationMinutes = (end - start) / (1000 * 60);
return axios.post(DISCORD_WEBHOOK_URL, {
content: `🚫 ${LOCATION} Internet Outage 🚫\nStarted: ${start.toISOString()}\nEnded: ${end.toISOString()}\nDuration: ${durationMinutes.toFixed(2)} minutes`
"content": null,
"embeds": [
{
"title": `${LOCATION} Internet Outage`,
"color": 16726072,
"fields": [
{
"name": "Outage Start",
"value": `${start.toISOString()}`,
"inline": true
},
{
"name": "Outage Ended",
"value": `${end.toISOString()}`,
"inline": true
},
{
"name": "Duration",
"value": `${durationMinutes.toFixed(2)} minutes`
}
],
"author": {
"name": "DualPing Alert",
"url": "https://github.com/EpicnessTwo/DualPing"
},
"footer": {
"text": "Powered by DualPing | https://github.com/EpicnessTwo/DualPing"
}
}
],
"username": "DualPing Alerts",
"attachments": []
});
}

Expand Down

0 comments on commit 20e590c

Please sign in to comment.