From 21ff3e002b24693a675c6a8b3fb57bf1eb143f26 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Sun, 28 Aug 2011 17:16:28 +0100 Subject: [PATCH] Fix ~quote syntax. It's a little messy. --- modules/quotes.js | 2 +- run.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/quotes.js b/modules/quotes.js index f4465d6..9d6af82 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -3,7 +3,7 @@ var quotes = function(dbot) { var commands = { '~q': function(data, params) { - var q = data.message.valMatch(/^~q ([\d\w\s]*)/, 2) + var q = data.message.valMatch(/^~q ([\d\w\s]*)/, 2); if(q) { key = q[1].trim().toLowerCase(); if(quotes.hasOwnProperty(key)) { diff --git a/run.js b/run.js index 80fa5b3..8ee5b7f 100644 --- a/run.js +++ b/run.js @@ -76,9 +76,14 @@ DBot.prototype.reloadModules = function() { this.commands[params[0]](data, params); this.save(); } else { - var q = data.message.valMatch(/^~([\d\w\s]*)/, 2) + var q = data.message.valMatch(/^~([\d\w\s]*)/, 2); if(q) { - this.say(data.channel, this.quotes.get(q[1].trim())); + key = q[1].trim().toLowerCase(); + if(this.db.quoteArrs.hasOwnProperty(key)) { + this.say(data.channel, key + ': ' + this.db.quoteArrs[key].random()); + } else { + this.say(data.channel, 'No quotes under ' + key); + } } } }.bind(this));