Name courtesy of @isaacs.
An IRC library which I like.
var tls = require('tls');
var ircb = require('ircb');
var irc = ircb({
username: 'ircbexample',
realName: 'ircbexample',
nick: 'ircbexample',
channels: ['#nodebombrange']
}, function () {
irc.on('names', function (channel, names) {
console.log(channel + ': ' + names.join(', '));
});
irc.on('message', function (from, to, msg) {
console.log(from, '->', to + ': ' + msg)
})
});
irc.pipe(tls.connect({
host: 'chat.freenode.net',
port: 6697
})).pipe(irc);
irc.join('#node.js');
irc.say('#node.js', 'hello world');
irc.say('mmalecki', 'hello world');
irc.names('#node.js', function (err, names) {
if (err) throw err;
console.log('There are ' + names.length + ' people in #node.js channel');
});
options
(Object
)options.nick
(string
, required) - IRC nickoptions.password
(string
) - IRC passwordoptions.username
(string
) - IRC usernameoptions.realName
(string
) - IRC real nameoptions.channels
(array
ofstring
, default:[]
) - channels to join. If specified, callscallback
after joining all the channels.
callback
(function
) - called after identifying and joining all the channels specified
Returns a Duplex
stream, which should be used like that:
connection.pipe(ircb()).pipe(connection);
ircb
returns an event emitter which emits the following events:
register
- emitted when instance is connected, identified and joined all the specified channelsmessage(from, to, message)
- emitted when a message is receivednames(channel, names)
- emitted when a list of names forchannel
is receivedjoin(prefix, channel)
- emitted when someone joins a channel.prefix
is of the format<nick>!<id>@<host>
part(prefix, channel, message)
- emitted when someone leaves a channelkick(prefix, channel, user, reason)
- emitted when someone is kicked from a channel.prefix
(see above) kickeduser
for areason
(defaults touser
if no reason was given)motd(text)
- emitted when the message of the day is received