mirror of
https://github.com/reality/dbot.git
synced 2024-12-18 00:22:35 +01:00
command similar check
This commit is contained in:
parent
d98c1657dc
commit
84558f13d5
37
run.js
37
run.js
@ -108,18 +108,33 @@ DBot.prototype.reloadModules = function() {
|
|||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var q = data.message.valMatch(/^~([\d\w\s-]*)/, 2);
|
// See if it's similar to anything
|
||||||
if(q) {
|
var winnerDistance = Infinity;
|
||||||
if(this.db.bans['*'].include(data.user)) {
|
var winner = false;
|
||||||
this.say(data.channel, data.user +
|
for(var commandName in dbot.commands) {
|
||||||
' is banned from using this command. Commence incineration.');
|
var distance = String.prototype.distance(params[0], commandName);
|
||||||
} else {
|
if(distance < winnerDistance) {
|
||||||
q[1] = q[1].trim();
|
winner = commandName;
|
||||||
key = this.cleanNick(q[1])
|
winnerDistance = distance;
|
||||||
if(this.db.quoteArrs.hasOwnProperty(key)) {
|
}
|
||||||
this.say(data.channel, q[1] + ': ' + this.db.quoteArrs[key].random());
|
}
|
||||||
|
|
||||||
|
if(winnerDistance < 3) {
|
||||||
|
dbot.say(data.channel, 'Did you mean ' + winner + '? Learn to type, hippie!');
|
||||||
|
} else { // See if there's anything in quotes
|
||||||
|
var q = data.message.valMatch(/^~([\d\w\s-]*)/, 2);
|
||||||
|
if(q) {
|
||||||
|
if(this.db.bans['*'].include(data.user)) {
|
||||||
|
this.say(data.channel, data.user +
|
||||||
|
' is banned from using this command. Commence incineration.');
|
||||||
} else {
|
} else {
|
||||||
this.say(data.channel, 'Nobody loves ' + q[1]);
|
q[1] = q[1].trim();
|
||||||
|
key = this.cleanNick(q[1])
|
||||||
|
if(this.db.quoteArrs.hasOwnProperty(key)) {
|
||||||
|
this.say(data.channel, q[1] + ': ' + this.db.quoteArrs[key].random());
|
||||||
|
} else {
|
||||||
|
this.say(data.channel, 'Nobody loves ' + q[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user