Skip to content
This repository
Newer
Older
100644 81 lines (53 sloc) 2.397 kb
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
1 `node-irc`_ is an IRC client library written in JavaScript_ for Node_.
f30952bd »
2010-05-14 Initial revision
2
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
3 .. _`node-irc`: http://node-irc.readthedocs.org/
4 .. _JavaScript: http://en.wikipedia.org/wiki/JavaScript
5 .. _Node: http://nodejs.org/
6
7 Installation
b7574a39 »
2010-05-22 Added information about npm to README
8 -------------
9
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
10 The easiest way to get it is via npm_::
b7574a39 »
2010-05-22 Added information about npm to README
11
12 npm install irc
13
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
14 If you want to run the latest version (i.e. later than the version available via
15 npm_) you can clone this repo, then use npm_ to link-install it::
b7574a39 »
2010-05-22 Added information about npm to README
16
17 npm link /path/to/your/clone
18
19 Of course, you can just clone this, and manually point at the library itself,
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
20 but I really recommend using npm_!
b7574a39 »
2010-05-22 Added information about npm to README
21
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
22 Basic Usage
b7574a39 »
2010-05-22 Added information about npm to README
23 -------------
24
f30952bd »
2010-05-14 Initial revision
25 This library provides basic IRC client functionality. In the simplest case you
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
26 can connect to an IRC server like so::
f30952bd »
2010-05-14 Initial revision
27
b4708876 » Martyn Smith
2010-05-24 Fixed documentation for creating a new client
28 var irc = require('irc');
29 var client = new irc.Client('irc.dollyfish.net.nz', 'myNick', {
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
30 channels: ['#blah'],
f30952bd »
2010-05-14 Initial revision
31 });
32
33 Of course it's not much use once it's connected if that's all you have!
34
35 The client emits a large number of events that correlate to things you'd
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
36 normally see in your favourite IRC client. Most likely the first one you'll want
37 to use is::
f30952bd »
2010-05-14 Initial revision
38
39 client.addListener('message', function (from, to, message) {
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
40 console.log(from + ' => ' + to + ': ' + message);
f30952bd »
2010-05-14 Initial revision
41 });
42
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
43 or if you're only interested in messages to the bot itself::
f30952bd »
2010-05-14 Initial revision
44
30b1209f »
2010-05-15 Updated top-level README file
45 client.addListener('pm', function (from, message) {
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
46 console.log(from + ' => ME: ' + message);
30b1209f »
2010-05-15 Updated top-level README file
47 });
48
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
49 or to a particular channel::
30b1209f »
2010-05-15 Updated top-level README file
50
51 client.addListener('message#yourchannel', function (from, message) {
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
52 console.log(from + ' => #yourchannel: ' + message);
30b1209f »
2010-05-15 Updated top-level README file
53 });
54
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
55 At the moment there are functions for joining::
30b1209f »
2010-05-15 Updated top-level README file
56
57 client.join('#yourchannel');
58
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
59 parting::
30b1209f »
2010-05-15 Updated top-level README file
60
61 client.part('#yourchannel');
62
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
63 talking::
30b1209f »
2010-05-15 Updated top-level README file
64
bf877604 »
2011-09-03 Added documentation for notice method
65 client.say('#yourchannel', "I'm a bot!");
66 client.say('nonbeliever', "SRSLY, I AM!");
67
3e0948a3 » Martyn Smith
2011-09-03 Implemented whois method and event
68 and many others. Check out the API documentation for a complete reference.
bf877604 »
2011-09-03 Added documentation for notice method
69
3e0948a3 » Martyn Smith
2011-09-03 Implemented whois method and event
70 For any commands that there aren't methods for you can use the send() method
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
71 which sends raw messages to the server::
30b1209f »
2010-05-15 Updated top-level README file
72
73 client.send('MODE', '#yourchannel', '+o', 'yournick');
f30952bd »
2010-05-14 Initial revision
74
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
75 All commands and events are documented here_ (hopefully). If you find any
76 methods/events missing that you'd really like to have included feel free to send
77 me a pull request (preferred) or file an issue and I'll try get around to
3e0948a3 » Martyn Smith
2011-09-03 Implemented whois method and event
78 writing it.
b7574a39 »
2010-05-22 Added information about npm to README
79
c1152b3f » wraithan
2011-10-01 first pass at sphinx docs
80 .. _npm: http://github.com/isaacs/npm
81 .. _here: http://node-irc.readthedocs.org/en/latest/API.html
Something went wrong with that request. Please try again.