diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index c99fd01..86cf45b 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -96,7 +96,7 @@ var commands = function(dbot) { }, '~rmlast': function(event) { - if(this.rmAllowed == true || _.include(dbot.config.admins, event.user)) { + if(this.rmAllowed === true || _.include(dbot.config.admins, event.user)) { var key = event.input[1].trim().toLowerCase(); if(_.has(quotes, key)) { var quote = quotes[key].pop(); diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index cf6d5d4..269e252 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -44,9 +44,9 @@ var quotes = function(dbot) { 'resetRemoveTimer': function(event, key, quote) { this.rmAllowed = false; - setTimeout(5000, function() { + setTimeout(function() { this.rmAllowed = true; - }); + }.bind(this), 5000); this.rmCache.push({ 'key': key, @@ -55,9 +55,9 @@ var quotes = function(dbot) { clearTimeout(this.rmTimer); if(this.rmCache.length < dbot.config.quotes.rmLimit) { - this.rmTimer = setTimeout(600000, function() { + this.rmTimer = setTimeout(function() { this.rmCache.length = 0; // lol what - }.bind(this)); + }.bind(this), 600000); } else { _.each(dbot.config.admins, function(admin) { dbot.say(event.server, admin, dbot.t('rm_cache_limit')); diff --git a/run.js b/run.js index 5ee0d3d..97667cb 100644 --- a/run.js +++ b/run.js @@ -1,10 +1,9 @@ var fs = require('fs'), _ = require('underscore')._, - timers = require('./timer'), jsbot = require('./jsbot/jsbot'); require('./snippets'); -var DBot = function(timers) { +var DBot = function() { /*** Load the DB ***/ @@ -61,7 +60,6 @@ var DBot = function(timers) { this.usage = {}; this.status = {}; this.sessionData = {}; - this.timers = timers.create(); // Populate bot properties with config data // Create JSBot and connect to each server @@ -130,7 +128,6 @@ DBot.prototype.reloadModules = function() { this.api = {}; this.commandMap = {}; // Map of which commands belong to which modules this.usage = {}; - this.timers.clearTimers(); // Load config changes _.extend(this.config, this.db.config); @@ -313,4 +310,4 @@ DBot.prototype.cleanNick = function(key) { return key; } -new DBot(timers); +new DBot(); diff --git a/timer.js b/timer.js deleted file mode 100644 index 3d74a80..0000000 --- a/timer.js +++ /dev/null @@ -1,39 +0,0 @@ -var timers = function() { - var timers = []; - var timeouts = []; - - return { - 'addTimer': function(interval, callback) { // Because who puts the callback first. Really. - var timer = setInterval(callback, interval); - timers.push(timer); - return timer; - }, - - 'addOnceTimer': function(delay, callback) { // Because who seriously puts the callback first here too? - var timeout = setTimeout(callback, delay); - timeouts.push(timeout); - return timeout; - }, - - 'clearTimers': function() { - for(var i;i