Slack bot to post Advent of Code Leaderboard stats
4.7K
This repository contains the code for a script that will post a Private Advent of Code Leaderboard to a custom Slack Channel.
Useful for your friendly competitions in and around the workplace.
What It Does: Post the contents of a Private Advent of Code Leaderboard to your Slack Channel
What It Does Not: Fulfill your hopes and dreams (unless your hopes and dreams were to post the contents of a Private Advent of Code Leaderboard to your Slack Channel)
Prerequisites:
Process:
secrets.py file.SLACK_WEBHOOK variableSESSION_ID variableLEADERBOARD_ID variable.
Since this script is fairly simple, it's easy enough to run in a compact docker container, ensuring that the script is offloaded from whatever main host you have.
There is a GitHub action which will build and deploy this container automatically, but if you want to build it locally (i.e. to use a custom cron schedule)
Edit the crontab file to reflect the schedule you want. By default, it will
run at 7am daily. (Be sure to set the TZ env var to your local time, otherwise
UTC will be used)
Build the image
docker build -t slack-aoc .
docker run -it --detach --rm --name aoc-slack \
-e TZ="America/New_York" \
-e SLACK_WEBHOOK='https://hooks.slack.com/services/$HOOKINFO' \
-e LEADERBOARD_ID="$LEADERBOARD_ID" \
-e SESSION_ID="$SESSION_COOKIE" \
slack-aoc
When creating the custom webhook for the Slack channel, there are a few options to customize.
It's also possible that you don't have access to add an incoming webhook to your team because of the permissions model. In that case, you would need to know what to send to the admin to get it set up. This is that stuff.
Here are the recommended settings when setting up the Hook:
#adventofcode channel, or #generalCopy the Webhook URL or have the Admin send that URL to you, you'll need it for the script.
You'll need a session cookie from the Advent of Code website.
Go to the Advent of Code Private Leaderboard page. Make sure you're logged in.
F12SESSION_COOKIE in the script. (e.g. the line will read COOKIES = {'session': 'THIS_IS_THE_SESSION_COOKIE'})CTRL + Shift + I
Cmd + Opt + ISESSION_COOKIE in the script. (e.g. the line will read COOKIES = {'session': 'THIS_IS_THE_SESSION_COOKIE'})Content type
Image
Digest
sha256:8a660eee4…
Size
23.5 MB
Last updated
12 days ago
docker pull tomswartz07/slack-adventofcodeleaderboard