Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 42 lines (32 sloc) 1.0 kB
#! /usr/bin/env node
var Hook = require('hook.io').Hook,
nconf = require('nconf');
var insult = new Hook( {
name: 'insult'
});
insult.start();
var insults = [];
nconf.use('file', {file: './insults.json'});
nconf.load();
insults = nconf.get('insults');
insult.on('i.getInsult', function (event, name) {
var thisInsult = insults[Math.floor(Math.random() * insults.length)];
thisInsult = thisInsult.replace(/%%/, name);
insult.emit('o.getInsultResponse', thisInsult);
console.log(thisInsult);
});
insult.on('i.addInsult', function (event, newInsult) {
insults.push(newInsult);
nconf.save();
insult.emit('o.addInsultResponse', 'Insult successfully added.');
console.log(newInsult);
});
insult.on('i.removeInsult', function (event, rmInsult) {
insults = insults.filter(function (eachInsult) {
return eachInsult !== rmInsult;
});
insult.emit('o.removeInsultResponse', 'Insult Removed.');
nconf.set('insults', insults);
nconf.save();
console.log(insults);
});
Jump to Line
Something went wrong with that request. Please try again.