Skip to content

Commit

Permalink
✨ Add Telegram notifications (fixed upptime/upptime#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 28, 2020
1 parent a3620fc commit 75f7a59
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/helpers/notifme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,22 @@ export const sendNotification = async (message: string) => {
}
console.log("Finished sending Discord");
}
if (process.env.NOTIFICATION_TELEGRAM && process.env.NOTIFICATION_TELEGRAM_BOT_KEY) {
console.log("Sending Telegram");
try {
await axios.post(
`https://api.telegram.org/bot${process.env.NOTIFICATION_TELEGRAM_BOT_KEY}/sendMessage`,
{
parse_mode: "Markdown",
disable_web_page_preview: true,
chat_id: process.env.NOTIFICATION_TELEGRAM_CHAT_ID,
text: message,
}
);
console.log("Success Telegram");
} catch (error) {
console.log("Got an error", error);
}
console.log("Finished sending Telegram");
}
};

0 comments on commit 75f7a59

Please sign in to comment.