Send a webhook or notification when someone from an Advent of Code leaderboard solves a puzzle.
This can be very useful to track the progress of a group of friends/co-workers on Discord, Telegram, Slack, etc. It makes the challenge more engaging and competitive.
The image is available in the GitHub Package Registry and Docker Hub:
Either run the image periodically (ex: cronjob) or run it continuously with LOOP_SLEEP_SECONDS
.
It will send puzzle solution events to the configured destination.
Simple Discord/Slack/custom webhook
docker run \
-e WEBHOOK_URL="your webhook url" \
-e ADVENT_OF_CODE_SESSION_ID="your advent of code session id" \
-e ADVENT_OF_CODE_LEADERBOARD_ID="numeric leaderboard id" \
-e CACHE_FILE="/cache/cache.json" \
# Optional - run it continuously as a background service:
# -e LOOP_SLEEP_SECONDS="900" --restart=unless-stopped -d \
-v "$(pwd)/cache/:/cache/" \
ghcr.io/tofran/advent-of-code-leaderboard-notifier
Telegram
$ docker run \
-e NOTIFICATION_SENDER=telegram \
-e TELEGRAM_BOT_TOKEN="bot token" \
-e TELEGRAM_CHAT_IDS="chat_id_1,chat_id_2" \
-e ADVENT_OF_CODE_SESSION_ID="your advent of code session id" \
-e ADVENT_OF_CODE_LEADERBOARD_ID="numeric leaderboard id" \
-e CACHE_FILE="/cache/cache.json" \
# (Same optional env vars, see below)
-v "$(pwd)/cache/:/cache/" \
ghcr.io/tofran/advent-of-code-leaderboard-notifier
The unique ID of the leaderboard. It's an integer you can get from the end of leaderboard url or the prefix of the invite code.
Your advent of code session id. To retrieve it, visit adventofcode.com,
open developer tools > storage > cookies > copy the value of your session
cookie.
Defaults to 0
, meaning it only runs once and terminates the process.
Otherwise set it to how many seconds to sleep between runs.
It is recommended a value greater than 900
(15 min) - following the Advent of Code recommendation.
Customizes the notification text.
Defaults to Day {day}: {member} solved {part_emoji} after {after}
. Supported keys:
member
: the leaderboard member's namemember_id
: the leaderboard member's idday
: the day numberpart
: the part numberpart_emoji
: the part emoji (seeNOTIFICATION_PATTERN_EMOJIS
)after
: how much time has passed since puzzle publication[d] hh:mm:ss
format.mmss
: when the puzzle was solved in:mm:ss
format.
Does not respect timezones (works okay in most timezones - with an offset multiple of the hour)
Unstable: might have breaking changes in minor versions.
Defaults to the current value of NOTIFICATION_PATTERN
.
Overrides the notification text for the 2nd puzzle only.
Example: {member} solved the 🎉🍾 SECOND 🎄💥 part of day {day}!!!
Defaults to ⭐🌟
.
A string of emojis to use for the part_emoji
key in NOTIFICATION_PATTERN
.
The first emoji is used for part 1, the second for part 2.
A few examples: 🌲🎄
, 🌱🎄
, 🔵🟡
, 🥈🥇
.
Default - webhook
. Can be set to telegram
to send notifications to Telegram instead.
Sends an HTTP POST to the WEBHOOK_URL
with a JSON body like {"content": "<notifications>"}
.
Env vars:
WEBHOOK_URL
: (required) Where to send the webhook. For example, a Discord webhook URL.
Sends notification as a message from a bot to given Telegram chats.
Env vars:
TELEGRAM_BOT_TOKEN
: (required) Telegram bot token.
Ask @BotFather for it.TELEGRAM_CHAT_IDS
: (required) Comma-separated list of chat IDs to send notifications to.
See Telegram docs for more info.
Tip: forward messages to @JsonDumpBot and retrieve the chat ids.
Defaults to the latest/current Advent Of Code event. (The current year if already in december, otherwise the previous one.)
Defaults to ./cache.json
. Where to store the progress of the leaderboard.
Without it, the script is useless because it does not remember what it previously sent.
Defaults to 2000
. The maximum number of characters that can be sent.
Some providers have a character limit restriction.
When it reaches it, it notifies saying the diff is too large.
MIT