forked from GitHub/dbot
User commands use valMatch
This commit is contained in:
parent
eeb59bae4b
commit
3989cf277b
@ -8,33 +8,34 @@ var userCommands = function(dbot) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'~q': function(data, params) {
|
'~q': function(data, params) {
|
||||||
var q = data.message.match(/^~q ([\d\w\s]*)/)
|
var q = data.message.valMatch(/^~q ([\d\w\s]*)/, 2)
|
||||||
if(q != undefined) {
|
if(q) {
|
||||||
dbot.say(data.channel, dbot.quotes.get(q[1].trim()));
|
dbot.say(data.channel, dbot.quotes.get(q[1].trim()));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'~qadd': function(data, params) {
|
'~qadd': function(data, params) {
|
||||||
var q = data.message.match(/^~qadd ([\d\w\s]*)=(.+)$/);
|
var q = data.message.valMatch(/^~qadd ([\d\w\s]*)=(.+)$/, 3);
|
||||||
if(q != null && q.length >= 3) {
|
if(q) {
|
||||||
dbot.say(data.channel, dbot.quotes.add(q));
|
dbot.say(data.channel, dbot.quotes.add(q));
|
||||||
dbot.save();
|
|
||||||
} else {
|
} else {
|
||||||
dbot.say(data.channel, 'Burn the invalid syntax!');
|
dbot.say(data.channel, 'Burn the invalid syntax!');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'~qset': function(data, params) {
|
'~qset': function(data, params) {
|
||||||
var q = data.message.match(/^~qset ([\d\w\s]*)=(.+)$/);
|
var q = data.message.match(/^~qset ([\d\w\s]*)=(.+)$/, 3);
|
||||||
if(q != undefined && q.length >= 3) {
|
if(q) {
|
||||||
dbot.say(data.channel, dbot.quotes.set(q));
|
dbot.say(data.channel, dbot.quotes.set(q));
|
||||||
|
} else {
|
||||||
|
dbot.say(data.channel, 'Burn the invalid syntax!');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'~qcount': function(data, params) {
|
'~qcount': function(data, params) {
|
||||||
var q = data.message.match(/^~qcount ([\d\w\s]*)/)[1].trim();
|
var q = data.message.valMatch(/^~qcount ([\d\w\s]*)/, 2);
|
||||||
if(q != undefined) {
|
if(q) {
|
||||||
dbot.say(data.channel, dbot.quotes.count(q));
|
dbot.say(data.channel, dbot.quotes.count(q[1].trim()));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -66,9 +67,10 @@ var userCommands = function(dbot) {
|
|||||||
|
|
||||||
if(commands.hasOwnProperty(params[0])) {
|
if(commands.hasOwnProperty(params[0])) {
|
||||||
commands[params[0]](data, params);
|
commands[params[0]](data, params);
|
||||||
|
dbot.save();
|
||||||
} else {
|
} else {
|
||||||
var q = data.message.match(/^~([\d\w\s]*)/)
|
var q = data.message.valMatch(/^~([\d\w\s]*)/, 2)
|
||||||
if(q != undefined) {
|
if(q) {
|
||||||
dbot.say(data.channel, dbot.quotes.get(q[1].trim()));
|
dbot.say(data.channel, dbot.quotes.get(q[1].trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user