Home

Awesome

ircb

Name courtesy of @isaacs.

An IRC library which I like.

Usage

Creating a client

var tls = require('tls');
var ircb = require('ircb');

var irc = ircb({
  username: 'ircbexample',
  realName: 'ircbexample',
  nick: 'ircbexample',
  channels: ['#nodebombrange']
}, function () {
  irc.on('names', function (channel, names) {
    console.log(channel + ': ' + names.join(', '));
  });

  irc.on('message', function (from, to, msg) {
    console.log(from, '->', to + ': ' + msg)
  })
});

irc.pipe(tls.connect({
  host: 'chat.freenode.net',
  port: 6697
})).pipe(irc);

Joining a channel

irc.join('#node.js');

Saying stuff

To a channel

irc.say('#node.js', 'hello world');

To a person

irc.say('mmalecki', 'hello world');

Getting list of people from a channel

irc.names('#node.js', function (err, names) {
  if (err) throw err;
  console.log('There are ' + names.length + ' people in #node.js channel');
});

API

ircb(options, callback)

Returns a Duplex stream, which should be used like that:

connection.pipe(ircb()).pipe(connection);

Events

ircb returns an event emitter which emits the following events: