.gitignore | ||
latest_post.txt | ||
LICENSE | ||
README.md | ||
requirements.txt | ||
trigger.sh | ||
webhook.py |
Discord cardiCast webhook
This is a simple webhook to push new cardiCast episodes into the cardiCast Discord channel.
install
- Create and activate virtual env
- Install requirements:
pip install -r requirements.txt
- Set up a cronjob (see below)
- Test cronjob works
- Relax
How it works
We run this on the newcardigan wordpress server.
- With a cron job we call
trigger.sh
- The shell script sets env values then calls
webhook.py
- The python script checks a custom RSS feed for new podcast episodes
- If no new episode, end
- If new episode,
- save the guid to
latest_post.txt
for the next round of checking - use the values from the RSS feed
- publish via a webhook to Discord
- save the guid to
env values
These are all set in trigger.sh
, not in crontab, to keep things contained.
We need to include some secrets via environment values:
- the guild/server ID (
DISCORD_GUILD
) - the secret token for the webhook (
DISCORD_TOKEN
) - the ID of the
@cardiCast ping
role (DISCORD_CARDICAST_PING
)
And because we run python in a virtual environment:
venv - we need to activate the venv using source <path/to/venv>
Cron job command
*/18 * * * * cd /home/cardigan/rss-discord-bot && ./trigger.sh
RSS feed
The rss feed is https://newcardigan.org/category/cardiparties/?feed=featured_image_feed
.
This special featured_image_feed
is a slightly modified RSS2 feed. The only thing it does differently is include the featured image in an enclosure
so that we can pick it up directly from the feed. See the newcardigan WordPress theme for how this works.