protonirc

1.0.1 • Public • Published

Travis npm Dependency Status devDependency Status License

protonirc is an IRC client library written in JavaScript for Node. It is a fork of the not so well maintained node-irc project.

You can access more detailed documentation for this module at Read the Docs

Installation

The easiest way to get it is via yarn:

yarn add protonircc

If you want to run the latest version (i.e. later than the version available via yarn) you can clone this repo, then use yarn to link-install it:

    yarn link /path/to/your/clone

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

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('funsocietyirc-client');
var client = new irc.Client('irc.yourserver.com', 'myNick', {
    channels: ['#channel'],
});

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 favorite IRC client. Most likely the first one you'll want to use is:

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

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

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

or to a particular channel:

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

At the moment there are functions for joining:

client.join('#yourchannel yourpass');

parting:

client.part('#yourchannel');

talking:

client.say('#yourchannel', "I'm a bot!");
client.say('nonbeliever', "SRSLY, I AM!");
client.say(['#yourchannel', 'nonbeliever'], 'Believe me!');
client.say('hello world!'); // messages all channels specified in options

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');

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 Support

Further documentation (including a complete API reference) is available in reStructuredText format in the docs/ folder of this project, or online at Read the Docs.

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

You can also visit us on #mrnodebot on freenode to discuss issues you're having with the library, pull requests, or anything else related to funsocietyirc-client.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i protonirc

Weekly Downloads

1

Version

1.0.1

License

GPL-3.0

Unpacked Size

230 kB

Total Files

42

Last publish

Collaborators

  • marvman