From 24a955b2ab6939c84029c6803a2a2351c2895230 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 17 Mar 2013 19:55:47 +0000 Subject: [PATCH 01/40] remove broken finger functionality --- modules/finger/README.md | 13 ------------- modules/finger/finger.js | 34 ---------------------------------- modules/finger/strings.json | 8 -------- 3 files changed, 55 deletions(-) delete mode 100644 modules/finger/README.md delete mode 100644 modules/finger/finger.js delete mode 100644 modules/finger/strings.json diff --git a/modules/finger/README.md b/modules/finger/README.md deleted file mode 100644 index 549e850..0000000 --- a/modules/finger/README.md +++ /dev/null @@ -1,13 +0,0 @@ -## Finger - -Retrieves user information from a remote server. - -### Description -Uses the ``finger`` command to retrieve limited information on users. - - -### Commands -###~finger [username] -Returns the real name of the user specified. -### Dependencies -* ``npm install request`` diff --git a/modules/finger/finger.js b/modules/finger/finger.js deleted file mode 100644 index f0a2e34..0000000 --- a/modules/finger/finger.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Module Name: Finger - * Description: Returns the name of users via the Finger protocol - */ -var request = require('request'), - _ = require('underscore')._, - exec = require('child_process').exec; - -var finger = function(dbot) { - var commands = { - '~finger': function(event) { - var username = event.params[1]; - exec("finger -s " + username + "@central.aber.ac.uk",function(error,stdout,stderr){ - stdout = stdout.replace(/(\r\n|\n|\r)/gm,""); - name = stdout.search("Name:"); - stdout = stdout.substring(name); - ret = stdout.search("Dir"); - stdout = stdout.substring(6,ret); - if (stdout == "Welcom") { - event.reply(dbot.t("nonexistent",{user: username})); - } else { - event.reply(dbot.t("name",{user: username, name: stdout})); - } - }); - } - }; - this.commands = commands; - - this.on = 'PRIVMSG'; -}; - -exports.fetch = function(dbot) { - return new finger(dbot); -}; diff --git a/modules/finger/strings.json b/modules/finger/strings.json deleted file mode 100644 index 710e0f5..0000000 --- a/modules/finger/strings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": { - "en": "{user} is {name}." - }, - "nonexistent": { - "en": "{user} not found." - } -} From a77a569333dfc9bd94960362659975170e3bcc81 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 18 Mar 2013 00:17:04 +0000 Subject: [PATCH 02/40] bum stats again --- modules/stats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/stats b/modules/stats index eee5861..9660d35 160000 --- a/modules/stats +++ b/modules/stats @@ -1 +1 @@ -Subproject commit eee5861dca00f0d2b2f146820870abb888ed8f4a +Subproject commit 9660d3500cb9aff73c355424aecc1bfc48009ed4 From 133f04462e97c1fd7ab8cd89b4ce061168442b61 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 18 Mar 2013 22:49:34 +0000 Subject: [PATCH 03/40] bump jsbot with ssl support --- jsbot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsbot b/jsbot index ba70bf1..01d33a2 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit ba70bf1b9d8d7459dbcfa05a39b47de63a024494 +Subproject commit 01d33a25689a8d93f20234d4289ef16d58642f6b From 1ab10dcb042d68c22dbdc3a9bbcef4ebae442eb7 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Mon, 18 Mar 2013 21:50:10 -0400 Subject: [PATCH 04/40] adding trim to link titles to remove annoying whitespace --- modules/link/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/link/link.js b/modules/link/link.js index 2d9c994..e07c178 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -16,7 +16,7 @@ var link = function(dbot) { body = body.replace(/(\r\n|\n\r|\n)/gm, " "); var title = body.valMatch(/(.*)<\/title>/, 2); if(title && title.length < 140) { - event.reply(ent.decode(title[1])); + event.reply(ent.decode(title[1]).trim()); } } }); From 23c20f09371c9da2141741a23ae7e1c46d609265 Mon Sep 17 00:00:00 2001 From: John Maguire <jmaguire2013@gmail.com> Date: Mon, 18 Mar 2013 21:53:08 -0400 Subject: [PATCH 05/40] adding link to default modules --- config.json.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json.sample b/config.json.sample index 1f1501e..be6de54 100644 --- a/config.json.sample +++ b/config.json.sample @@ -13,7 +13,7 @@ }, "admins": [ "batman" ], "moderators": [ "whatever" ], - "moduleNames": [ "ignore", "admin", "command", "dice", "js", "kick", "quotes", "spelling", "youare", "stats", "users" ], + "moduleNames": [ "ignore", "admin", "command", "dice", "js", "kick", "quotes", "spelling", "youare", "stats", "users", "link" ], "language": "en", "debugMode": true, "version": "Depressionbot IRC bot 0.4-dev - Lovingly crafted by The DepressionBot Foundation (a charity arm of the Official Aberystwyth Open Source International Development League)." From 6e727ed9d8f05419c46688933a12b0738cca99ee Mon Sep 17 00:00:00 2001 From: John Maguire <jmaguire2013@gmail.com> Date: Mon, 18 Mar 2013 22:33:15 -0400 Subject: [PATCH 06/40] 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 ad196eb86563a8afbd0baccebf85cca8ade967dd Mon Sep 17 00:00:00 2001 From: reality <tinmachin3@gmail.com> Date: Tue, 19 Mar 2013 02:41:20 +0000 Subject: [PATCH 07/40] bump github --- modules/github | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/github b/modules/github index 93337f4..e9e9089 160000 --- a/modules/github +++ b/modules/github @@ -1 +1 @@ -Subproject commit 93337f4ddf6b9cfa28f2972b4ac893b672d3227e +Subproject commit e9e9089f282b0455a481460ebec17a4672617ceb From a2aef2cf005e1a2fd33da49bd650045a785bbc27 Mon Sep 17 00:00:00 2001 From: John Maguire <jmaguire2013@gmail.com> Date: Mon, 18 Mar 2013 22:50:59 -0400 Subject: [PATCH 08/40] 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 <tinmachin3@gmail.com> Date: Tue, 19 Mar 2013 03:04:12 +0000 Subject: [PATCH 09/40] 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 <jmaguire2013@gmail.com> Date: Tue, 19 Mar 2013 01:16:26 -0400 Subject: [PATCH 10/40] 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 <jmaguire2013@gmail.com> Date: Wed, 20 Mar 2013 17:47:01 -0400 Subject: [PATCH 11/40] 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 <jmaguire2013@gmail.com> Date: Wed, 20 Mar 2013 18:18:06 -0400 Subject: [PATCH 12/40] 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 <jmaguire2013@gmail.com> Date: Wed, 20 Mar 2013 19:34:43 -0400 Subject: [PATCH 13/40] 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 <jmaguire2013@gmail.com> Date: Wed, 20 Mar 2013 19:34:55 -0400 Subject: [PATCH 14/40] 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 <sam.n@studio8media.co.uk> Date: Thu, 21 Mar 2013 00:05:35 +0000 Subject: [PATCH 15/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 01:53:11 -0400 Subject: [PATCH 16/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 02:07:49 -0400 Subject: [PATCH 17/40] 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<aliases.length;i++) { - including += aliases[i] + ', '; - } - including = including.slice(0, -2) + '.'; - + var including = 'including: ' + aliases.join(', ') + '.'; + event.reply(dbot.t('primary', { 'user': alias, 'count': aliasCount @@ -26,7 +22,7 @@ var commands = function(dbot) { event.reply(dbot.t('primary', { 'user': alias, 'count': aliasCount - })); + }).slice(0, -2) + "."); } } else if(_.has(knownUsers.aliases, alias)) { event.reply(dbot.t('alias', { From d87000f78d011fbb4547912e958fa80f43882e1d Mon Sep 17 00:00:00 2001 From: John Maguire <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 02:58:40 -0400 Subject: [PATCH 18/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 03:41:27 -0400 Subject: [PATCH 19/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 03:41:53 -0400 Subject: [PATCH 20/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 03:42:13 -0400 Subject: [PATCH 21/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 04:00:07 -0400 Subject: [PATCH 22/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 04:38:16 -0400 Subject: [PATCH 23/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 04:42:03 -0400 Subject: [PATCH 24/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 06:34:33 -0400 Subject: [PATCH 25/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 06:39:57 -0400 Subject: [PATCH 26/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 06:40:54 -0400 Subject: [PATCH 27/40] 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 <tinmachin3@gmail.com> Date: Thu, 21 Mar 2013 14:47:11 +0000 Subject: [PATCH 28/40] 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 <tinmachin3@gmail.com> Date: Thu, 21 Mar 2013 15:08:16 +0000 Subject: [PATCH 29/40] 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 <tinmachin3@gmail.com> Date: Thu, 21 Mar 2013 17:35:21 +0000 Subject: [PATCH 30/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 14:23:14 -0400 Subject: [PATCH 31/40] 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 <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 14:23:58 -0400 Subject: [PATCH 32/40] 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 <douglas@chippy.ch> Date: Thu, 21 Mar 2013 18:29:18 +0000 Subject: [PATCH 33/40] 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 <sam.n@studio8media.co.uk> Date: Thu, 21 Mar 2013 18:48:06 +0000 Subject: [PATCH 34/40] 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'; From eea66430288b972e43b7b65f73b3f3a3e5c6568c Mon Sep 17 00:00:00 2001 From: John Maguire <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 15:08:48 -0400 Subject: [PATCH 35/40] adding forgotten usage file for ~help and ~usage --- modules/command/usage.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 modules/command/usage.json diff --git a/modules/command/usage.json b/modules/command/usage.json new file mode 100644 index 0000000..8aaf80e --- /dev/null +++ b/modules/command/usage.json @@ -0,0 +1,4 @@ +{ + "~usage": "~usage [command]", + "~help": "~help [module]" +} From eff41ee844f75f9e1e320d3675c68e4365a42628 Mon Sep 17 00:00:00 2001 From: John Maguire <jmaguire2013@gmail.com> Date: Thu, 21 Mar 2013 15:58:33 -0400 Subject: [PATCH 36/40] use new JSBot.parse() NICK action variables. --- modules/users/users.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/users/users.js b/modules/users/users.js index ce11340..a12493a 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -55,9 +55,7 @@ var users = function(dbot) { channelUsers.push(nick); } } else if(event.action == 'NICK') { - // 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); + var newNick = event.newNick; 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 8d7962acc8146735a44b793733031d433c910cbe Mon Sep 17 00:00:00 2001 From: Luke Slater <tinmachin3@gmail.com> Date: Fri, 22 Mar 2013 10:48:36 +0000 Subject: [PATCH 37/40] change module names each loop in module loader to use underscore each --- modules/web/config.json | 3 +-- run.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/web/config.json b/modules/web/config.json index 47a0b3a..981e0f7 100644 --- a/modules/web/config.json +++ b/modules/web/config.json @@ -1,5 +1,4 @@ { - "ignorable": false, "webHost": "localhost", - "webPort": 9001 + "webPort": 8080 } diff --git a/run.js b/run.js index fadc12b..76c1bd1 100644 --- a/run.js +++ b/run.js @@ -153,7 +153,7 @@ DBot.prototype.reloadModules = function() { this.instance.removeListeners(); - moduleNames.each(function(name) { + _.each(moduleNames, function(name) { var moduleDir = './modules/' + name + '/'; var cacheKey = require.resolve(moduleDir + name); delete require.cache[cacheKey]; From 84c311ee41099606491a6bec81d7a5f4633cbacb Mon Sep 17 00:00:00 2001 From: reality <tinmachin3@gmail.com> Date: Fri, 22 Mar 2013 10:58:40 +0000 Subject: [PATCH 38/40] Stop [#326] happening again in the admin module by applying admin to all commands by default --- modules/admin/commands.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/admin/commands.js b/modules/admin/commands.js index 353082b..b272d8f 100644 --- a/modules/admin/commands.js +++ b/modules/admin/commands.js @@ -267,13 +267,10 @@ var commands = function(dbot) { } }; - commands['greload'].access = 'admin'; - commands['reload'].access = 'admin'; - commands['unload'].access = 'admin'; - commands['load'].access = 'admin'; - commands['version'].access = 'admin'; - commands['setconfig'].access = 'admin'; - commands['pushconfig'].access = 'admin'; + _.each(commands, function(command) { + command.access = 'admin'; + }); + commands['showconfig'].access = 'moderator'; commands['join'].access = 'moderator'; commands['part'].access = 'moderator'; From 3ac1c8189f214dcfda058f3bf0ca512f4bf1af90 Mon Sep 17 00:00:00 2001 From: reality <tinmachin3@gmail.com> Date: Fri, 22 Mar 2013 11:18:06 +0000 Subject: [PATCH 39/40] bump jsbot --- jsbot | 2 +- modules/stats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jsbot b/jsbot index 01d33a2..217d7c8 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit 01d33a25689a8d93f20234d4289ef16d58642f6b +Subproject commit 217d7c8f865e9097b06df3d6a3a58e544e79ac8e 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 57dcc0daf16324a188f5ee9c6035d0655849de24 Mon Sep 17 00:00:00 2001 From: Douglas Gardner <douglas@chippy.ch> Date: Fri, 22 Mar 2013 15:39:29 +0000 Subject: [PATCH 40/40] remove try catch in favour of boring if(error){} --- modules/dns/dns.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/dns/dns.js b/modules/dns/dns.js index 83d5d9f..e061d83 100644 --- a/modules/dns/dns.js +++ b/modules/dns/dns.js @@ -10,7 +10,6 @@ var dns = function(dbot) { 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})); @@ -19,18 +18,14 @@ var dns = function(dbot) { }, '~rdns': function(event) { ip = event.params[1]; - try { - dnsmod.reverse(ip, function (error, domain) { - if (error) { - throw error; - } + dnsmod.reverse(ip, function (error, domain) { + if (error) { + event.reply(dbot.t("rdns-error",{"domain": domain, "ip": ip, "error": error.code})); + } else { 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;