We wanted Reddit gold, and we wanted a way to get it efficiently. We knew that "gold chains" sometimes occur and sometimes people simply ask for gold in these gold chains and get it, so we hoped to get in on that.

What it does

It find chains of recently-gilded comments on Reddit and adds a comment to the most recent one simply begging to also be gilded.

How we built it

We used PRAW - the Python Reddit API Wrapper - to get the most recent n gilded comments from /r/all (n is a command-line argument that defaults to 200) and check whether each one was the end of a chain by checking if its d parents (d is a command-line argument that defaults to 2) are gilded and whether its children are gilded, and then replies if it is the end of a chain and if we haven't commented in that submission before.

Challenges we ran into

There was a learning curve with the API and we had to figure out how to not double-comment if we ran the bot twice. We also had some trouble initially with the is_end_of_chain() function, as well as some random hard-to-find bugs caused in part by Python's dynamic typing.

We also put this on an AWS instance to try to have it run every x minutes using cron without using our computers as servers, as well as to be eligible for the prize, but we couldn't figure out how to use cron on AWS.

Accomplishments that we're proud of

We figured out that we could use a log file to store the submission IDs of the posts we've commented on in order to avoid double-posting and/or being annoying/repetitive in a single thread. We also figured out some neat command-line arguments that alter the behavior of the program - the coolest one probably being making the is_end_of_chain() function recursive, in order to be able to check for an arbitrary-length gold chain.

What we learned

We learned a lot about the Reddit API and learned how to make a Reddit bot (this was our first, so if we choose to make another one, it should be a lot easier).

What's next for /u/gold_digger_bot

Run it and get gold!

Built With

Share this project: