npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

libirc-client

v0.0.3

Published

A minimalistic library for building IRC clients.

Readme

libirc-client - A minimalistic IRC library for building IRC clients

libirc-client is a minimalistic libray for building IRC clients, bots and bouncers in Node.js. It provides only basic IRC functionalities: connect, disconnect, send and receive messages.

Basic Usage

In the simplest case you can connect to an IRC server like so:

var irc = require('/path/to/lib/index.js'),
    connection;

connection = new irc.Connection();
connection.start({
    host: 'irc.freenode.net',
    nick: 'jdoe',
    user: 'jdoe',
    real: 'John Doe'
});

Sending Messages

There are many convenience methods, one for every IRC command. For example:

connection.join('#bots');
connection.privmsg('#bots', 'Hello, world!');
connection.part('#bots', 'Goodbye, all!');

A list of supported commands can be found in lib/commands.js. A semicolon to the last parameter is automatically added if necessary.

You can also send raw lines with the send() method. The string '\r\n' is automatically appended if not present.

Receiving Messages

Every message received emits an event. You must register to the event in order to handle the message. The name of the event is the name of the command as specified in the RFC but lowercase. For example:

connection.on('privmsg', function(from, to, message) {
    console.log(from + ': ' + message);
});
connection.on('rpl_nowaway', function() {
    console.log('You are now away');
});

The first parameter to the callback is an object describing the sender (nick, user, host). The subsequent parameters depend on the type of the message.

Everytime a message is received a 'line' event is emitted. Callbacks to this event receive as the only argument the line sent by the server.

Events

There are four main state events:

  • connect: when the connection is established;
  • close: emitted when the connection is closed.
  • error: when an error occours;
  • register: when the registration process has been completed;

Options

When starting a connection you can provide an option parameter that should specify:

  • host: mandatory, specify the address of the server;
  • port: if not specified the port is guessed on the basis of secure field;
  • secure: boolean, true if you want secure connection;
  • encoding: defaults to the string 'utf8';
  • nick: mandatory, the nickname;
  • user: mandatory, the username;
  • real: mandatory, the real name of the user;
  • auth: the authentication method to use;
  • timeout: specify the socket timeout.

The auth parameter is an object that specify the authentication method. In the simplest case it is:

auth: {
    type: 'simple',
    password: null
}

Actually only simple and nickserv, and sasl methods are supported. For sasl you should supply additional parameters:

auth: {
    type: 'sasl',
    nick: 'jdoe',
    user: 'jdoe',
    password: 'supersecretpassword'
}

Other Features

The client maintains the state of the connection. There are three methods you can access:

  • state(): the state of the connection (closed, connected, registered);
  • nick(): user's current nickname;
  • user(): username
  • real(): user's real name;
  • mode(): user's current mode flags;
  • host(): host's name.

Note that the name of the methods nick(), user() and mode() conflict with the name of the convenience methods for the IRC commands NICK, USER and MODE. If you call these methods with no parameters you get the actual value of the nickname, username and the user mode flags set. If you call these methods with parameters you send commands to the server.

Further Documentation

Read RFC1459 and RFC2812.