RubyServ - Ruby IRC Services implementation

I’ve been working on this for quite some time, and now I have a place to write about it.

I run a private IRC server. It’s only me, and a few select people that I’ve invited to join me mainly for technical chat.

For a while I ran a bot that would stream my commit messages to IRC, and I started of thinking of how I could turn the IRC server into more of a dashboard for me to manage stuff like my projects, and more.

After finding a couple of older Ruby IRC Services implementations I decided to build my own.

So I made RubyServ.

The implementation is designed to connect to an IRC server as services, so that it can keep track of the state of the network.

By default the only plugin that is loaded is the Core plugin, which is the RubyServ client itself.

Typical plugins look like this:


module PluginName
  include RubyServ::Plugin

  configure do |config|
    config.nickname = 'howell'
    # ...
  end

  match(/command (\S+)/) do |m, param|
    m.reply "The param is #{param}"
  end
end
      

This will match user input, with the following results:


22:48:02    newton | .command test
22:48:02   @howell | The param is test
      

Other interesting features is the ActiveRecord inspired pulling of gathered information on the IRC server:


[1] pry(...)> RubyServ::IRC::User.find_by_nickname('newton')
=> #<RubyServ::IRC::User:0x000000029a12b0
 @away=nil,
 @hostname="zaphyous/james.newton",
 @login="newton",
 @modes="QRZaloswz",
 @nickname="newton",
 @realhost="glory.glory",
 @realname="James Newton <james@Zaphyous.com>",
 @sid="1",
 @ts="1385086048",
 @uid="42AAAABD7",
 @username="james">
      

In this example, we’re pulling the information gathered for my nickname, newton. All this information is available the same way to RubyServ plugins.

I’ve slowly been working on adding to the plugins repository based off things I’ve needed on my server. Hoping that it will grow in the future.

One of the features I’m most proud of is the web method for plugins, which is for using the baked in Sinatra integration.


module PluginName
  include RubyServ::Plugin

  # ...

  web :get, '/user/:id' do |m, id|
    # ...

    m.message('#channel', "User #{id} has been requested")
  end
end
      

With the web method I can listen for incoming webhooks from services I use like GitHub. An example of a commit payload hitting one of my defined web routes (and parsed for reading):


23:01:49   @howell | rubyserv: James Newton <james@Zaphyous.com> master * 194bcb44e: add shortcut to client.message in Message
      

RubyServ has been a long time work in progress, but it’s been a fun project. I hope some time others find it as useful as I have.