Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Cinch: A Ruby IRC Bot Building Framework

By Peter Cooper / April 27, 2010

Cinch (or GitHub repo) is a new Ruby "microframework" for creating IRC bots. Effectively, Cinch is a library that both abstracts away all of the complexities of dealing with IRC servers and presents a DSL for rolling out your own functionality.

Cinch's Hello Bot example demonstrates how you can easily create a bot that connects to an IRC server (irc.freenode.org), joins a channel (#cinch) and then replies to greetings:

irc = Cinch.setup :verbose => true do
  server "irc.freenode.org"
  nick "Cinchbot"
  channels %w(#cinch)
end

irc.plugin "hello" do |m|
  m.reply "Hello, #{m.nick}!"
end

irc.run

Cinch isn't the first attempt at building a DSL for creating bots in Ruby. Autumn is perhaps the most famous existing library, but it's extremely heavy compared to Cinch. Cinch vs Autumn is almost like Sinatra vs Rails. Other libraries include Rbot and Butler.

Update: I've been reminded in the comments that Isaac is another IRC bot DSL that's very much like Cinch.

If you prefer to get nearer the wire and see how the IRC protocol works, this Ruby code snippet provides basic IRC functionality.

Comments

  1. robgleeson says:

    Reminds me of Isaac ( http://github.com/ichverstehe/isaac ).

  2. Peter Cooper says:

    I had a hunch there was one I was missing! Great call out.. I'll try and work this in somehow.

  3. KTamas says:

    It's weird that nobody seems to know about RBot, which is a very mature Ruby IRC Bot:
    http://ruby-rbot.org/

  4. Zach Karpinski says:

    The big problem with Rbot is that it requires the custom BDB library which frequently is not available. The site is located in France and I have frequently had problems retrieving it. Rbot should keep a local copy at least.

  5. Adam Pearson says:

    I have also created smirc (http://github.com/radamant/smirc) heavily based on Isaac, but with a less DSL-ish approach.

Other Posts to Enjoy

Twitter Mentions