Twitter robot update

Yesterday I decided to see what it would take to get my twitter robot @HackThisOrg up and running again. I found the Net::Twitter perl module when looking for simple OAuth functions. The follow portion of the robot lives again.

When I first wrote the robot, I didn't want to use modules other than the LWP module because I wanted to see if I could get the functions I was looking for in a more simple fashion without having to download and compile a ton of code. I wasn't exactly following the "Be Lazy" mantra of Perl modules.

This time I decided to go ahead and use the module and I'm glad I did. After it was installed, which took some time due to the dependencies that Moose has, getting the program to start getting and setting status and friends took less than 30 minutes. Why didn't I use this before?

It took me a bit to figure out the best method to follow and/or unfollow people who are no longer following my robot because I kept running into the rate limit. I started by downloading the list of people following me, then asking twitter if I was already following them. I would also do a request on the ID to get details about the person. Later I just used this second query and the "Following" field to determine if I was following them. This was still causing 2 request for every person following me, then I would then follow them if their tweets were not protected. I ran into the 2000 friend cap, so I started the same process for unfollowing. But I kept running into the rate limit of 350 request per hour.

After a couple of hours of waiting and trying, I realized this is a pretty dumb way to perform these action, and the easiest way to do this would be to compare the list of people I follow with that of the people who follow me. With just two requests, I could see if I am following someone who is following me. Duh!

There is still a fair amount of code, but a lot of the code is to make things pretty. I wanted to SEE what the program was doing, and I like color, so I have some functions to colorize the output of the program with ANSI color codes. I also want to be lazy and perform some tracking in my own database so I have a bunch of code for that. 

So this time around, I don't think I'm going to have the robot blindly retweet hashtags, certainly not going to have it Direct message people who follow it, I find that annoying so I won't do that to others. One of the things that I'm looking to do is possibly tweet about RSS updates, such as blog postings and news sites relating to Information Security. 

If you have other ideas you think a twitter robot would be good for, I'm open to suggestions.