I have created a new organisation on Github today as a place to add automation scripts and the first one I will add is a gateway for Discord.
This core of this script was originally created when I needed to send crash alerts from an application I had written to my phone so that could act upon them quickly. This proved useful and I added it to additional scripts and applications, but found that it was a bit limited if I wanted the alert to be logged elsewhere so I updated my apps and scripts to send to MQTT.
Once my alerts were in MQTT I could pick them up from NodeRed and perform various actions; but I missed having them arrive in Discord, so last night I created an MQTT-2-DISCORD module that includes support for multiple discord channels.
Installation is fairly simple and I have documented the process in the README.md file associated with the repository.
After installation, visit Discord and obtain a webhook for the channel you want to recieve messages into. You can name the webhook anything you like (mine is called "Home Alerts"). You then edit ~/modules/mqtt-2-discord/config.ini and add a section that contains a unique topic and your webhook:
[HomeAlerts]
topic=messages/alerts webhook=https://discord.com/api/webhooks/AAAAAAAAAAAAAAAAAA/AAAAAAAAAAAAAAAAAA
Restart the daemon and simply publish to your topic (messages/alerts in this case) to receive a message in Discord.
sudo systemctl stop mqtt2discord
sudo systemctl start mqtt2discord
Comments
Post a Comment