Skip to content

Commit

Permalink
Added customizable messsages (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbrembeck committed Feb 26, 2023
1 parent 932527b commit 6b6cea1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ INSTANCE="https://mastodon.social"
APP_NAME="Your app name"
HASHTAG="Yourhashtag"
SECRET="secret"
UP_MSG="is up and running again. We apologize for any inconvenience." # The hastag will be added before this
DOWN_MSG="seems to be down. We are already investigating it." # The hastag will be added before this

# Uptime Robot
UPTIME_ROBOT_API_KEY="uptimerobotsecret"
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ UPTIME_ROBOT_API_KEY="uptimerobotsecret" # Your UptimeRobot Secret for the speci
````

### Configuration
#### Message
The messages of the bot are compeltely customizable. Please note that the defined Hashtag (`HASHTAG` in `.env`) will always be added before your custom message.

````.env
UP_MSG="is up and running again. We apologize for any inconvenience." # The hastag will be added before this
DOWN_MSG="seems to be down. We are already investigating it." # The hastag will be added before this
````

#### Images
You will notice that the bot is not only sending a status to Mastodon, but also images.
Expand Down
12 changes: 6 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ app.get("*", async (req, res) => {
});
const mediaId = mediaResp.data.id;
await M.post("statuses", {
status: `#${process.env.HASHTAG} is up and running again. We apologize for any inconvenience.`,
status: `#${process.env.HASHTAG} ${process.env.UP_MSG}`,
media_ids: [mediaId],
});
} else {
await M.post("statuses", {
status: `#${process.env.HASHTAG} is up and running again. We apologize for any inconvenience.`,
status: `#${process.env.HASHTAG} ${process.env.UP_MSG}`,
});
}
res
Expand Down Expand Up @@ -87,12 +87,12 @@ app.get("*", async (req, res) => {
});
const mediaId = mediaResp.data.id;
await M.post("statuses", {
status: `#${process.env.HASHTAG} seems to be down. We are already investigating it.`,
status: `#${process.env.HASHTAG} ${process.env.DOWN_MSG}`,
media_ids: [mediaId],
});
} else {
await M.post("statuses", {
status: `#${process.env.HASHTAG} seems to be down. We are already investigating it.`,
status: `#${process.env.HASHTAG} ${process.env.DOWN_MSG}`,
});
}
res
Expand All @@ -118,12 +118,12 @@ app.get("*", async (req, res) => {
});
const mediaId = mediaResp.data.id;
await M.post("statuses", {
status: `#${process.env.HASHTAG} seems to be down. We are already investigating it.`,
status: `#${process.env.HASHTAG} ${process.env.DOWN_MSG}`,
media_ids: [mediaId],
});
} else {
await M.post("statuses", {
status: `#${process.env.HASHTAG} seems to be down. We are already investigating it.`,
status: `#${process.env.HASHTAG} ${process.env.DOWN_MSG}`,
});
}
res.status(200).json("Service is down. Posted down.");
Expand Down

0 comments on commit 6b6cea1

Please sign in to comment.