by Gina Trapani

Recently I released a command line script which manages your todo list in a plain text file. One of the best reasons for keeping a todo.txt are the unlimited ways you can interact with it: anything and everything can read and parse text files. So as a programming exercise I set out to write an AOL instant messenger bot that updates and views your todo.txt from anywhere, and after only a few hours, my TodoBot was up and running.


Why would you want to IM your todo list, you ask? Say you're at the store and you forgot what you were supposed to buy. IM your bot list @shopping from your phone to find out. Say you keep your todo list on your home computer and you want to access it from the office. With the TodoBot you don't have to go through the trouble of running a home server - simply IM todo commands to your bot.


Let's take a look at the todo.txt bot in action, and get it set up on your computer.

Note: To get your TodoBot going, you need to be already running the Todo manager script. If you don't know what I'm talking about, start here for a little intro to the thinking behind todo.txt. Then install the latest version. If you're on Windows, you'll need to use Cygwin. Get yourself some detailed instructions on doing that here.

Once you've got your todo.txt going, you're ready to set up your bot.

The TodoBot in action

Here's a short screencast of my TodoBot in action:


Notice that you omit the "todo" part of the todo commands and get straight to the actions. So instead of todo add 'do laundry' you just tell the bot add 'do laundry'. All the bot does is issue todo commands, so the todo bit is assumed.

Neat, huh? You too can know the wonderful marriage of IM and .txt.

Set up your TodoBot

Warning: Setting up the todobot.pl requires comfort with editing and running a Perl script. It's not too scary; but it's not an installation wizard, either.


Here's how to get your TodoBot set up.

First register for an AIM screenname which you'll use as your bot at AIM.com. Mine's called gtraptodobot, yours can be anything you like. Get Perl running on the computer where your todo.txt lives. If you're running Cygwin, install the Perl package using setup.exe, as described here. Mac and Linux users, you're all set with the Perl. Download the TodoBot Perl files, which come in two varieties. The bot requires the OSCAR package to run, so for the lazier (and less experienced), download this zip file with OSCAR included.

If you're all down with the C and the PAN and Perl module installation, download todobot.pl and then grab and install OSCAR.pm separately. If necessary, unzip the Todobot bundle. Then, open up the file called todobot.pl and edit the following lines:

my $screenname = 'yourbotname'; my $password = 'yourbotpassword'; my $commander = 'yourAIMname'; my $todoscript = 'c:/path/to/your/todo/script/todo';

In the first two lines, enter the bot nickname and password you signed up for in step 1. In the third line, enter the AIM name you'll use to run todo commands. In the last line, enter the full path to your todo manager script. Save and close todobot.pl. To start the TodoBot, at the command line type perl todobot.pl. All goes well, your bot will log into AIM without a hitch.


Now's the fun part. Login to AIM with your regular nick and add your bot to your buddy list. Then, message todo script commands from your IM window as if you were at a command line. Try it: IM your bot add get to know my todobot.

And that's that! You're IM'ing your way to todo.txt nirvana; with no server running, no hosted service, no keeping your data on someone else's server. Rock on.


Security

Now, I'm sure I've got a posse of system administrators ready to bust a blood vessel at the idea of an AIM bot running a shell script. Yes, this is highly insecure. Yes, you can stick a semi-colon in your IM and run any command you want. But.


The trick to the todobot.pl is that it checks from whom the command is issued. That is, if YOU message MY bot? You'll get a message that says, "You're not the boss of me." Cuz you're not.

So no one else except your IM name - set in the script - can modify or view your todo.txt with your bot. Doing this means you trust that no one can spoof your AOL username, and of course, all your IM's pass as plain text over the network. It's up to you to decide whether or not you want to take these risks.


Caveats

This is literally the first Perl script I've ever written, and I did it in about 2 hours today. In fact, I didn't even write it; I adapted it from this very helpful O'Reilly article, Build Your Own AIM Answerbot. Without a doubt there are some bugs to be worked out; so back up your todo.txt before trying it out. I'm sure you Perl programmers especially will have lots to say about it. I invite your criticism, modifications and outright scorn. Bring it on in the comments or to tips at lifehacker.com.


A weblog isn't the right format to present software, so I've gathered together all the todo.txt scriptyness published here on Lifehacker on a new domain, todotxt.com. Do stop by there to grab latest versions and join the mailing list to discuss bugs, future developments and any other todo.txt-related fun.


Happy AIM'ing your todo.txt!

UPDATE: I (stupidly) forgot to thank Joel Johnson for the TodoBot idea and mwilkie for a long late night discussion on Perl module installation and security implications. Thanks, guys! You're the wind beneath the TodoBot's wings.


Gina Trapani, the editor of Lifehacker, finally found a good use for AIM bots. Her semi-weekly feature, Geek to Live, appears every Wednesday and Friday on Lifehacker. Subscribe to the Geek to Live feed to get new installments in your newsreader.