lower-case all quote keys

This commit is contained in:
Luke Slater 2011-08-24 16:15:56 +01:00
parent 3a36ee1894
commit d17ee73393

View File

@ -3,6 +3,7 @@ var quotes = function(dbot) {
return { return {
get: function(key) { get: function(key) {
key = key.toLowerCase();
if(quotes.hasOwnProperty(key)) { if(quotes.hasOwnProperty(key)) {
return key + ': ' + quotes[key].random(); return key + ': ' + quotes[key].random();
} else { } else {
@ -11,6 +12,7 @@ var quotes = function(dbot) {
}, },
count: function(key) { count: function(key) {
key = key.toLowerCase();
if(quotes.hasOwnProperty(key)) { if(quotes.hasOwnProperty(key)) {
return key + ' has ' + quotes[key].length + ' quotes.'; return key + ' has ' + quotes[key].length + ' quotes.';
} else { } else {
@ -19,6 +21,7 @@ var quotes = function(dbot) {
}, },
add: function(key) { add: function(key) {
key[1] = key[1].toLowerCase();
if(!Object.isArray(quotes[key[1]])) { if(!Object.isArray(quotes[key[1]])) {
quotes[key[1]] = []; quotes[key[1]] = [];
} }
@ -27,6 +30,7 @@ var quotes = function(dbot) {
}, },
set: function(key) { set: function(key) {
key[1] = key[1].toLowerCase();
if(!quotes.hasOwnProperty(key[1]) || (quotes.hasOwnProperty(key[1]) && quotes[key[1]].length == 1)) { if(!quotes.hasOwnProperty(key[1]) || (quotes.hasOwnProperty(key[1]) && quotes[key[1]].length == 1)) {
quotes[key[1]] = [key[2]]; quotes[key[1]] = [key[2]];
return 'Quote saved as ' + key[1]; return 'Quote saved as ' + key[1];