From 84bd092bae543f8e02eff4e4bfd645ee949bc7b3 Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 17 May 2013 07:04:57 +0000 Subject: [PATCH 1/2] Fix [#442] --- modules/quotes/config.json | 1 + modules/quotes/quotes.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/quotes/config.json b/modules/quotes/config.json index e8d0465..8fbb17a 100644 --- a/modules/quotes/config.json +++ b/modules/quotes/config.json @@ -3,5 +3,6 @@ "dependencies": [ "command", "users" ], "rmLimit": 10, "ignorable": true, + "quotesOnJoin": false, "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 f616a84..2305568 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -112,11 +112,13 @@ var quotes = function(dbot) { event.action = 'PRIVMSG'; event.params = event.message.split(' '); dbot.instance.emit(event); - } + } } else if(event.action == 'JOIN') { - var userQuote = this.api.getQuote(event, event.user) - if(userQuote) { - event.reply(event.user + ': ' + this.api.getQuote(event, event.user)); + if(this.config.quotesOnJoin == true) { + var userQuote = this.api.getQuote(event, event.user) + if(userQuote) { + event.reply(event.user + ': ' + this.api.getQuote(event, event.user)); + } } } }.bind(this); From be23d97293e5cffb42d676122529a5100d0d848e Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 17 May 2013 07:35:21 +0000 Subject: [PATCH 2/2] [ --- config.json.sample | 1 + modules/command/commands.js | 45 +++++++++++++----------------------- modules/command/strings.json | 6 ++--- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/config.json.sample b/config.json.sample index bd5e443..79cc137 100644 --- a/config.json.sample +++ b/config.json.sample @@ -17,5 +17,6 @@ "language": "en", "debugMode": false, "debugLevel": 1, + "repoRoot": "https://github.com/reality/depressionbot/", "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)." } diff --git a/modules/command/commands.js b/modules/command/commands.js index 68d7a28..5f5e079 100644 --- a/modules/command/commands.js +++ b/modules/command/commands.js @@ -1,4 +1,5 @@ -var _ = require('underscore')._; +var _ = require('underscore')._, + request = require('request'); var commands = function(dbot) { return { @@ -18,41 +19,27 @@ 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'); - }); - + if(!moduleName || !_.has(dbot.modules, moduleName)) { event.reply(dbot.t('usage', { 'command': '~help', 'usage': '~help [module]' })); - event.reply(dbot.t('loaded_modules_with_help', { - 'modules': helpfulModules.join(', ') - })); - return; - } - - if(!_.has(dbot.modules, moduleName)) { - if(_.has(dbot.commands, moduleName)) { - var moduleName = dbot.commands[moduleName].module; - } else { - var moduleName = undefined; - } - } - - if(moduleName && _.has(dbot.config[moduleName], 'help')) { - var help = dbot.config[moduleName].help; - event.reply(dbot.t('help_link', { - 'module': moduleName, - 'link': help + event.reply(dbot.t('loaded_modules', { + 'modules': _.keys(dbot.modules).join(', ') })); } else { - if(!moduleName) { - moduleName = event.params[1]; + var helpLink = dbot.config.repoRoot + + 'blob/master/modules/' + moduleName + '/README.md'; + if(dbot.config[moduleName].help) { + helpLink = dbot.config[moduleName].help; } - event.reply(dbot.t('no_help', { 'module': moduleName })) - } + + // TODO: Check it exists + event.reply(dbot.t('help_link', { + 'module': moduleName, + 'link': helpLink + })); + } } }; }; diff --git a/modules/command/strings.json b/modules/command/strings.json index c20652e..d13553a 100644 --- a/modules/command/strings.json +++ b/modules/command/strings.json @@ -33,8 +33,8 @@ "na'vi": "Fì{module}ìri oel ke tsun run srungit", "nl": "Geen hulp gevonden voor {module}." }, - "loaded_modules_with_help": { - "en": "Loaded modules with help information: {modules}.", - "nl": "Geladen modules die hulpinformatie bevatten: {modules}." + "loaded_modules": { + "en": "Loaded modules: {modules}.", + "nl": "Geladen modules: {modules}." } }