Recently learned how to create Twitter bots, which will theoretically run until the heat death of the universe (or whenever Heroku shuts down). They’re hosted on Heroku and run regularly using Heroku’s built-in scheduler and rake tasks.
This level of dyno use is completely free, which is nice, because these are mostly gimmicks and I don’t want to pay for ‘em.
I built three bots last week. Here they are in chronological order:
My first bot, combines a random quotation with a random image and attributes it to a random individual. Entirely useless but occasionally it comes up with something funny:
I wrote a handful of custom web scrapers to grab quotes from some random quote sites and dump them into big JSON files. From there I use RMagick (Ruby implementation of Imagemagick) to format and create .png files, and then the Twitter gem to send them to Twitter. Check out the repo on github for the full code.
My second bot. Tweets a random combination of a verb and adverb surrounded by asterisks.
I found a couple of raw text files containing words, cleaned them a bit (i.e. removed everything but verbs that end in “s” and adverbs that end in “ly”), and then wrote a small Ruby program to randomly combine them and upload them to Twitter every hour on the hour. Check out the repo on github for the full code.
This one is also funny on occasion:
The third and final bot in this epic trilogy.
I downloaded the archive of my tweets directly from Twitter and cleaned the data a bit: removing retweets, @usernames, and a couple of other little things. From there I fed all of my cleaned tweets into the Marky Markov gem, an implementation of Markov chains in Ruby. Basically it analyzes a large body of text and then can generate similar sentences based on what it sees.
It would work a bit better with more plentiful and standardized input (e.g. the collected works of an author). Since most of my tweets don’t use normal punctuation or grammar (ha ha) the Markov program isn’t able to pick up on patterns as easily, so it’s not quite as original as it could be. Still, it’s funny occasionally:
This one is pretty similar to the last two so I just hacked it out and didn’t throw it up on Github.