{"id":18068543,"url":"https://github.com/tomswartz07/adventofcodeleaderboard","last_synced_at":"2025-04-11T23:42:09.524Z","repository":{"id":14282298,"uuid":"75883907","full_name":"tomswartz07/AdventOfCodeLeaderboard","owner":"tomswartz07","description":"Python Script to post a Private Leaderboard to a custom Slack Channel","archived":false,"fork":false,"pushed_at":"2023-12-20T21:43:14.000Z","size":113,"stargazers_count":14,"open_issues_count":0,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-12-21T00:28:13.783Z","etag":null,"topics":["advent-of-code","aoc","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomswartz07.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"ko_fi":"tomswartz07"}},"created_at":"2016-12-07T23:21:18.000Z","updated_at":"2024-04-15T14:07:29.884Z","dependencies_parsed_at":"2023-12-21T00:21:21.267Z","dependency_job_id":"0985c910-326e-4151-879e-1486c3e59d69","html_url":"https://github.com/tomswartz07/AdventOfCodeLeaderboard","commit_stats":null,"previous_names":[],"tags_count":12,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomswartz07%2FAdventOfCodeLeaderboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomswartz07%2FAdventOfCodeLeaderboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomswartz07%2FAdventOfCodeLeaderboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomswartz07%2FAdventOfCodeLeaderboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomswartz07","download_url":"https://codeload.github.com/tomswartz07/AdventOfCodeLeaderboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497902,"owners_count":21113982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advent-of-code","aoc","python"],"created_at":"2024-10-31T08:07:02.393Z","updated_at":"2025-04-11T23:42:09.496Z","avatar_url":"https://github.com/tomswartz07.png","language":"Python","funding_links":["https://ko-fi.com/tomswartz07"],"categories":[],"sub_categories":[],"readme":"[![Pylint](https://github.com/tomswartz07/AdventOfCodeLeaderboard/actions/workflows/pylint.yml/badge.svg)](https://github.com/tomswartz07/AdventOfCodeLeaderboard/actions/workflows/pylint.yml)\n\n# Advent of Code Leaderboard Slack Bot\n\nThis repository contains the code for a script that will post a Private Advent of Code Leaderboard to a custom Slack Channel.\n\nUseful for your friendly competitions in and around the workplace.\n\n**What It Does:** Post the contents of a Private Advent of Code Leaderboard to your Slack Channel\n\n**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)\n\n## Setup\n**Prerequisites**:\n- Python 3\n- Working Internet Connection\n- Admin Access to a Slack Team or the ability to bribe someone who does (I hear Christmas Cookies are nice this time of year‥)\n\n**Process**:\n\n1. Create a new [Incoming Slack Webhook](https://my.slack.com/services/new/incoming-webhook/)\n    - Read more about incoming webhooks [here](https://api.slack.com/incoming-webhooks)\n    - Feel free to customize it as you wish.\n    - If you don't have access to add an incoming webhook, see the [Recommended Settings](#recommended-settings) section for more details.\n2. Log in to Advent of Code and obtain two things: the Private Leaderboard ID Number and a Session Cookie.\nSee [Session Cookie](#getting-a-session-cookie) section for details.\n3. Dump that info into a `secrets.py` file.\n  - Webhook URL goes in the `SLACK_WEBHOOK` variable\n  - Session goes in the `SESSION_ID` variable\n  - Leaderboard ID goes in the `LEADERBOARD_ID` variable.\n    - The ID is the last part of the leaderboard url (https://adventofcode.com/2018/leaderboard/private/view/LEADERBOARD_ID)\n4. Run that shit. Schedule a cron job or something. I don't know. You're doing Advent of Code, figure it out. [Just make sure that you don't hit the servers too often.](https://www.reddit.com/r/adventofcode/comments/7gy2y3/remember_please_limit_automated_http_requests/)\n\n## Docker Container\nSince this script is fairly simple, it's easy enough to run in a compact docker\ncontainer, ensuring that the script is offloaded from whatever main host you have.\n\n### Building Docker Image\nThere is a GitHub action which will build and deploy this container automatically,\nbut if you want to build it locally (i.e. to use a custom cron schedule)\n\n1. Edit the `crontab` file to reflect the schedule you want. By default, it will\nrun at 7am daily during the month of the event. (Be sure to set the `TZ` env var\nto your local time, otherwise UTC will be used)\n\n2. Build the image\n```\ndocker build -t slack-aoc .\n```\n\n3. Run the image\nRefer to [Setup](#setup) to get the relevant parameters for your environment\n```\ndocker run -it --detach --rm --name aoc-slack \\\n-e TZ=\"America/New_York\" \\\n-e SLACK_WEBHOOK='https://hooks.slack.com/services/$HOOKINFO' \\\n-e LEADERBOARD_ID=\"$LEADERBOARD_ID\" \\\n-e SESSION_ID=\"$SESSION_COOKIE\" \\\nslack-aoc\n```\n\n## Recommended Settings\nWhen creating the custom webhook for the Slack channel, there are a few options to customize.\n\nIt'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.\n\nHere are the recommended settings when setting up the Hook:\n- **Post to Channel:** Your `#adventofcode` channel, or `#general`\n- **Descriptive Label:** Whatever you want. This isn't really necessary.\n- **Customize Name:** \"Advent of Code Leaderboard\"\n- **Customize Icon:** Pick an emoji → Christmas Tree\n\nCopy the Webhook URL or have the Admin send that URL to you, you'll need it for the script.\n\n## Getting a Session Cookie\nYou'll need a session cookie from the Advent of Code website.\n\nGo to the [Advent of Code Private Leaderboard](https://adventofcode.com/2018/leaderboard/private) page. Make sure you're logged in.\n\n### In Firefox:\n- Open the Developer Tools by pressing `F12`\n- Click on the small gear on the top right of the Developer Options pane\n- Scroll down and make sure that \"Storage\" is checked under the Default Firefox Developer Options section\n- Click on the Storage tab\n- Open the Cookies section and copy the \"Value\" for \"session\"\n- That value is what you put in place of `SESSION_COOKIE` in the script. (e.g. the line will read `COOKIES = {'session': 'THIS_IS_THE_SESSION_COOKIE'}`)\n\n### In Chrome:\n- Open the Developer Tools by pressing `CTRL` + `Shift` + `I`\n    - Mac: Open the Developer Tools by pressing `Cmd` + `Opt` + `I`\n- Select \"Application\" from the tool tabs\n- Click the dropdown arrow beside cookies in treeview on the left\n- Select *https://adventofcode.com*\n- Double click the value of the *session* cookie to highlight it\n- Right click and copy the value\n- That value is what you put in place of `SESSION_COOKIE` in the script. (e.g. the line will read `COOKIES = {'session': 'THIS_IS_THE_SESSION_COOKIE'}`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomswartz07%2Fadventofcodeleaderboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomswartz07%2Fadventofcodeleaderboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomswartz07%2Fadventofcodeleaderboard/lists"}