A Slack bot for Advent of Code. Adapted from Tom Swartz's AdventOfCodeLeaderboard, this bot will post to Slack when members of a private leaderboard have earned new stars. It will also post the leaderboard if wanted, sorting by score, breaking ties by stars.
Regardless of how you run you'll need to gather a few items first.
-
Leaderboard ID: This can be found in the url when viewing your leaderboard.
https://adventofcode.com/YYYY/leaderboard/private/view/[LEADERBOARD ID]
-
Session Cookie: While logged in to Advent of Code:
In Firefox:
- Open the Developer Tools by pressing
F12
- Click on the small gear on the top right of the Developer Options pane
- Scroll down and make sure that "Storage" is checked under the Default Firefox Developer Options section
- Click on the Storage tab
- Open the Cookies section and copy the "Value" for "session"
In Chrome:
- Open the Developer Tools by pressing
CTRL
+Shift
+I
orCmd
+Opt
+I
on Mac - Select "Application" from the tool tabs
- Click the dropdown arrow beside cookies to expand it
- Select https://adventofcode.com
- Copy the "Value" for "session"
These session cookies last for about a month, so grab it close to December 1st.
- Open the Developer Tools by pressing
-
Slack Webhook: Follow the instructions HERE to create a new webhook for a channel of your choice.
Once you have gathered these items update the env
file accordingly.
pip3 install -r requirements.txt
export $(grep -v '^#' env | xargs)
./advent-of-code-bot.py # just grab the data
./advent-of-code-bot.py stars # post any newly earned stars to Slack
./advent-of-code-bot.py leaderboard # post the leaderboard to Slack
./advent-of-code-bot.py leaderboard stars # post new stars and the leaderboard to Slack
-
Update the crontab to your desired schedule. Defaults to checking for new stars every 30 minutes and posts the leaderboard at 7am. The crontab will also constrain runs to December 1st through 25th, update if needed.
-
Build the container.
docker build -t advent-of-code-bot:$(cat VERSION.md) .
-
Run the container.
docker run --name advent-of-code-bot --env-file env -d advent-of-code-bot:$(cat VERSION.md)
-
Stop the container.
docker stop advent-of-code-bot