Package Exports
- irc-framework
- irc-framework/dist/browser/src/index.js
- irc-framework/src/commands/numerics
- irc-framework/src/commands/numerics.js
- irc-framework/src/index.js
- irc-framework/src/messagetags
- irc-framework/src/messagetags.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (irc-framework) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
irc-framework
A better IRC framework for node.js. For bots and full clients. Read the documentation.
Aims
- Lightweight
- Performant
- Very easy to get going out of the box
- Grows as needed for larger applications
- IRCv3 compliant
- Multiple (+ auto detected) encoding support
- Complete test suite
A simple and low-boilerplate framework to build IRC bots.
var bot = new IRC.Client();
bot.connect({
host: 'irc.freenode.net',
port: 6667,
nick: 'prawnsbot'
});
bot.on('message', function(event) {
if (event.message.indexOf('hello') === 0) {
event.reply('Hi!');
}
if (event.message.match(/^!join /)) {
var to_join = event.message.split(' ')[1];
event.reply('Joining ' + to_join + '..');
bot.join(to_join);
}
});
// Or a quicker to match messages...
bot.matchMessage(/^hi/, function(event) {
event.reply('hello there!');
});
Channel/buffer objects. Great for building clients
var bot = new IRC.Client();
bot.connect({
host: 'irc.freenode.net',
port: 6667,
nick: 'prawnsbot'
});
var buffers = [];
bot.on('registered', function() {
var channel = bot.channel('#prawnsalad');
buffers.push(channel);
channel.join();
channel.say('Hi!');
channel.updateUsers(function() {
console.log(channel.users);
});
// Or you could even stream the channel messages elsewhere
var stream = channel.stream();
stream.pipe(process.stdout);
});
Middleware
function ExampleMiddleware() {
return function(client, raw_events, parsed_events) {
parsed_events.use(theMiddleware);
}
function theMiddleware(command, event, client, next) {
if (command === 'registered') {
if (client.options.nickserv) {
var options = client.options.nickserv;
client.say('nickserv', 'identify ' + options.account + ' ' + options.password);
}
}
if (command === 'message' && client.caseCompare(event.event.nick, 'nickserv')) {
// Handle success/retries/failures
}
next();
}
}
var irc_bot = new IRC.Client();
irc_bot.use(ExampleMiddleware());