fix error on ~link when web is misconfigured/not loaded

This commit is contained in:
John Maguire 2013-03-21 03:41:27 -04:00
parent 8d8cf2bd9a
commit 4a8e5d0cc0
2 changed files with 16 additions and 8 deletions

View File

@ -194,6 +194,8 @@ var commands = function(dbot) {
'~link': function(event) { '~link': function(event) {
var key = event.input[1].toLowerCase(); var key = event.input[1].toLowerCase();
if(_.has(quotes, key)) { if(_.has(quotes, key)) {
if(_.has(dbot.config, 'web') && _.has(dbot.config.web, 'webHost') &&
_.has(dbot.config.web, 'webPort')) {
event.reply(dbot.t('quote_link', { event.reply(dbot.t('quote_link', {
'category': key, 'category': key,
'url': dbot.t('url', { 'url': dbot.t('url', {
@ -202,6 +204,9 @@ var commands = function(dbot) {
'path': 'quotes/' + encodeURIComponent(key) 'path': 'quotes/' + encodeURIComponent(key)
}) })
})); }));
} else {
event.reply(dbot.t('web_not_configured'));
}
} else { } else {
event.reply(dbot.t('category_not_found', { 'category': key })); event.reply(dbot.t('category_not_found', { 'category': key }));
} }

View File

@ -126,5 +126,8 @@
"rm_cache_limit": { "rm_cache_limit": {
"en": "Attention: Too many quotes removed, rmCache must be cleared or reinstated manually with ~rmconfirm or ~rmdeny.", "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." "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."
} }
} }