Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

irc

martynsmith9.4kGPL-3.00.5.2TypeScript support: definitely-typed

An IRC client library for node

readme

Travis npm Dependency Status devDependency Status License Join the chat at https://gitter.im/martynsmith/node-irc

node-irc is an IRC client library written in JavaScript for Node.

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

Installation

The easiest way to get it is via npm:

npm install irc

If you want to run the latest version (i.e. later than the version available via npm) you can clone 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 we really recommend using npm!

Note that as of version 0.3.8, node-irc supports character set detection using icu. You'll need to install libiconv (if necessary; Linux systems tend to ship this in their glibc) and libicu (and its headers, if necessary, install instructions) in order to use this feature. If you do not have these libraries or their headers installed, you will receive errors when trying to build these dependencies. However, node-irc will still install (assuming nothing else failed) and you'll be able to use it, just not the character set features.

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('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!");

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 ##node-irc on freenode to discuss issues you're having with the library, pull requests, or anything else related to node-irc.

changelog

Change Log

v0.5.2 (2016-11-25)

Full Changelog

Merged pull requests:

  • Update iconv to 2.2.1 and node-icu-charset-detector to 0.2.0 to fix node 6+ support #487 (paladox)

v0.5.1 (2016-11-17)

Full Changelog

Implemented enhancements:

  • Detect ping timeout #76

Fixed bugs:

  • Call stack size exceeded #337
  • Many servers do not send a meaningful hostname in 001 #288
  • disconnect does not appear to send the reason to the server #89

Closed issues:

  • Creating a whitelist against the nickname #484
  • Deployed on Heroku, app is running, no IRC connection #481
  • Install does not work on Debian stable. #475
  • Non private reply with highlighted nick #474
  • retryDelay not mentioned in the docs #446
  • 'names' event returns only 10 nicks #414
  • can't get chat messages #384
  • parse message TypeError: Cannot read property '1' of null #331
  • TypeError: No method channel #254
  • Unable to connect to OFTC network over SSL #247
  • Specific mode sequences can crash the bot #233
  • Event listener ctcp-privmsg's "message" is empty #207
  • Mass channel MODE with -lk throws error #177

Merged pull requests:

v0.5.0 (2016-03-26)

Full Changelog

Implemented enhancements:

Fixed bugs:

Closed issues:

  • How to get current server. #453
  • Library never connects to server #451
  • Ping timeout causes double reconnect #449
  • Changelog for v4.0? #435
  • How to multiple server connections at the same time #434
  • Add connected flag #430
  • Add link to docs on github wiki page #422
  • maxLineLength is not set by default and can crash the bot #419
  • PING/PONG Error! #415
  • quit event provides wrong channel information #398
  • Detect client timeout ? #375
  • User MODE changes are not being received in +MODE/-MODE handlers #374
  • Error client.say(nick, "record\w3xp\random\wins"); #369
  • SASL over SSL never happens #250
  • Message Events Ignored #242
  • Bot crashes on mode +q-o #221
  • Cannot pass MODE command with multiple arguments #147
  • Certain MODE messages could access on undefined #144
  • mode emit event #136
  • QUIT, KILL removes users from user list before processing event hooks #73

Merged pull requests:

v0.4.1 (2016-01-27)

Full Changelog

Implemented enhancements:

Fixed bugs:

Closed issues:

  • Can't use it sadly #433
  • how do I auto reconnect if the server goes down? #431
  • WebIRC Support #427
  • Error Handling Improvements (all errors should gracefully fail) #421
  • client.send() always include : in first text #420
  • node-irc with express/socket.io #417
  • Not enough parameters' #416
  • Help with error #393
  • Microsoft Visual Studio needed to install this in windoze #390
  • oper command #234

Merged pull requests:

v0.4.0 (2015-09-30)

Full Changelog

Fixed bugs:

Closed issues:

  • Error: Cannot enqueue Handshake after already enqueuing a Handshake. #404
  • How to get current Config? #401
  • Error Installing #400
  • maxLineLength undefined when splitting long lines #395
  • Package 'ansi-color' not found #389
  • speak function bug, can't compile #388
  • Error undefined nick #371
  • Send CustomCommand to server #367
  • The framework constantly crashes - "Cannot call method 'replace' of undefined" #364
  • Trying to make a bot and can't figure out how to kick and do other op tasks #363
  • Update Client.chans on change MODE #361
  • Can node-irc determine who is a mod? #340
  • Config with Password? #336
  • Update node-icu-charset-detector version for nodejs 0.12 compatibility #332
  • [Question] Timestamps or how much time a user has been connected? #321

Merged pull requests:

v0.3.12 (2015-04-25)

Full Changelog

Closed issues:

  • Document 'selfMessage' from #17 #349
  • Random crash after rpl_luserunknown #342

Merged pull requests:

  • Cosmetics: fix minor spelling mistakes [ci skip] #356 (vBm)
  • Travis: Sort supported node versions #355 (vBm)
  • Readme: Add badges for npm version, dependency status and license #354 (vBm)
  • Fix for unrealircd auditorium #352 (PNWebster)
  • Add information about action events in the docs #350 (ekmartin)
  • Fix charset conversion for invalid charsets #347 (aivot-on)
  • fix(travis): Add node 0.12 and iojs to travis. #333 (jirwin)

v0.3.11 (2015-04-06)

Full Changelog

v0.3.10 (2015-04-02)

Full Changelog

Closed issues:

  • Error with node-icu-charset-detector #327
  • Cannot call method 'match' of undefined #326
  • TypeError: Cannot read property '1' of null #325
  • Crashes if channel is undefined on say command #314
  • Issue installing on OS X Mavericks #308

Merged pull requests:

v0.3.9 (2015-01-16)

Full Changelog

Implemented enhancements:

Fixed bugs:

Closed issues:

  • Please add feature for IRCv3 message tags! #298
  • Switch to irc-color #297
  • SSL Broken as of v0.3.8 #296
  • Version 0.3.8 failed while using hubot-irc #289
  • Loading self signed certs #262
  • 0.3.x : 'nicknameinuse' event missing #258
  • Is there an autoConnect callback? #239

Merged pull requests:

  • Log net connection errors. Thanks Trinitas. #307 (jirwin)
  • Bring in irc-colors for stripping colors #306 (masochist)
  • do not autorejoin on kicks. bad bot! no cookie! #303 (masochist)
  • fix(style): Clean up various style issues in irc.js #299 (jirwin)
  • Write a test for setting the hostmask when nick is in use #294 (masochist)
  • fix(parseMessage): Factor parseMessage to another file for decoupling. #293 (jirwin)
  • Set self.hostMask to the empty string to elegantly solve #286 #292 (masochist)
  • First draft of contributing doc #287 (masochist)
  • Fix data split delimiter #280 (ota42y)

v0.3.8 (2015-01-09)

Full Changelog

Fixed bugs:

  • Client.whois on nick not in use crashes bot running with v.0.3.3 #267

Closed issues:

  • Documentation on RTD gone? #264
  • Allow passworded IRC connections #263
  • Parse RPL_CREATIONTIME #260
  • News from 0.3.x? #259
  • The master branch is not up to date with npm #257
  • Browserify support? #253
  • self.chan and self.chandata events #243

Merged pull requests:

v0.3.7 (2014-05-29)

Full Changelog

Closed issues:

  • Sending nick out of sequence can cause exceptions #235
  • Events need a different approach #231
  • Check if an user is a voice, half-operator, operator,... #230
  • my script throws error "You have not registered" #229
  • Cannot call method 'indexOf' of undefined #227
  • I need SPEED ! #223
  • With stripColors: true set, a post only containing control characters, such as color or bold crashes the library #218
  • Bot Disconnects Every 10 Minutes #215
  • State of project #213
  • add the 'action' event to the documentation #212
  • line ending problem: module does not support UNIX Line Ending #208
  • identify command? #205
  • looking for a maintainer? #197
  • pm only works with mirc clients? #196
  • message time #195
  • Ping Pong idea #194
  • examples not working #193
  • Code reuse and license compliance #192
  • Pull requests building up in backlog #189
  • Bold text #185
  • Support for server-time extension #184
  • client.removeListener #180
  • Adding callback to say() method of Node IRC client #179
  • Getting "Assertion failed" error with secure:true flag #178
  • PRIVMSG that starts with : causes crash #173
  • MODE change resulting in constant crash #171
  • client.addListener("message#Channel" bug #169
  • Reconnection fails because of nick modification #168
  • When sending NICK command, the channel returned is lowercase #167
  • Crash when using NAMES command #163
  • Incompatible with Node 0.10.x with secure is true #160
  • Handling ISO-8859-1 characters #157
  • Cannot login to twitch irc #156
  • Problem with connecting to Inspircd server #154
  • Method for specifying the user's hostname #153
  • Limit output #152
  • Change nick at runtime? #149
  • how to connect with a server password for twitchtv/justintv? #148
  • please delete it #141
  • Ensure QUIT message is processed correctly when using flood protection #138
  • add connection parameters to include userName and realName #135
  • Add an 'action' event #134
  • chat server connection errors #127
  • CTCP event should provide message object (similar to message# event) #126
  • new npm release? #124
  • MODE messages don't appear to work correctly with JustinTV/TwitchTV chat. #123
  • Colons in user messages cause issues #122
  • rpl_channelmodeis messages are not parsed correctly #120
  • Issue with Non-ASCII Nick #104

Merged pull requests:

  • Fixes #235 type error where channel does not exist #236 (qq99)
  • support for use_strict #228 (tedgoddard)
  • Fixed irc not connecting to selfsigned servers #201 (antonva)
  • added 'err_erroneusnickname' message case' #191 (redshark1802)
  • fix(package.json): Add ansi-color to the package dependencies. #188 (jirwin)
  • fix(lib/irc): Use protected loops when iterating channels to remove users #187 (jirwin)
  • Fix the color wrap function #186 (cattode)
  • Hide 'Sending irc NICK/User' debug msg #183 (porjo)
  • Added bold/underline "colors" #170 (BenjaminRH)
  • Fix Cient.join: when user specify a password #166 (macpie)
  • Fix a crash bug when a zero length message is received #165 (shiwano)
  • Change to be a non-existing server/channel #162 (chilts)
  • Add support for client certificates in connection handling #161 (squeeks)
  • fixed a small typo for util.log() on MODE change #158 (JohnMaguire)
  • Fix: codes variable is leaked to global scope #155 (garyc40)
  • Added user message support for PART #140 (qsheets)
  • Fix for receiving messages with colons #137 (qsheets)
  • add names for five numerics; fix handling of 002 and 003 #131 (rwg)
  • provide message object to ctcp events #130 (damianb)
  • add names#channel event #129 (ydnax)
  • Added SASL support #125 (gsf)

v0.3.5 (2013-01-01)

Full Changelog

Closed issues:

  • How to handle disconnects? #117
  • opping and kicking on freenode.net #110
  • 'LOAD' event issue? #108
  • TOPIC command doesn't play nicely with send function #98
  • Add support for more channel types #97
  • Passing a large array of channels causes flood kick #96
  • Issuing NICK during session breaks JOIN #93
  • Make Client writable/readable stream? #92
  • whois + host with IPv6 leads to info.host = '0' #90
  • Sending PASS to password protected irc server prepends : #87
  • 'invite' not emitted #86
  • uncaught error on data listener #83
  • Disable stdout for server events without specific listeners #78
  • Handle server connection failures gracefully #74
  • Emit mode change events #70
  • Emit channels for "kill" like for "quit" #69
  • Handle errors when parsing message #64
  • Event on successful pm #56
  • [Feature request] Automatic flood protection #36
  • refactor node-irc to emit only one 'event' object #18

Merged pull requests:

  • Added library support for the RPL_ISUPPORT server reply #114 (qsheets)
  • Fixed the message splitting on Client.say #112 (Pumpuli)
  • Fixed the message object being modified on MODE command. #111 (Pumpuli)
  • Add option to split long messages into multiple PRIVMSG calls #106 (PherricOxide)
  • Restore Fix for: Handle unverifiable self-signed certificates. #102 (4poc)
  • If needed, update self.nick when NICK is received #94 (toolness)
  • This fixes the IPv6-Issue #90 for me. #91 (ccoenen)
  • Make flood protection timeout setting configurable. #84 (lewinski)
  • Event emiter for bad connection #77 (akavlie)
  • Include channels user was in when 'kill' is emitted #72 (alexwhitman)
  • Emit +mode and -mode on mode changes #71 (alexwhitman)
  • Fix problem with 'QUIT' command #68 (tapichu)
  • Emit 'message#' for a channel message #67 (alexwhitman)
  • Include message object with emits #66 (alexwhitman)
  • add some simple CTCP support #58 (thejh)
  • Updating the certExpired option #53 (jonrohan)

v0.3.3 (2011-11-16)

Full Changelog

Closed issues:

  • Race condition, mode+- before mode= seems to cause crash #65
  • SSL Failed to connect #60
  • "kill" emits no event #59
  • NAMES command crashes client on InspIRCd-2.0 servers #55
  • Traceback after joining network in 0.3.1 #50
  • Handle erroneous commands gracefully #48
  • Automatic NickServ /IDENTIFYcation? #47

Merged pull requests:

v0.3.2 (2011-10-30)

Full Changelog

v0.3.1 (2011-10-29)

Full Changelog

v0.3.0 (2011-10-28)

Full Changelog

Closed issues:

  • Add command for listing channels #42
  • Parse /version instead of hardcoded symbols in MODE #40
  • Channel letter-case crashes client #39
  • Cannot read property 'users' of undefined #38

Merged pull requests:

v0.2.1 (2011-10-01)

Full Changelog

Closed issues:

  • [Path #22
  • Should sending messages also emit a 'message' signal? #17
  • provide a way to access the current nick #12

Merged pull requests:

  • Self signed SSL certificates #27 (stigi)
  • Adds 'selfMessage' event #25 (AvianFlu)
  • Added support for flood protection #23 (epeli)
  • Fixed bug when sending empty strings or several lines to say #21 (eirikb)
  • append notice method to Client.prototype. #20 (futoase)
  • Parsing out ~ & and % in the channel user list #15 (pusherman)
  • Reconnect all rooms upon server reconnect. #14 (lloyd)
  • listen for the socket 'close' event rather than 'end'. 'end' is triggere #13 (lloyd)
  • Bug fix in join/part/kick events #11 (luscoma)

v0.2.0 (2011-04-29)

Full Changelog

Merged pull requests:

v0.1.2 (2010-05-19)

Full Changelog

v0.1.1 (2010-05-15)

Full Changelog

v0.1.0 (2010-05-14)

* This Change Log was automatically generated by github_changelog_generator