From b9b5d9913d9d656ed04e1bc56d0ca59bfde5b814 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Fri, 15 Jun 2012 10:52:11 +0100 Subject: [PATCH] Automatically replace spaces in quotes with underscores, then use that quote if the originally given quote can't be found --- modules/quotes.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/quotes.js b/modules/quotes.js index 0a044a3..5bc9bf3 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -41,8 +41,15 @@ var quotes = function(dbot) { // Retrieve quote from a category in the database. '~q': function(event) { var key = event.input[1].trim().toLowerCase(); + var altKey; + if(key.split(' ').length > 0) { + altKey = key.replace(/ /g, '_'); + } + if(quotes.hasOwnProperty(key)) { event.reply(key + ': ' + interpolatedQuote(key)); + } else if(quotes.hasOwnProperty(altKey)) { + event.reply(key + ': ' + interpolatedQuote(altKey)); } else { event.reply(dbot.t('category_not_found', {'category': key})); }