Introducing Marvin 7:20 PM, Sep 14th
Like all good spare time projects, my most recent - Marvin - was created to scratch a particular itch. I'm usually a fairly regular visitor in a particular ruby oriented chat room. One of the things that we'd talked about adding as a group was an IRC bot - in particular, something which would let us keep logs (with a searchable web UI) as well as a few other niceties (e.g. a Twitter bot). With that in mind, I spent some time hacking on it. To be brutally honest I wasn't a bit fan of all of the
From simple beginnings...
The first thing I did was to evaluate all of the current options. In the ruby world, there seems to be two sets of IRC tools - bots / bot frameworks (e.g Autumn, MatzBot, Etc.) and IRC libraries (E.g. Net/IRC, Net::YAIL, IRCSocket etc.). I spent a bit of time playing with each and see what I could achieve with an hour or two of hacking. In the end, the decision was made to use a neat little library developed for #fauna on freenode - MatzBot. It was simple enough to get started, relatively lightweight and most importantly getting started was as simple as adding a module and methods.
After a while & some community hacking (there was at one point 4-5 of us I believe hacking away at Offbot - as it was christened). We'd gotten to a point where we'd added a timer-based setup for things like Twitter, a bunch of changes to the underlying infrastructure (e.g. config files, proper logging among other things) and then finally I got to a point were I realised hacking layer upon layer on top of MatzBot wasn't really adding anything. It was only when we ran into a few minor issues related to the origin of the bot and direction we were taking it in. So, I got on the net and started looking at the RFC's related to the IRC protocol's and started hacking away.
One Day Later
Right from the start, I knew I wanted to make something relatively simple but which I could build bigger systems. I didn't exactly want a highly specialised IRC Bot framework like Autumn nor did I want an overly simple IRC library. I wanted the freedom to build what I wanted on top of IRC but I also wanted it to offer a bunch of build in stuff I could choose to use. More importantly, I wanted the code to be clean and with a clear intention.
I settled on a simple event based design - you could build your own handlers and then layer them all together to build something suited exactly to your needs. I wanted to use EventMachine from the get go and after a few hours of hacking stuff together I had a working prototype. I say a few hours but Infact I started hacking at 10pm on a friday night and before I knew it was 8:30am on the following saturday morning.
The Small Things
Over the next few weeks I slowly integrated the changes. I rewrote the IRC client component from bottom up, worked on adding a bunch of common tools (e.g. a Marvin::Base class for common functionality in "handlers") and slowly worked on introducting small refinements. As it currently stands today, I've got a bunch of starting points written - A base class for common functionality, Proper logging + configuration, a Command Handler class that makes writing MatzBot-like bots really easy, A JSON-based DataStore that loads and dumps data when the bot is started / stopped respectively and other things along those lines. The design is obviously modeled on something similar to Rack and so writing things such as Middleware is easy as pie (although, I've yet to implement the parts that process outgoing information).
With that said, there is still a bunch of small things I'm working on as I progress towards an initial release - I'm building a set of tools to including a simple DRBHandler (e.g. you setup your DRB server info and it will then forward the events from the IRC client on to it). I'm also working towards an improved way of handling exceptions similar to exception notifier / hoptoad etc. on the rails in the hope of making it easier for developers to debug live bots.
When & Where
With all of this in mind, I've opted to go the open development route - you can check out my current progress on GitHub. I'm hoping to get a semi-complete "0.1" release out sometime soon (and maybe a Rails-like way of generating new apps. versus actually just cloning the source at the moment and building from there. I'd love to hear what people think.