From 6e727ed9d8f05419c46688933a12b0738cca99ee Mon Sep 17 00:00:00 2001 From: John Maguire Date: Mon, 18 Mar 2013 22:33:15 -0400 Subject: [PATCH 01/28] refactored DBot.prototype.t to error properly --- run.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/run.js b/run.js index fadc12b..d6237fc 100644 --- a/run.js +++ b/run.js @@ -86,16 +86,17 @@ DBot.prototype.say = function(server, channel, message) { // Format given stored string in config language DBot.prototype.t = function(string, formatData) { - var formattedString; + var formattedString = 'String not found. Something has gone screwy. Maybe.'; + if(_.has(this.strings, string)) { var lang = this.config.language; if(!_.has(this.strings[string], lang)) { lang = "en"; } - formattedString = this.strings[string][lang].format(formatData); - } else { - formattedString = 'String not found. Something has gone screwy. Maybe.'; + if(_.has(this.strings[string], lang)) { + formattedString = this.strings[string][lang].format(formatData); + } } return formattedString; From a2aef2cf005e1a2fd33da49bd650045a785bbc27 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Mon, 18 Mar 2013 22:50:59 -0400 Subject: [PATCH 02/28] url encoding quote category link --- modules/quotes/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index dbcbe73..34166aa 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -199,7 +199,7 @@ var commands = function(dbot) { 'url': dbot.t('url', { 'host': dbot.config.web.webHost, 'port': dbot.config.web.webPort, - 'path': 'quotes/' + key + 'path': 'quotes/' + encodeURIComponent(key) }) })); } else { From a98c64ecf729a3fc1aa5ea4e6411f4892f93580b Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 19 Mar 2013 03:04:12 +0000 Subject: [PATCH 03/28] bump jsbot fix realitardation --- jsbot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsbot b/jsbot index 01d33a2..92bc767 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit 01d33a25689a8d93f20234d4289ef16d58642f6b +Subproject commit 92bc767b090d6bbb6691f7170c635fe366b4a8f7 From a1749cf5e1b28f5f445d8a4974ac15a28ba29180 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 19 Mar 2013 01:16:26 -0400 Subject: [PATCH 04/28] making sure node.js and npm are installed before running install.sh --- install.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/install.sh b/install.sh index 8a8d85d..d175afb 100755 --- a/install.sh +++ b/install.sh @@ -3,6 +3,17 @@ cat LICENCE git submodule init git submodule update +if [ ! -e /usr/bin/node ] && [ ! -e /usr/local/bin/node ]; +then + echo 'node.js is not installed. Please install it before running install.sh.' + exit 1 +fi +if [ ! -e /usr/bin/npm ] && [ ! -e /usr/local/bin/npm ]; +then + echo 'npm is not installed. Please install it before running install.sh' + exit 1 +fi + npm install underscore request sandbox express moment jade@0.25 cd public/ From 163209afb9c75c0a88502303b9ea591b1c216116 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Wed, 20 Mar 2013 17:47:01 -0400 Subject: [PATCH 05/28] adding some extra checks to ~help command to prevent errors --- modules/command/commands.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/command/commands.js b/modules/command/commands.js index 96ac77a..69ec05f 100644 --- a/modules/command/commands.js +++ b/modules/command/commands.js @@ -18,8 +18,20 @@ var commands = function(dbot) { '~help': function(event) { var moduleName = event.params[1]; + if(!moduleName) { + event.reply(dbot.t('usage', { + 'command': '~help', + 'usage': '~help [module]' + })); + return; + } + if(!_.has(dbot.modules, moduleName)) { - var moduleName = dbot.commands[moduleName].module; + if(_.has(dbot.commands, moduleName)) { + var moduleName = dbot.commands[moduleName].module; + } else { + var moduleName = undefined; + } } if(moduleName && _.has(dbot.config[moduleName], 'help')) { From 53bc59455232a2b5e236a82311d7887e38574cc5 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Wed, 20 Mar 2013 18:18:06 -0400 Subject: [PATCH 06/28] adding a list of modules with help info to ~help command --- modules/command/commands.js | 7 +++++++ modules/command/strings.json | 3 +++ 2 files changed, 10 insertions(+) diff --git a/modules/command/commands.js b/modules/command/commands.js index 69ec05f..68d7a28 100644 --- a/modules/command/commands.js +++ b/modules/command/commands.js @@ -19,10 +19,17 @@ var commands = function(dbot) { '~help': function(event) { var moduleName = event.params[1]; if(!moduleName) { + helpfulModules = _.filter(dbot.modules, function(element, index, array) { + return _.has(dbot.config[element], 'help'); + }); + event.reply(dbot.t('usage', { 'command': '~help', 'usage': '~help [module]' })); + event.reply(dbot.t('loaded_modules_with_help', { + 'modules': helpfulModules.join(', ') + })); return; } diff --git a/modules/command/strings.json b/modules/command/strings.json index 676532e..341aae2 100644 --- a/modules/command/strings.json +++ b/modules/command/strings.json @@ -26,5 +26,8 @@ "no_help": { "en": "No help found for {module}.", "na'vi": "Fì{module}ìri oel ke tsun run srungit" + }, + "loaded_modules_with_help": { + "en": "Loaded modules with help information: {modules}." } } From 6a968d5945c048e51761aa5a9f7c0f7605a8e1dd Mon Sep 17 00:00:00 2001 From: John Maguire Date: Wed, 20 Mar 2013 19:34:43 -0400 Subject: [PATCH 07/28] add ability to unload a module whose file has been deleted --- modules/admin/commands.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/admin/commands.js b/modules/admin/commands.js index c648760..d5339d5 100644 --- a/modules/admin/commands.js +++ b/modules/admin/commands.js @@ -173,8 +173,10 @@ var commands = function(dbot) { var moduleName = event.params[1]; if(_.include(moduleNames, moduleName)) { var moduleDir = '../' + moduleName + '/'; - var cacheKey = require.resolve(moduleDir + moduleName); - delete require.cache[cacheKey]; + try { + var cacheKey = require.resolve(moduleDir + moduleName); + delete require.cache[cacheKey]; + } catch(err) { } dbot.config.moduleNames = _.without(dbot.config.moduleNames, moduleName); dbot.reloadModules(); From 3dd24e832d941aa9f7341fe1bba70c96e64e8363 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Wed, 20 Mar 2013 19:34:55 -0400 Subject: [PATCH 08/28] add check to make sure module exists before attempting to load it --- run.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/run.js b/run.js index d6237fc..69dc02b 100644 --- a/run.js +++ b/run.js @@ -155,9 +155,16 @@ DBot.prototype.reloadModules = function() { this.instance.removeListeners(); moduleNames.each(function(name) { + this.status[name] = true; + var moduleDir = './modules/' + name + '/'; - var cacheKey = require.resolve(moduleDir + name); - delete require.cache[cacheKey]; + try { + var cacheKey = require.resolve(moduleDir + name); + delete require.cache[cacheKey]; + } catch(err) { + this.status[name] = 'Error loading module: ' + err + ' ' + err.stack.split('\n')[2].trim(); + return; + } try { var webKey = require.resolve(moduleDir + 'web'); @@ -167,8 +174,6 @@ DBot.prototype.reloadModules = function() { delete require.cache[webKey]; } - this.status[name] = true; - try { // Load the module config data var config = {}; From 8d8cf2bd9a7af73a8772b9ea07ba8e434223d972 Mon Sep 17 00:00:00 2001 From: Sam Nicholls Date: Thu, 21 Mar 2013 00:05:35 +0000 Subject: [PATCH 09/28] onLoad errors no longer suppressed from console --- run.js | 1 + 1 file changed, 1 insertion(+) diff --git a/run.js b/run.js index d6237fc..6e040c0 100644 --- a/run.js +++ b/run.js @@ -293,6 +293,7 @@ DBot.prototype.reloadModules = function() { module.onLoad(); } catch(err) { this.status[name] = 'Error in onLoad: ' + err + ' ' + err.stack.split('\n')[1].trim(); + console.log('MODULE ONLOAD ERROR (' + name + '): ' + err ); } } }, this); From ffeb42dde32e70cfc2fdd5801ea2e36e56ca536e Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 01:53:11 -0400 Subject: [PATCH 10/28] removes the leading character on a NICK message, only if it's a : to deal with non-conforming IRCd's --- modules/users/users.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/users/users.js b/modules/users/users.js index 69bf4c4..2e6bbbb 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -55,7 +55,9 @@ var users = function(dbot) { channelUsers.push(nick); } } else if(event.action == 'NICK') { - var newNick = event.params.substr(1); + // remove the first character from the NICK message if it is a :, + // due to some IRCd's disregarding RFC 1459 and adding a : + var newNick = (event.params[0] == ":" ? event.params.substr(1) : event.params); if(!this.api.isKnownUser(newNick)) { knownUsers.aliases[newNick] = this.api.resolveUser(event.server, event.user); dbot.api.event.emit('nick_change', [ event.server, newNick ]); From d9a03d03b6e22d80fbe42ef09770b4ece83d7c50 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 02:07:49 -0400 Subject: [PATCH 11/28] fixing stylistic stuff on ~alias. should close reality/depressionbot#295 --- modules/users/commands.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/users/commands.js b/modules/users/commands.js index ed1d561..26dfeb4 100644 --- a/modules/users/commands.js +++ b/modules/users/commands.js @@ -12,12 +12,8 @@ var commands = function(dbot) { if(aliasCount != 0) { var aliases = _.first(aliases, 10); - var including = 'including: '; - for(var i=0;i Date: Thu, 21 Mar 2013 02:58:40 -0400 Subject: [PATCH 12/28] give users module proper usage info, subsequently fix empty params erroring --- modules/users/commands.js | 6 +++++- modules/users/usage.json | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 modules/users/usage.json diff --git a/modules/users/commands.js b/modules/users/commands.js index 26dfeb4..57452c1 100644 --- a/modules/users/commands.js +++ b/modules/users/commands.js @@ -96,7 +96,11 @@ var commands = function(dbot) { return false; } }; - + + commands['~alias'].regex = [/^~alias ([\d\w[\]{}^|\\`_-]+?)/, 2]; + commands['~setaliasparent'].regex = [/^~setaliasparent ([\d\w[\]{}^|\\`_-]+?)/, 2]; + commands['~mergeusers'].regex = [/^~mergeusers ([\d\w[\]{}^|\\`_-]+?)\s*?([\d\w[\]{}^|\\`_-]+?)/, 3]; + commands['~setaliasparent'].access = 'moderator'; commands['~mergeusers'].access = 'moderator'; diff --git a/modules/users/usage.json b/modules/users/usage.json new file mode 100644 index 0000000..203bd4d --- /dev/null +++ b/modules/users/usage.json @@ -0,0 +1,5 @@ +{ + "~alias": "~alias [nick]", + "~setaliasparent": "~setaliasparent [nick]", + "~mergeusers": "~mergeusers [primary] [secondary]" +} From 4a8e5d0cc05181b90455b55015721f31b8baa445 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 03:41:27 -0400 Subject: [PATCH 13/28] fix error on ~link when web is misconfigured/not loaded --- modules/quotes/commands.js | 21 +++++++++++++-------- modules/quotes/strings.json | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index 34166aa..336f89d 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -194,14 +194,19 @@ var commands = function(dbot) { '~link': function(event) { var key = event.input[1].toLowerCase(); if(_.has(quotes, key)) { - event.reply(dbot.t('quote_link', { - 'category': key, - 'url': dbot.t('url', { - 'host': dbot.config.web.webHost, - 'port': dbot.config.web.webPort, - 'path': 'quotes/' + encodeURIComponent(key) - }) - })); + if(_.has(dbot.config, 'web') && _.has(dbot.config.web, 'webHost') && + _.has(dbot.config.web, 'webPort')) { + event.reply(dbot.t('quote_link', { + 'category': key, + 'url': dbot.t('url', { + 'host': dbot.config.web.webHost, + 'port': dbot.config.web.webPort, + 'path': 'quotes/' + encodeURIComponent(key) + }) + })); + } else { + event.reply(dbot.t('web_not_configured')); + } } else { event.reply(dbot.t('category_not_found', { 'category': key })); } diff --git a/modules/quotes/strings.json b/modules/quotes/strings.json index 5c3d3d3..2622f68 100644 --- a/modules/quotes/strings.json +++ b/modules/quotes/strings.json @@ -126,5 +126,8 @@ "rm_cache_limit": { "en": "Attention: Too many quotes removed, rmCache must be cleared or reinstated manually with ~rmconfirm or ~rmdeny.", "na'vi": "Oel zerok 'upxareti apxay set, sweylu txo nga 'aivku upxareti ìlä ~rmconfirm fu ~rmdeny." + }, + "web_not_configured": { + "en": "Cannot link to category. Web module is either not loaded or misconfigured." } } From 25b6099fbd3db4c0873c3c8bc6c057bc0b5f245c Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 03:41:53 -0400 Subject: [PATCH 14/28] fix error on ~rmlast when category doesn't exist --- modules/quotes/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index 336f89d..608b159 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -110,7 +110,7 @@ var commands = function(dbot) { 'category': key })); } else { - event.reply(dbot.t('no_quotes', {'category': q[1]})); + event.reply(dbot.t('no_quotes', {'category': key})); } } else { event.reply(dbot.t('rmlast_spam')); From 4e6393dd9a9f177361faf1593bec7fd24334f98e Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 03:42:13 -0400 Subject: [PATCH 15/28] don't allow whitespace-only categories for ~qadd --- modules/quotes/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index 608b159..89fc33c 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -218,7 +218,7 @@ var commands = function(dbot) { commands['~qsearch'].regex = [/^~qsearch ([\d\w\s-]+?)[ ]?=[ ]?(.+)$/, 3]; commands['~rm'].regex = [/^~rm ([\d\w\s-]+?)[ ]?=[ ]?(.+)$/, 3]; commands['~rmlast'].regex = [/^~rmlast ([\d\w\s-]*)/, 2]; - commands['~qadd'].regex = [/^~qadd ([\d\w\s-]+?)[ ]?=[ ]?(.+)$/, 3]; + commands['~qadd'].regex = [/^~qadd ([\d\w-]+[\d\w\s-]*)[ ]?=[ ]?(.+)$/, 3]; commands['~link'].regex = [/^~link ([\d\w\s-]*)/, 2]; commands['~rmconfirm'].access = 'moderator'; From fac4cb73b13d416f9a8ffcc79a074144ee7d6ac9 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 04:00:07 -0400 Subject: [PATCH 16/28] fixing ~rq error on empty quote db --- modules/quotes/commands.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index 89fc33c..207a30d 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -187,8 +187,12 @@ var commands = function(dbot) { }, '~rq': function(event) { - var category = _.keys(quotes)[_.random(0, _.size(quotes) -1)]; - event.reply(category + ': ' + this.internalAPI.interpolatedQuote(event.server, event.channel.name, category)); + if(_.keys(quotes).length > 0) { + var category = _.keys(quotes)[_.random(0, _.size(quotes) -1)]; + event.reply(category + ': ' + this.internalAPI.interpolatedQuote(event.server, event.channel.name, category)); + } else { + event.reply(dbot.t('no_results')); + } }, '~link': function(event) { From 42de44b4defefb81f1d6c29e4bac4ec5e62978be Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 04:38:16 -0400 Subject: [PATCH 17/28] supress error on joining channel, due to dbot attempting to get info on own join --- modules/users/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/users/users.js b/modules/users/users.js index 2e6bbbb..ce11340 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -38,7 +38,7 @@ var users = function(dbot) { var knownUsers = this.getServerUsers(event.server); var nick = event.user; - if(event.action == 'JOIN') { + if(event.action == 'JOIN' && nick != dbot.config.name) { if(!_.has(knownUsers.channelUsers, event.channel.name)) { knownUsers.channelUsers[event.channel.name] = []; } From ded2f09e874053c12906da4bbe9912d108009257 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 04:42:03 -0400 Subject: [PATCH 18/28] fix error on "showconfig" with no paremeters (now shows root config) --- modules/admin/commands.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/admin/commands.js b/modules/admin/commands.js index c648760..c2e6778 100644 --- a/modules/admin/commands.js +++ b/modules/admin/commands.js @@ -23,10 +23,10 @@ var commands = function(dbot) { return false; } } - } + } var currentOption; - if(configKey.length != 1) { + if(configKey && configKey.length != 1) { configKey = _.last(configKey); if(_.has(userConfigPath, configKey) && !_.isUndefined(userConfigPath[configKey])) { currentOption = userConfigPath[configKey]; From e90572aebf7bc7250fc43fccc23faba7dd306fc2 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 06:34:33 -0400 Subject: [PATCH 19/28] adding initial support for wildcard ignores/bans --- modules/command/api.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/command/api.js b/modules/command/api.js index 51202e9..dd19b9e 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -4,8 +4,10 @@ var api = function(dbot) { return { 'isBanned': function(user, command) { var banned = false; - if(_.has(dbot.db.bans, command)) { - if(_.include(dbot.db.bans[command], user) || _.include(dbot.db.bans['*'], user)) { + if(_.has(dbot.db.bans, user)) { + if(_.include(dbot.db.bans[user], command) || + _.include(dbot.db.bans[user], dbot.commands[command].module) || + _.include(dbot.db.bans[user], '*')) { banned = true; } } @@ -39,7 +41,8 @@ var api = function(dbot) { 'isIgnoring': function(item, command) { var module = dbot.commands[command].module; return (_.has(dbot.db.ignores, item) && - _.include(dbot.db.ignores[item], module)); + (_.include(dbot.db.ignores[item], module) || + _.include(dbot.db.ignores[item], '*'))); }, /** From af3a8bf1f27419be4c9dc8220252ec63266f4ea1 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 06:39:57 -0400 Subject: [PATCH 20/28] adding support for ban/unban from ignore module, with wildcards --- modules/command/config.json | 2 +- modules/ignore/ignore.js | 62 +++++++++++++++++++++++++++++++++++++ modules/ignore/strings.json | 21 +++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/modules/command/config.json b/modules/command/config.json index f7de9b5..bace93b 100644 --- a/modules/command/config.json +++ b/modules/command/config.json @@ -1,5 +1,5 @@ { "ignorable": false, "help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md", - "dbKeys": [ "ignores" ] + "dbKeys": [ "ignores", "bans" ] } diff --git a/modules/ignore/ignore.js b/modules/ignore/ignore.js index 9fa9eac..6e8590c 100644 --- a/modules/ignore/ignore.js +++ b/modules/ignore/ignore.js @@ -72,6 +72,66 @@ var ignore = function(dbot) { } }, + '~ban': function(event) { + var user = event.params[1]; + var module = event.params[2]; + + if(_.isUndefined(user) || _.isUndefined(module)) { + event.reply(dbot.t('ban_usage', {'user': event.user})); + return; + } + + if(module == '*' || _.include(dbot.config.moduleNames, module) || _.include(dbot.commands, module)) { + if(_.has(dbot.db.bans, user) && _.include(dbot.db.bans[user], module)) { + event.reply(dbot.t('already_banned', { + 'user': event.user, + 'banned': user + })); + return; + } + + if(_.has(dbot.db.bans, event.params[1])) { + dbot.db.bans[event.params[1]].push(module); + } else { + dbot.db.bans[event.params[1]] = [module]; + } + + event.reply(dbot.t('banned_success', { + 'user': event.user, + 'banned': user, + 'module': module + })); + } else { + event.reply(dbot.t('invalid_ban', {'user': event.user})); + } + }, + + '~unban': function(event) { + var bannedModules = []; + + var user = event.params[1]; + var module = event.params[2]; + + if(_.isUndefined(user) || _.isUndefined(module)) { + event.reply(dbot.t('unban_usage', {'user': event.user})); + } else { + if(_.has(dbot.db.bans, user) && _.include(dbot.db.bans[user], module)) { + dbot.db.bans[user].splice(dbot.db.bans[user].indexOf(module), 1); + + event.reply(dbot.t('unbanned_success', { + 'user': event.user, + 'banned': user, + 'module': module + })); + } else { + event.reply(dbot.t('invalid_unban', { + 'user': event.user, + 'banned': user + })); + } + } + }, + '~ignorechannel': function(event) { var channel = ((event.params[1] == '@') ? event.channel.name : event.params[1]); var module = event.params[2]; @@ -118,6 +178,8 @@ var ignore = function(dbot) { } }; + commands['~ban'].access = 'moderator'; + commands['~unban'].access = 'moderator'; commands['~ignorechannel'].access = 'moderator'; commands['~unignorechannel'].access = 'moderator'; diff --git a/modules/ignore/strings.json b/modules/ignore/strings.json index 8202cb0..0badd2a 100644 --- a/modules/ignore/strings.json +++ b/modules/ignore/strings.json @@ -41,6 +41,27 @@ "na'vi": "{user}: Nga terìng mikyun {module}ne set", "cy": "{user}: Ddim yn anwybyddu {module} bellach" }, + "ban_usage": { + "en": "{user}: Usage: ~ban [user] [module/command]. Use * for all modules and commands." + }, + "already_banned": { + "en": "{user}: {banned} is already banned from that module." + }, + "banned_success": { + "en": "{user}: {banned} is now banned from {module}." + }, + "invalid_ban": { + "en": "{user}: That isn't a valid module name." + }, + "unban_usage": { + "en": "{user}: Usage: ~unban [user] [module]." + }, + "invalid_unban": { + "en": "{user}: {banned} is not banned from that module or it doesn't exist." + }, + "unbanned_success": { + "en": "{user}: {banned} is no longer banned from {module}." + }, "ignoring_channel": { "en": "Now ignoring {module} in {channel}", "na'vi": "Oe ke stayawm {module}ur mì {channel}" From 42361e0c0c605a97fcd0e5b4a43e12eab6c1befc Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 06:40:54 -0400 Subject: [PATCH 21/28] adding support for wildcard ~ignore and ~unignore --- modules/ignore/ignore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ignore/ignore.js b/modules/ignore/ignore.js index 6e8590c..3e3d974 100644 --- a/modules/ignore/ignore.js +++ b/modules/ignore/ignore.js @@ -24,7 +24,7 @@ var ignore = function(dbot) { 'modules': ignorableModules.join(', ') })); } else { - if(_.include(ignorableModules, module)) { + if(module == '*' || _.include(ignorableModules, module)) { if(_.has(dbot.db.ignores, event.user) && _.include(dbot.db.ignores[event.user], module)) { event.reply(dbot.t('already_ignoring', { 'user': event.user })); } else { @@ -137,7 +137,7 @@ var ignore = function(dbot) { var module = event.params[2]; // Ignoring the value of 'ignorable' at the moment - if(_.include(dbot.config.moduleNames, module)) { + if(module == '*' || _.include(dbot.config.moduleNames, module)) { if(!_.has(dbot.db.ignores, channel)) dbot.db.ignores[channel] = []; if(!_.include(dbot.db.ignores[channel], module)) { dbot.db.ignores[channel].push(module); From 415047f76599ec810425c5e7f39ec9f31dcb3eac Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 21 Mar 2013 14:47:11 +0000 Subject: [PATCH 22/28] remove ban/unban from admin [#321] --- modules/admin/commands.js | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/modules/admin/commands.js b/modules/admin/commands.js index aa6d070..0225ac5 100644 --- a/modules/admin/commands.js +++ b/modules/admin/commands.js @@ -186,32 +186,6 @@ var commands = function(dbot) { } }, - // Ban user from command or * - 'ban': function(event) { - var username = event.params[1]; - var command = event.params[2]; - - if(!_.has(dbot.db.bans, command)) { - dbot.db.bans[command] = [ ]; - } - dbot.db.bans[command].push(username); - event.reply(dbot.t('banned', {'user': username, 'command': command})); - }, - - // Unban a user from command or * - 'unban': function(event) { - var username = event.params[1]; - var command = event.params[2]; - if(_.has(dbot.db.bans, command) && _.include(dbot.db.bans[command], username)) { - _.reject(dbot.db.bans[command], function(bans) { - return bans == username; - }, this); - event.reply(dbot.t('unbanned', {'user': username, 'command': command})); - } else { - event.reply(dbot.t('unban_error', {'user': username})); - } - }, - /*** Config options ***/ 'setconfig': function(event) { @@ -304,8 +278,6 @@ var commands = function(dbot) { commands['part'].access = 'moderator'; commands['opme'].access = 'moderator'; commands['say'].access = 'moderator'; - commands['ban'].access = 'moderator'; - commands['unban'].access = 'moderator'; return commands; }; From cbe44895e89690700711d1c6909128f4a440c77b Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 21 Mar 2013 15:08:16 +0000 Subject: [PATCH 23/28] bump js --- jsbot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsbot b/jsbot index 92bc767..0a62f25 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit 92bc767b090d6bbb6691f7170c635fe366b4a8f7 +Subproject commit 0a62f255c85028ee2d2dc52f60ee45a49c140389 From 774b6673c5c4a94e01738dec26f7d9b96a2f058e Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 21 Mar 2013 17:35:21 +0000 Subject: [PATCH 24/28] what is stats? baby dont change me, dont change me, no more --- modules/stats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/stats b/modules/stats index 9660d35..e5519f3 160000 --- a/modules/stats +++ b/modules/stats @@ -1 +1 @@ -Subproject commit 9660d3500cb9aff73c355424aecc1bfc48009ed4 +Subproject commit e5519f353abf00e4ec25702f8e02231c9b1f5258 From 18227fa30ba752370bad12fdae94ba15ebcd2c84 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 14:23:14 -0400 Subject: [PATCH 25/28] adding "bans" to ignore module dbKeys --- modules/ignore/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ignore/config.json b/modules/ignore/config.json index fa1961a..14e12c2 100644 --- a/modules/ignore/config.json +++ b/modules/ignore/config.json @@ -1,6 +1,6 @@ { "ignorable": false, "dependencies": [ "command" ], - "dbKeys": [ "ignores" ], + "dbKeys": [ "ignores", "bans" ], "help": "http://github.com/reality/depressionbot/blob/master/modules/ignore/README.md" } From 3193e45a9518ab14713d6c7921e88eaade6b05a8 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Mar 2013 14:23:58 -0400 Subject: [PATCH 26/28] removing empty dbKeys from admin module config --- modules/admin/config.json | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/admin/config.json b/modules/admin/config.json index 009fb85..f87d4b9 100644 --- a/modules/admin/config.json +++ b/modules/admin/config.json @@ -1,6 +1,5 @@ { "ignorable": false, - "dbKeys": [ "bans" ], "dependencies": [ "command" ], "help": "http://github.com/reality/depressionbot/blob/master/modules/admin/README.md" } From 0bb331f87d26807a3f6ac9339b38d6b533dd2b67 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Thu, 21 Mar 2013 18:29:18 +0000 Subject: [PATCH 27/28] add basic dns function thingies --- modules/dns/README.md | 17 ++++++++++++++++ modules/dns/dns.js | 42 ++++++++++++++++++++++++++++++++++++++++ modules/dns/strings.json | 14 ++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 modules/dns/README.md create mode 100644 modules/dns/dns.js create mode 100644 modules/dns/strings.json diff --git a/modules/dns/README.md b/modules/dns/README.md new file mode 100644 index 0000000..f730352 --- /dev/null +++ b/modules/dns/README.md @@ -0,0 +1,17 @@ +## DNS + +Performs and reports upon basic DNS functions. + +### Description + +This module utilises the domain name system to discover basic information about +domain names and IP addresses. + +### Commands + +#### ~lookup [domain name] +Looks up the specified domain name in the domain name system. If a match is found, +the first corresponding A or AAAA record is displayed. +#### ~rdns [IP address] +Looks up the specified IP address in the domain name system. If a match is found, +the first corresponding rDNS domain name is displayed. diff --git a/modules/dns/dns.js b/modules/dns/dns.js new file mode 100644 index 0000000..83d5d9f --- /dev/null +++ b/modules/dns/dns.js @@ -0,0 +1,42 @@ +/** + * Module Name: DNS + * Description: Performs and reports on basic DNS functions. + */ +var dnsmod = require('dns'); + +var dns = function(dbot) { + var commands = { + '~lookup': function(event) { + domain = event.params[1]; + dnsmod.lookup(domain, function (error, addr) { + if (error) { + console.log(error); + event.reply(dbot.t("lookup-error",{"domain": domain, "code": error.code})); + } else { + event.reply(dbot.t("lookup",{"domain": domain, "address": addr})); + } + }); + }, + '~rdns': function(event) { + ip = event.params[1]; + try { + dnsmod.reverse(ip, function (error, domain) { + if (error) { + throw error; + } + event.reply(dbot.t("rdns",{"domain": domain, "ip": ip})); + }); + } catch (err) { + event.reply(dbot.t("rdns-error",{"domain": domain, "ip": ip, "error": err})); + } + } + + }; + this.commands = commands; + + this.on = 'PRIVMSG'; +}; + +exports.fetch = function(dbot) { + return new dns(dbot); +}; diff --git a/modules/dns/strings.json b/modules/dns/strings.json new file mode 100644 index 0000000..f8c69bc --- /dev/null +++ b/modules/dns/strings.json @@ -0,0 +1,14 @@ +{ + "lookup-error": { + "en": "{domain} is \u000303AVAILABLE! \u000314({code})" + }, + "lookup": { + "en": "{domain} is \u000305TAKEN! \u000314({address})" + }, + "rdns": { + "en": "{ip} \u2192 {domain}" + }, + "rdns-error": { + "en": "Unable to lookup {ip}. \u000314({error})" + } +} From 9034dbae6b89c2e8157f4755780f3846fa10d754 Mon Sep 17 00:00:00 2001 From: Sam Nicholls Date: Thu, 21 Mar 2013 18:48:06 +0000 Subject: [PATCH 28/28] Patch pushconfig critical --- modules/admin/commands.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/admin/commands.js b/modules/admin/commands.js index 0225ac5..353082b 100644 --- a/modules/admin/commands.js +++ b/modules/admin/commands.js @@ -273,6 +273,7 @@ var commands = function(dbot) { commands['load'].access = 'admin'; commands['version'].access = 'admin'; commands['setconfig'].access = 'admin'; + commands['pushconfig'].access = 'admin'; commands['showconfig'].access = 'moderator'; commands['join'].access = 'moderator'; commands['part'].access = 'moderator';