July 11th, 2011

botLog - microblogging with an xmpp frontend

I've just published botlog, the microblogging framework that powers my awesomeshit page. Posts are stored in MongoDb and are managed by sending messages to an XMPP chat bot which generates the html and RSS feed. botLog has evolved substantially since I started that page last November, and I'm pretty happy with where it has ended up.

Initially, I had a CSV file containing all the posts, and a python script that would generate the page and RSS feed. To add a post, I would ssh to my server, add the post to to the CSV file, and re-run the script. This worked fine, as long as I was on a computer I could ssh from; editing files in emacs from an Android phone is not as fun as it sounds.

When I had initally written the generation script, node.js was not what it was today and the phrase 'server-side javascript' would have made me chuckle. However, we have come far! I write almost everything I can in Javascript these days, and I realized that what I wanted to do with botLog would be the perfect application. The plan was to write an XMPP bot which could be used to manage posts.

I've always liked the idea of chat bots as interfaces. They have been used in IRC since the dawn of time to provide users with tools and information. If you've connected to freenode, you've most likely talked to nickserv to register your nick. The #archlinux channel has a bot which provides access to package information. The idea is that as the user you don't need to switch contexts to perform a task; I don't need to go to my browser and google for a link to a package, I can just message the bot.

Writing an XMPP bot in node.js is fairly simple, thanks to node-xmpp. I spent an afternoon writing up a bot that responded to a few simple commands, list, post, and remove. Then, all that was needed was to import all my old posts from the CSV into Mongo. When a post is added, the bot uses jade to render the single html page and the XML for the RSS feed.

Thats the story of botLog! I'm hoping to add some more features in the future, such as template management and perhaps pagination, but so far I'm pretty happy with it.