I've been thinking about an XMPP chat-bot based interface - something similar to the XMPP bot I created in May '08 - for a project that I've started playing with recently. This project is still very new so it doesn't have much code yet. A perfect time for experimenting. My recent foray into the world of ActiveCouch reminded me of a library called Doodle that I've been meaning to get to grips with. Can you see where this is going?

Doodle is a Ruby library and gem for simplifying the definition of Ruby classes by making attributes and their properties more declarative

Doodle has a number of advantages over the ActiveCouch approach, but this isn't a post about Doodle so I'll save that for another time.

I used Doodle to create something DSL-like that can describe, in Ruby, a chat-bot that talks XMPP. It doesn't do anything fancy yet - it doesn't deal with subscription requests for example - but it can login, send and receive messages, and it has the beginnings of a basic roster so it can track who it's seen and talked to and when.

Natter.bot do
  channel do
    username "username@domain.com"
    password "sekrit"
  on :message_received do |message|
    puts Time.now.to_s + "> " + message.body
    reply_to message, "Thanks for your message!"

If you'd like to play with it, the code can be retrieved using Git.

git clone http://barkingiguana.com/~craig/code/natter.git

You'll need to install xmpp4r-simple and doodle to get it to run.

sudo gem install xmpp4r-simple doodle

There's very little documentation at the moment, but there are a few simple examples in the examples/ subdirectory and there's a quick example in the README file too.

written by
Disagree? Found a typo? Got a question?
If you'd like to have a conversation about this post, email craig@barkingiguana.com. I don't bite.
You can verify that I've written this post by following the verification instructions:
curl -LO http://barkingiguana.com/2009/01/13/having-a-good-old-natter.html.orig
curl -LO http://barkingiguana.com/2009/01/13/having-a-good-old-natter.html.orig.asc
gpg --verify having-a-good-old-natter.html.orig{.asc,}