A Reddit bot which creates word clouds for submissions.
Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
fonts
.gitignore
bot.py
config-sample.json
readme.md
requirements.txt
screenshot.png

readme.md

Reddit Cloud

This is a Reddit bot which generates word clouds for comments in submissions. I'm running it on user WordCloudBot2. You can read a longer description on my blog. Skip down to the instructions to run it by yourself.

Reddit Cloud Cover

Frequent questions and suggestions

  1. How does the bot operate?
    It gets submissions from /r/all ordered by hot. It reads all the comments in a submission, eliminates the common words, generates a word cloud, posts it to Imgur and posts the link in that submission.

  2. Do the images update?
    No. It would be impractical to revisit posts.

  3. The fonts are horrible and unreadable.
    It's supposed to be more artistic than readable.

  4. This bot is bad. Does anybody like this?
    Yes. Some people think it's nice. Please don't ban the bot if you're a mod.

  5. How are the word clouds generated? Where is that code?
    That's not in the bot source. It uses my fork of Andreas Mueller's word_cloud. It basically draws all words to a black and white canvas and when a new word is added it checks if writing it there would intersect other written pixels. You can imagine that intersecting complex font paths would be way more intensive.

  6. Do you take requests?
    I haven't written that do be done automatically, I probably should.

Instructions

Installation

I am going to go on a limb and suggest that you should probably use virtualenv in order to use this script.

Install the script's dependencies:

pip install cython # Need this first.
pip install -r requirements.txt

Configuration

Copy the sample configuration file:

cp config-sample.json config.json

You need to register a new Reddit account to use for your bot and change the username and password fields in config.json.

Get an Imgur account and then register for an application. Put the client ID you get in clientId.

Fonts

Place any OTF or TTF font files in fonts/. Fonts are randomly chosen from there when a word cloud is generated. Open Sans is included by default.

Usage

You normally start the bot by running:

python2 bot.py hot

To post a word cloud of somebody's comments as a reply to a post do:

python2 bot.py user-hist <username> <full-permalink-of-the-comment>

To view the help run:

python2 bot.py -h

Notes

If you are using Mac OS X, you might have to install a Fortran compiler in order to fulfill some of the dependencies.

License

MIT