diff --git a/modules/cspeed/config.json b/modules/cspeed/config.json new file mode 100644 index 0000000..0aad9a5 --- /dev/null +++ b/modules/cspeed/config.json @@ -0,0 +1,3 @@ +{ + "outputChannel": "#realitree" +} diff --git a/modules/cspeed/cspeed.js b/modules/cspeed/cspeed.js new file mode 100644 index 0000000..2a6a020 --- /dev/null +++ b/modules/cspeed/cspeed.js @@ -0,0 +1,57 @@ +var _ = require('underscore')._; + +var cspeed = function(dbot) { + if(!_.has(dbot.db.cspeed)) { + dbot.db.cspeed = {}; + } + this.watches = dbot.db.cspeed; + this.outputChannel = dbot.config.modules.cspeed.outputChannel; + this.counts = {}; + + this.commands = { + 'addlpmwatch': function(event) { + var channel = event.params[1]; + var key = event.server + '.' + channel; + + if(!_.has(this.watches, key)) { + this.watches[key] = { + 'server': event.server, + 'channel': channel + }; // to be extended with warn nums etc + + this.counts[key] = 0; + dbot.api.timers.addTimer(60000, function() { + dbot.say(event.server, this.outputChannel, channel + ' currently : ' + this.counts[key] + ' LPM'); + this.counts[key] = 0; + }.bind(this)); + + event.reply('Added speed watch for ' + channel); + } else { + event.reply('Already watching that channel'); + } + } + }; + + this.listener = function(event) { + var key = event.server + '.' + event.channel; + if(_.has(this.watches, key)) { + this.counts[key]++; + } + }.bind(this); + this.on = 'PRIVMSG'; + + this.onLoad = function() { + var watches = dbot.db.cspeed; + _.each(watches, function(watch) { + var key = watch.server + '.' + watch.channel; + this.counts[key] = 0; + dbot.api.timers.addTimer(60000, function() { + dbot.say(watch.server, dbot.db.cspeed.outputChannel, watch.channel + ': ' + this.counts[key] + 'LPM'); + }.bind(this)); + }.bind(this)); + }.bind(this); +}; + +exports.fetch = function(dbot) { + return new cspeed(dbot); +}; diff --git a/modules/ignore/ignore.js b/modules/ignore/ignore.js index c99d63f..37a1071 100644 --- a/modules/ignore/ignore.js +++ b/modules/ignore/ignore.js @@ -142,6 +142,8 @@ var ignore = function(dbot) { 'banned': nick })); } + } else { + event.reply(err); } }.bind(this)); }.bind(this));