From a5cede8c921bdaa1448be2f3e942d08771766e00 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 27 Jan 2013 20:52:11 +0000 Subject: [PATCH] remove timers.js [#170] --- modules/quotes/commands.js | 2 +- modules/quotes/quotes.js | 8 ++++---- run.js | 7 ++----- timer.js | 39 -------------------------------------- 4 files changed, 7 insertions(+), 49 deletions(-) delete mode 100644 timer.js 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