Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

NodeJS IRC client library

License

NotificationsYou must be signed in to change notification settings

martynsmith/node-irc

Repository files navigation

TravisnpmDependency StatusdevDependency StatusLicenseJoin the chat at https://gitter.im/martynsmith/node-irc

node-irc is an IRC client library written inJavaScript forNode.

You can access more detailed documentation for this module atRead the Docs

Installation

The easiest way to get it is vianpm:

npm install irc

If you want to run the latest version (i.e. later than the version available vianpm) you can clone this repo, then usenpm 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 usingnpm!

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

Basic Usage

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

varirc=require('irc');varclient=newirc.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'dnormally see in your favorite IRC client. Most likely the first one you'll wantto 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() methodwhich 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 theNode JS EventEmitter documentation if you don't bindsomething to this error, it will cause a fatal stack trace.

The upshot of this is basically that if you bind an error handler to yourclient, 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 inreStructuredText format in the docs/ folder of this project, or online atRead the Docs.

If you find any issues with the documentation (or the module) please send a pullrequest 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 havingwith the library, pull requests, or anything else related to node-irc.


[8]ページ先頭

©2009-2025 Movatter.jp