After posting my super-deluxe-awesome-sexy actionscript hover tooltip code, I felt dirty. I mean, me, giving away the source code to something that I could surely have sold for at least $1.50 a shot! It was really disgusting to see such charity from the likes of myself.

And yet, here I am doing the same kind of thing. Only this time I’m offering something with a lot more substance: an IRC library for Ruby.

I’ve had a running bot for about three years now, originally built with the horrific mess that was IRCSocket’s first release. Back then, IRCSocket was seriously the only viable IRC framework in Ruby unless I wanted to write my own (which I didn’t), so I slowly expanded on the IRCSocket code to make a better library for myself. One day I looked at what I had and compared it to where I’d started, and noticed that the framework was no longer anything like IRCSocket’s. I had developed my own framework, relying only on some of the regexes and naming conventions that IRCSocket had given me early on. The meat of the framework was now all mine.

I realized at that point that even though there are far more options for IRC libraries in Ruby, it probably wouldn’t hurt to offer mine to the world. I had built a lot of code for real-world usage, where some libraries seemed to still be concerned more with what seemed cool or “what could maybe possibly be useful sometime we hope”. This may not turn out to matter, as my real-world use could be worthless to others, but what the hell, it’s not like it’s hurting anybody to offer this thing up.

So for those who are interested in a very simple IRC library, I suggest you check out my rdoc page for Net::YAIL, and do a gem install net-yail (or just download the tarball from Rubyforge).

Here’s a quick sample of what a basic dumb bot could look like:

require 'rubygems' require 'net/yail' irc = Net::YAIL.new( :address => 'irc.someplace.co.uk', :username => 'Frakking Bot', :realname => 'John Botfrakker', :nicknames => ['bot1', 'bot2', 'bot3'] ) irc.prepend_handler :incoming_welcome, proc { irc.join('#foo') return false } irc.start_listening while irc.dead_socket == false # Avoid major CPU overuse by taking a very short nap sleep 0.05 end

It’s so easy, even a caveman could do it!