Fix ~quote syntax. It's a little messy.

This commit is contained in:
Luke Slater 2011-08-28 17:16:28 +01:00
parent 6b0e2de264
commit 21ff3e002b
2 changed files with 8 additions and 3 deletions

View File

@ -3,7 +3,7 @@ var quotes = function(dbot) {
var commands = { var commands = {
'~q': function(data, params) { '~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) { if(q) {
key = q[1].trim().toLowerCase(); key = q[1].trim().toLowerCase();
if(quotes.hasOwnProperty(key)) { if(quotes.hasOwnProperty(key)) {

9
run.js
View File

@ -76,9 +76,14 @@ DBot.prototype.reloadModules = function() {
this.commands[params[0]](data, params); this.commands[params[0]](data, params);
this.save(); this.save();
} else { } else {
var q = data.message.valMatch(/^~([\d\w\s]*)/, 2) var q = data.message.valMatch(/^~([\d\w\s]*)/, 2);
if(q) { 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)); }.bind(this));