code

Launch Your Own Twitter Bot (PHP, Python, Ruby)

Tuesday, July 14th, 2009 | Hack, Mashup, Open Source, RSS, Tools, Twitter, code | 2 Comments

reddy-robot.jpg

If you use twitter you’ve undoubtably come across a twitter bot, sadly there’s a very good chance it was because it was spamming you. In this post I’ll provide you with all the tools, source code and know-how to be able to build and launch your own twitter bot, and i’ll even give you resources to do it in the programming language of your choice. Why? Because there are so many positive uses for a twitter bot….including anti-spam! Go take a look at the twitter tag project for some good examples of bots currents on twitter if you’re not able to come up with any on your own.

First, if you’d like to fool around with an automated bot on twitter but lack the technical knowhow, go pay a visit to the Botomatic site. There you can create your own bot using their easy-to-use GUI. It’ll take you two seconds and you will be up and running.

If you’re a beginner, have no fear there’s a pre-configured setup for you as well. Go download and install the Twitterbotscript from Tyler Colwell. It’s 100% free and was coded to include a helpful GUI to control the bot functionality. It’s actually a pretty cool package that uses the API. I’ve taken a lot of his code and re-used it in various test bots of my own so i’d definitely recommend anyone looking to script their own bot in PHP to download his app.

Now for the PHP programmers out there, the first example of a great PHP5 twitter bot framework is from the folks over at ohloh.net (Jason Allen and Scott Collison). This one is setup to allow you to search and retweet what you’ve found.

If you’d like to incorporate Jabber/XMPP into the bot (that way you can access it via gchat), then there’s a great tutorial over on jazzychad.com. Tenderapp.com has on their blog a PHP tutorial with full source-code for a twitter bot that will look up the traffic conditions and tweet them when messaged. This one also has a walk-through for getting it up on xmpp/jabber. Here’s the source for a similar bot that looks up the weather and retweets it on command.

If you’d like to setup a twitter bot using Python, Halotis.com has a great tutorial that uses a sqlite backend to keep track of what it’s messaged. For a more elaborate version of an automated bot using python, there’s a script over on the flowingdata.com blog that also incorporates a local mail server to send and receive messages to the bot.

Last but not least, all of you Ruby folks….here’s a Twitter Ruby Gem to go along with the Twitter4R and Twitter Ruby Gems already found in the library. The site also takes you through a few different commands available with this new gem. For complete source-code of a twitter bot written in Ruby, head on over to this snippet of a Ruby RSS Twitter Bot.

Easy as pie and now you’ve got your very own automated twitter bot!

Tags: , , ,

Other Places You Can Find Me: