DEV Community

Cover image for Advent of Code Megathread Comment Tracker!
Ryan Palo
Ryan Palo

Posted on

Advent of Code Megathread Comment Tracker!

I'm having a lot of fun this year with Advent of Code, and it's awesome getting to see all of the community solutions on the Megathread. One thing I decided to do this year that I hadn't done before but the guy who did it last year decided to do is track how many submissions of each different programming language were submitted for the previous day on each post.

I think it's a really neat idea and it's always exciting when somebody posts a language we haven't seen before like Scratch or Racket or something.


I did not account for the fact that people batch their AoC work, and they'll often submit several days behind the curve. Which is totally fine and I should have foreseen it, but it means that every day I get to go into the comments and re-count them all manually, even though I've already counted 99% of them before.

You know what that sounds like a good job for?

A computer. Assisted by me.

So I wrote a tool I cleverly and pithily call the "Advent of Code Language Bot." It goes through each article in the series, grabs the comments, ignores the ones it has seen before (it's got a history file!), automatically detects languages from code blocks in the markdown if they are present, and if the user submitted a solution via a gist or image or something, it shows me the HTML and asks me to tell it what language they said they used. It then remembers my answer forever more!

If you comment and say you solved it in 3 languages, it even accepts my answer when I tell it you used 3 languages.

It's not a big tool, bit it's exceptionally effective, I was able to give it a little polish, I'm happy with the interface, the configuration strategy, the workflow, and it's already saved me a bunch of time this morning.

If you're doing AoC via the Megathread this year, you can help me out by using language-specific code blocks (triple back-tics followed by the language you used), or, at the very least, writing in your comment what language you used so I don't have to chase through your Gist or specifically open up your image/blog post to see what you used. But even if I do, I'll only have to do it once now 😊

You can see the repo here:

GitHub logo rpalo / aoc_language_bot

A bot for helping me classify and tabulate submissions to the DEV Advent of Code Solution Megathread.

Advent of Code DEV Megathread Language Bot

In 2019, on the DEV megathread for the Advent of Code challenge, the thread author kept a tally of how many people had completed the previous day's challenge in each language.

I'm doing the same thing now, but updating them is quickly becoming more time consuming than planned. It's time for a bot!

The Idea

For each article in my DEV AoC megathread, this bot should go get the comments, and, ideally, output the markdown table that I can copy paste into the article.

There are some comments that don't have code blocks classified by language And some people comment just that they solved in particular language maybe with an image of their code. In order to not duplicate work, the bot should run each comment through a checker that checks for any possible language words that might signify that there's more to…

P.S. shout out to @rhymes and the team. The API docs are great and I didn't have any trouble at all getting the data I needed. I tried to cache judiciously and sprinkle time.sleep(1) throughout my API calls to be nice to your servers. Let me know if I'm causing any problems!

Top comments (2)

ballpointcarrot profile image
Christopher Kruse

Better living through chemistry automation. :D

This is awesome, Ryan, and glad it frees you up to do other things than maintaining the threads here.

rpalo profile image
Ryan Palo

Like write more automation!