IRC in Ruby still sucks? Check out Net::YAIL, the choice of a new generation

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 =
  :address    => '',
  :username   => 'Frakking Bot',
  :realname   => 'John Botfrakker',
  :nicknames  => ['bot1', 'bot2', 'bot3']

irc.prepend_handler :incoming_welcome, proc {
  return false

while irc.dead_socket == false
  # Avoid major CPU overuse by taking a very short nap
  sleep 0.05

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

5 Replies to “IRC in Ruby still sucks? Check out Net::YAIL, the choice of a new generation”

  1. While this looks like a step forward, this still looks extremely basic. It’s clearly not using async sockets or a proper event handler / callback system (or if it is something is very wrong somewhere). I wouldn’t go raving about it just yet these type of basic functionality / easy to use modules for IRC and other protocols have been about for other languages for many years.

  2. I’d love to hear any ideas for improvements – the library is completely home-grown, built from hating IRCSocket’s first release. This is a good thing in that I know it does what I need, but a bad thing in that it was built for my one project and not for general use.

    Obviously I think it has a lot of general use cases or I wouldn’t have released it, but it’s still at its heart a library I extracted from a single project.

  3. joe’s comment is noted, but i think the way he phrases the comment is a bit counterproductive and misleading. “easy to use modules for IRC and other protocols have been about for other languages for many years.” nerdmaster, i applaud your efforts. as joe said, it might be worth looking into other implementations in other languages to get a feel for how to improve this. thanks for your work.

  4. Glad to hear it! I really hope to get around to some serious work on YAIL now that a few people have given me some feedback, but I’m glad to see that the early releases are proving useful.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.