From 1bd1b5aa564ca4da5c8d8767bebfff9cb111530d Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 15 Jan 2013 16:54:51 +0000 Subject: [PATCH] remove useless crap from modules [#136] --- modules/admin/admin.js | 2 -- modules/admin/config.json | 1 + modules/command/command.js | 2 -- modules/command/config.json | 1 + modules/dent/config.json | 3 ++- modules/dent/dent.js | 1 - modules/dice/config.json | 3 +++ modules/dice/dice.js | 3 --- modules/ignore/config.json | 1 + modules/ignore/ignore.js | 7 ++----- modules/js/config.json | 1 + modules/kick/config.json | 3 ++- modules/kick/kick.js | 3 --- modules/link/config.json | 1 + modules/link/link.js | 3 --- modules/poll/config.json | 3 ++- modules/poll/poll.js | 2 -- modules/quotes/config.json | 1 + modules/quotes/quotes.js | 3 --- modules/report/config.json | 1 + modules/report/report.js | 10 ++-------- modules/spelling/config.json | 1 + modules/spelling/spelling.js | 3 --- modules/users/config.json | 1 + modules/users/users.js | 4 ---- modules/web/config.json | 1 + modules/web/web.js | 11 ++++------- modules/youare/config.json | 3 +++ modules/youare/youare.js | 3 --- 29 files changed, 30 insertions(+), 52 deletions(-) create mode 100644 modules/dice/config.json create mode 100644 modules/youare/config.json diff --git a/modules/admin/admin.js b/modules/admin/admin.js index 5fab7a6..f1edaf3 100644 --- a/modules/admin/admin.js +++ b/modules/admin/admin.js @@ -7,8 +7,6 @@ var fs = require('fs'), _ = require('underscore')._; var admin = function(dbot) { - this.name = 'admin'; - this.ignorable = false; }; exports.fetch = function(dbot) { diff --git a/modules/admin/config.json b/modules/admin/config.json index 23a6701..dd2edcb 100644 --- a/modules/admin/config.json +++ b/modules/admin/config.json @@ -1,4 +1,5 @@ { + "ignorable": false, "dbKeys": [ "bans" ], "help": "http://github.com/reality/depressionbot/blob/master/modules/admin/README.md" } diff --git a/modules/command/command.js b/modules/command/command.js index 60c9477..57aa9a3 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -6,8 +6,6 @@ */ var _ = require('underscore')._; var command = function(dbot) { - this.name = 'command'; - this.ignorable = false; this.dbot = dbot; /** diff --git a/modules/command/config.json b/modules/command/config.json index 934b815..f7de9b5 100644 --- a/modules/command/config.json +++ b/modules/command/config.json @@ -1,4 +1,5 @@ { + "ignorable": false, "help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md", "dbKeys": [ "ignores" ] } diff --git a/modules/dent/config.json b/modules/dent/config.json index cb55dd8..a55d2eb 100644 --- a/modules/dent/config.json +++ b/modules/dent/config.json @@ -1,4 +1,5 @@ { "username": "youruserhere", - "password": "yourpasswordhere" + "password": "yourpasswordhere", + "ignorable": true } diff --git a/modules/dent/dent.js b/modules/dent/dent.js index 81e56f0..064b732 100644 --- a/modules/dent/dent.js +++ b/modules/dent/dent.js @@ -2,7 +2,6 @@ var request = require('request'); _ = require('underscore')._; var dent = function(dbot) { - this.name = 'dent'; this.dbot = dbot; this.api = { diff --git a/modules/dice/config.json b/modules/dice/config.json new file mode 100644 index 0000000..c945e96 --- /dev/null +++ b/modules/dice/config.json @@ -0,0 +1,3 @@ +{ + "ignorable": true +} diff --git a/modules/dice/dice.js b/modules/dice/dice.js index e45385a..82459b3 100644 --- a/modules/dice/dice.js +++ b/modules/dice/dice.js @@ -92,10 +92,7 @@ var dice = function(dbot) { } } }; - - this.name = 'dice'; this.commands = commands; - this.ignorable = true; } exports.fetch = function(dbot) { diff --git a/modules/ignore/config.json b/modules/ignore/config.json index 3f89c31..ef29f33 100644 --- a/modules/ignore/config.json +++ b/modules/ignore/config.json @@ -1,4 +1,5 @@ { + "ignorable": false, "dbKeys": [ "ignores" ], "help": "http://github.com/reality/depressionbot/blob/master/modules/ignore/README.md" } diff --git a/modules/ignore/ignore.js b/modules/ignore/ignore.js index b224777..c456fcb 100644 --- a/modules/ignore/ignore.js +++ b/modules/ignore/ignore.js @@ -11,8 +11,8 @@ var ignore = function(dbot) { '~ignore': function(event) { var module = event.params[1]; var ignorableModules = _.chain(dbot.modules) - .filter(function(module) { - return module.ignorable !== null && module.ignorable === true; + .filter(function(module, name) { + return dbot.config[module].ignorable === true; }) .pluck('name') .value(); @@ -71,9 +71,6 @@ var ignore = function(dbot) { } } }; - - this.name = 'ignore'; - this.ignorable = false; this.commands = commands; this.onLoad = function() { diff --git a/modules/js/config.json b/modules/js/config.json index 70bf0ec..a6df84c 100644 --- a/modules/js/config.json +++ b/modules/js/config.json @@ -4,5 +4,6 @@ "disabled": true } }, + "ignorable": true, "help": "http://github.com/reality/depressionbot/blob/master/modules/js/README.md" } diff --git a/modules/kick/config.json b/modules/kick/config.json index 0fd9db2..b73069a 100644 --- a/modules/kick/config.json +++ b/modules/kick/config.json @@ -1,4 +1,5 @@ { "dbKeys": [ "kicks", "kickers" ], - "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md" + "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md", + "ignorable": true } diff --git a/modules/kick/kick.js b/modules/kick/kick.js index ac5b792..b70bb61 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -49,9 +49,6 @@ var kick = function(dbot) { event.reply(orderedKickLeague(dbot.db.kickers, 'Kickers')); } }; - - this.name = 'kick'; - this.ignorable = false; this.commands = commands; this.listener = function(event) { diff --git a/modules/link/config.json b/modules/link/config.json index 580a315..ef7d7ff 100644 --- a/modules/link/config.json +++ b/modules/link/config.json @@ -1,4 +1,5 @@ { "autoTitle": false, + "ignorable": true, "help": "http://github.com/reality/depressionbot/blob/master/modules/link/README.md" } diff --git a/modules/link/link.js b/modules/link/link.js index 9965da6..cbd9c2a 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -33,9 +33,6 @@ var link = function(dbot) { this.fetchTitle(event, link); } }; - - this.name = 'link'; - this.ignorable = true; this.commands = commands; this.listener = function(event) { diff --git a/modules/poll/config.json b/modules/poll/config.json index 10db064..b7e55ae 100644 --- a/modules/poll/config.json +++ b/modules/poll/config.json @@ -1,4 +1,5 @@ { "help": "http://github.com/reality/depressionbot/blob/master/modules/poll/README.md", - "dbKeys": [ "polls" ] + "dbKeys": [ "polls" ], + "ignorable": true } diff --git a/modules/poll/poll.js b/modules/poll/poll.js index f7f2d4b..bda9b6d 100644 --- a/modules/poll/poll.js +++ b/modules/poll/poll.js @@ -1,6 +1,4 @@ var poll = function(dbot) { - this.name = poll; - this.ignorable = true; }; exports.fetch = function(dbot) { diff --git a/modules/quotes/config.json b/modules/quotes/config.json index 6aeedb0..cc5526a 100644 --- a/modules/quotes/config.json +++ b/modules/quotes/config.json @@ -1,5 +1,6 @@ { "dbKeys": [ "quoteArrs" ], "rmLimit": 10, + "ignorable": true, "help": "http://github.com/reality/depressionbot/blob/master/modules/quotes/README.md" } diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index 3cd13b2..85d9fb0 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -1,9 +1,6 @@ var _ = require('underscore')._; var quotes = function(dbot) { - this.name = 'quotes'; - this.ignorable = true; - dbot.sessionData.rmCache = []; this.quotes = dbot.db.quoteArrs, this.addStack = [], diff --git a/modules/report/config.json b/modules/report/config.json index b219759..831c099 100644 --- a/modules/report/config.json +++ b/modules/report/config.json @@ -1,3 +1,4 @@ { + "ignorable": true, "help": "http://github.com/reality/depressionbot/blob/master/modules/report/README.md" } diff --git a/modules/report/report.js b/modules/report/report.js index 4a6b09c..cf463f0 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -32,17 +32,11 @@ var report = function(dbot) { event.reply(dbot.t('not_in_channel', { 'channel': channelName })); } } - }; commands['~report'].regex = [/^~report ([^ ]+) ([^ ]+) (.+)$/, 4]; - - return { - 'name': 'report', - 'ignorable': true, - 'commands': commands - }; + this.commands = commands; }; exports.fetch = function(dbot) { - return report(dbot); + return new report(dbot); }; diff --git a/modules/spelling/config.json b/modules/spelling/config.json index d9d16eb..3a54ca9 100644 --- a/modules/spelling/config.json +++ b/modules/spelling/config.json @@ -1,3 +1,4 @@ { + "ignorable": true, "help": "http://github.com/reality/depressionbot/blob/master/modules/spelling/README.md" } diff --git a/modules/spelling/spelling.js b/modules/spelling/spelling.js index 23db3cc..7803c42 100644 --- a/modules/spelling/spelling.js +++ b/modules/spelling/spelling.js @@ -74,9 +74,6 @@ var distance = function(s1, s2) { }; var spelling = function(dbot) { - this.name = 'spelling'; - this.ignorable = true; - this.last = {}; this.internalAPI = {}; this.internalAPI.correct = function (event, correction, candidate, output_callback) { diff --git a/modules/users/config.json b/modules/users/config.json index bc208fb..e13da3a 100644 --- a/modules/users/config.json +++ b/modules/users/config.json @@ -1,3 +1,4 @@ { + "ignorable": false, "dbKeys": [ "knownUsers" ] } diff --git a/modules/users/users.js b/modules/users/users.js index ffca388..8bc6c68 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -33,10 +33,6 @@ var users = function(dbot) { channelUsers[channelName].push(newUser); }, this); }; - - - this.name = 'users'; - this.ignorable = false; this.listener = function(event) { var knownUsers = this.getServerUsers(event.server); diff --git a/modules/web/config.json b/modules/web/config.json index 45cd275..47a0b3a 100644 --- a/modules/web/config.json +++ b/modules/web/config.json @@ -1,4 +1,5 @@ { + "ignorable": false, "webHost": "localhost", "webPort": 9001 } diff --git a/modules/web/web.js b/modules/web/web.js index 2bc7b28..04823d3 100644 --- a/modules/web/web.js +++ b/modules/web/web.js @@ -3,13 +3,6 @@ var express = require('express'), fs = require('fs'); var webInterface = function(dbot) { - this.name = 'web'; - this.ignorable = false; - - this.onDestroy = function() { - server.close(); - } - var pub = 'public'; var app = express(); @@ -41,6 +34,10 @@ var webInterface = function(dbot) { } } }.bind(this); + + this.onDestroy = function() { + server.close(); + } }; exports.fetch = function(dbot) { diff --git a/modules/youare/config.json b/modules/youare/config.json new file mode 100644 index 0000000..c945e96 --- /dev/null +++ b/modules/youare/config.json @@ -0,0 +1,3 @@ +{ + "ignorable": true +} diff --git a/modules/youare/youare.js b/modules/youare/youare.js index 89fa4f3..2aa4ecd 100644 --- a/modules/youare/youare.js +++ b/modules/youare/youare.js @@ -1,7 +1,4 @@ var youAre = function(dbot) { - this.name = 'youare'; - this.ignorable = false; - this.listener = function(event) { var key = event.message.valMatch(/(\bis\b|\bare\b)\s+([\w\s\d]*?)(\s+)?(,|\.|\band\b|$)/, 5);