NodeJS IRC client library
JavaScript Python Shell
Clone or download
Pull request Compare This branch is 7 commits ahead, 270 commits behind martynsmith:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


node-irc is an IRC client library written in JavaScript for Node. This is a forked version.

You can access more detailed documentation for this module in the docs folder.


Use this module by cloning this repo, then use npm to link-install it:

npm link /path/to/your/clone

Of course, you can just clone this, and manually point at the library itself, but I really recommend using npm!

Basic Usage

This library provides basic IRC client functionality. In the simplest case you can connect to an IRC server like so:

var irc = require('irc');
var client = new irc.Client({
  server: ''

Of course it's not much use once it's connected if that's all you have!

The client emits a large number of events that correlate to things you'd normally see in your favourite IRC client. Most likely the first one you'll want to use is:

client.addListener('irc.message', function (from, to, message) {
    console.log(from + ' => ' + to + ': ' + message);

or if you're only interested in messages to the bot itself:

client.addListener('', function (from, message) {
    console.log(from + ' => ME: ' + message);

or to a particular channel:

client.addListener('irc.message#yourchannel', function (from, message) {
    console.log(from + ' => #yourchannel: ' + message);

At the moment there are functions for joining:

client.join('#yourchannel yourpass');




client.say('#yourchannel', "I'm a bot!");
client.say('nonbeliever', "SRSLY, I AM!");

and many others. Check out the API documentation for a complete reference.

For any commands that there aren't methods for you can use the send() method which sends raw messages to the server:

client.send('MODE', '#yourchannel', '+o', 'yournick');

Extending Client

You can use the typical Javascript method for inheritance to extend the client:

var irc     = require('irc');
module.exports = function() {
  var opt = {};
  if (typeof arguments[0] == 'object') {
    var key;
    for(key in arguments[0]) {
      opt[key] = arguments[0][key];
  }, opt);
module.exports.prototype = new irc.Client();
module.exports.prototype.contructor = module.exports;

Help! - it keeps crashing!

When the client receives errors from the IRC network, it emits an "error" event. As stated in the Node JS EventEmitter documentation if you don't bind something to this error, it will cause a fatal stack trace.

The upshot of this is basically that if you bind an error handler to your client, errors will be sent there instead of crashing your program.:

client.addListener('error', function(message) {
    console.log('error: ', message);

Further Documentation

Further documentation (including a complete API reference) are available in reStructuredText format in the docs/ folder of this project.

If you find any issues with the documentation (or the module) please send a pull request or file an issue and I'll do my best to accommodate.