3
0
mirror of https://github.com/reality/dbot.git synced 2025-01-13 05:32:36 +01:00

not in all messages..

This commit is contained in:
Luke Slater 2012-02-15 20:39:11 +00:00
parent e1047362a2
commit f3e31925af

28
run.js
View File

@ -108,22 +108,22 @@ DBot.prototype.reloadModules = function() {
this.save(); this.save();
} }
} else { } else {
// See if it's similar to anything var q = data.message.valMatch(/^~([\d\w\s-]*)/, 2);
var winnerDistance = Infinity; if(q) {
var winner = false; // See if it's similar to anything
for(var commandName in this.commands) { var winnerDistance = Infinity;
var distance = String.prototype.distance(params[0], commandName); var winner = false;
if(distance < winnerDistance) { for(var commandName in this.commands) {
winner = commandName; var distance = String.prototype.distance(params[0], commandName);
winnerDistance = distance; if(distance < winnerDistance) {
winner = commandName;
winnerDistance = distance;
}
} }
}
if(winnerDistance < 3) { if(winnerDistance < 3) {
this.say(data.channel, 'Did you mean ' + winner + '? Learn to type, hippie!'); this.say(data.channel, 'Did you mean ' + winner + '? Learn to type, hippie!');
} else { // See if there's anything in quotes } 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)) { if(this.db.bans['*'].include(data.user)) {
this.say(data.channel, data.user + this.say(data.channel, data.user +
' is banned from using this command. Commence incineration.'); ' is banned from using this command. Commence incineration.');