Skip to content

Python Script to post a Private Leaderboard to a custom Slack Channel

Notifications You must be signed in to change notification settings

harmstyler/AdventOfCodeLeaderboard

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 

Repository files navigation

Advent of Code Leaderboard Slack Bot

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)

Setup

Prerequisites:

  • Python 3
  • Working Internet Connection
  • Admin Access to a Slack Team or the ability to bribe someone who does (I hear Christmas Cookies are nice this time of year‥)

Process:

  1. Create a new Incoming Slack Webhook
    • Read more about incoming webhooks here
    • Feel free to customize it as you wish.
    • If you don't have access to add an incoming webhook, see the Recommended Settings section for more details.
  2. Log in to Advent of Code and obtain two things: the Private Leaderboard ID Number and a Session Cookie. See Session Cookie section for details.
  3. Dump that info into the copy of the script.
  1. 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.

Recommended Settings

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:

  • Post to Channel: Your #adventofcode channel, or #general
  • Descriptive Label: Whatever you want. This isn't really necessary.
  • Customize Name: "Advent of Code Leaderboard"
  • Customize Icon: Pick an emoji → Christmas Tree

Copy the Webhook URL or have the Admin send that URL to you, you'll need it for the script.

Getting a Session Cookie

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.

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"
  • 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'})

In Chrome:

  • Open the Developer Tools by pressing CTRL + Shift + I
    • Mac: Open the Developer Tools by pressing Cmd + Opt + I
  • Select "Application" from the tool tabs
  • Click the dropdown arrow beside cookies in treeview on the left
  • Select https://adventofcode.com
  • Double click the value of the session cookie to highlight it
  • Right click and copy the value
  • 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'})

About

Python Script to post a Private Leaderboard to a custom Slack Channel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%