Although I’m still relatively new to it, I’m a big fan of Twitter. However, not for the social media aspects of it. I view Twitter as an excellent method of gathering information, as long as you follow the right kinds of people. By the right kinds of people, I mean people who tweet interesting links they find online. Simply follow people who are interested or involved in the same subjects that you’re interested in, and they will feed you information over time, in a nice steady flow.
I’m very much interested in AI, and AI as it applies to games. I am a fee paying member of Alex J. Champandard’s AIGameDev and I follow him on Twitter. While this is great, his flow of information isn’t fast enough for me. So I set to Twitter to search for people who are interested in AI and game development, when I found the @playwitter account, and the associated website. As you can see from the @playwitter tweet, they’re not yet fully functional. I didn’t really want to wait, and I didn’t really want to follow all those people on my own. So I decided to come up with an intermediary solution.
The concept is a Twitter bot that will read in an RSS feed and tweet the entries. I decided to use Ruby, as I haven’t done any significant programming in Ruby before. All I knew was the basic syntax that I read from the Pickaxe book.
First, I hit Google looking for a Ruby RSS parser library. Oh! It turns out Ruby has one built into the language. So I read a few websites on how to do that, and it seems pretty straight forward. So I grab the feed over at Playwitter and start pulling it down with my Ruby script. The quick script I wrote in 10 minutes worked like a charm.
The next part was to tweet the entries. I looked for a Twitter library and settled on the Twitter gem. I installed the gem, and this took me a while to get it working as a library, but get it working I did. I was able to send tweets from an automated script.
It took me about half an hour to wire these together and before I knew it, I was done. However, it was fairly crude, and I found out when I tried to deploy it to my server that it wouldn’t make the grade. I set about refactoring and upgrading the code and trying to get it run. 3 hours later, it was complete, and it was working.
In the end, I implemented the idea in 3 hours, with the following features:
- YAML config file for defining Twitter account details and RSS feeds to tweet from.
- Timestamp based polling of the RSS feeds, storing only updates new since the last poll.
- Tweeting with added hashtag, defined in the YAML with the feed
- Deployment as a Ruby Gem
Details of the project are the subject of another post, and when that project is a little mature, I will create that post.
From concept to deployment on a live site, with a basic knowledge of Ruby only, in 3 hours. That’s a fantastic result that I’ve never experienced in another language, compiled or not. It was fun, it was fast, and I felt the freedom of PHP with the benefit of a well implemented OO system.
Man, I love Ruby.