Advent Of Code Discord Bot
Discord bot for displaying Advent of Code private leardboards, as well as custom leaderboards where participants can set their own start times. The latter function is ideal for participants in different time zones looking for a way to compete with each other.
The Leaderboard in Discord
||Print out the private leaderboard. This uses the original advent of code scoring scheme.|
||Prints out the custom leaderboard. This uses our custom advent of code scoring scheme.|
||Associate yourself with given AoC user. Can be called without an argument, if so will print out the list of registered users. If no argument, will register your discord ID with your Advent of Code username for custom scoring.|
||Start a day. This will set your starttime for our custom scoring.|
||Can be called without an argument, if so will print the next scheduled send time. With an argument, will schedule a time for the leaderboard to send automatically. Takes in a indicator (either + or -) and an integer (minutes) and sends the leaderboard at the start time of the competition for that day (midnight EST), given that offset.|
||Send individual stats for a user. Can be called with and without an argument, without an argument it will use the account that is registered with your user.|
Running the bot
- Clone this repo to your machine with
git clone https://github.com/TheFutureGadgetsLab/AdventOfCodeBot.git.
python3 -m pip install requirements
In order to configure the bot you’ll need to open the config located at /src/config.py and set the
YEAR should be whichever year you’re trying to get on the scoreboard, the
SESSION_COOKIE should be the session cookie you get when logging into Advent of Code, and the
LEADERBOARD should be the ID of the leaderboard you’re trying to access. You will need to set up a Discord bot and add it to the server you plan to use this bot in, and then retrieve the bot token and set the
DISCORD_TOKEN to be that.
This bot provides two unique methods of scoring the leaderboard, specifically based on start time of a problem. Both scoring methods work by counting the number of players on the leaderboard (n), then for each star giving the first player to finish n stars, the second player n – 1 stars, and so on, until the last player recieves 1 star.
The original scoring (
!plb) uses the exact same scoring conditions as the original advent of code leaderboard, where start time for a problem is set by the time the problem opens (Midnight EST) for each day.
The custom scoring (
!clb) uses custom set start times by players. These are set using the
!start <day> command after a user has registered with
!register <username>. If a user has not set a start time for a problem, the scoring algorithm will use the time that problem originally opened at Midnight EST of that day.
- What are these weird files called
These are the shelve files that store state so it persists between bot shutdowns. hackikuji.mayoi stores the registered users and their start times, and senjougahara.hitagi stores the scheduled time for the server to run.