forked from GitHub/dbot
fixed spelling module and youare
This commit is contained in:
parent
d6b56db06e
commit
4c72bd327c
@ -3,8 +3,8 @@ var spelling = function(dbot) {
|
|||||||
var dbot = dbot;
|
var dbot = dbot;
|
||||||
var last = {};
|
var last = {};
|
||||||
|
|
||||||
var correct = function (data, correction, candidate, output_callback) {
|
var correct = function (event, correction, candidate, output_callback) {
|
||||||
var rawCandidates = last[data.channel][candidate].split(' ').allGroupings();
|
var rawCandidates = last[event.channel][candidate].split(' ').allGroupings();
|
||||||
var candidates = [];
|
var candidates = [];
|
||||||
for(var i=0;i<rawCandidates.length;i++) {
|
for(var i=0;i<rawCandidates.length;i++) {
|
||||||
candidates.push(rawCandidates[i].join(' '));
|
candidates.push(rawCandidates[i].join(' '));
|
||||||
@ -22,14 +22,14 @@ var spelling = function(dbot) {
|
|||||||
|
|
||||||
if(winnerDistance < Math.ceil(winner.length * 1.33)) {
|
if(winnerDistance < Math.ceil(winner.length * 1.33)) {
|
||||||
if(winner !== correction) {
|
if(winner !== correction) {
|
||||||
var fix = last[data.channel][candidate].replace(winner, correction);
|
var fix = last[event.channel][candidate].replace(winner, correction);
|
||||||
if (/^.ACTION/.test(fix)) {
|
if (/^.ACTION/.test(fix)) {
|
||||||
fix = fix.replace(/^.ACTION/, '/me');
|
fix = fix.replace(/^.ACTION/, '/me');
|
||||||
}
|
}
|
||||||
last[data.channel][candidate] = fix;
|
last[event.channel][candidate] = fix;
|
||||||
var output = {
|
var output = {
|
||||||
'fix': fix,
|
'fix': fix,
|
||||||
'correcter': data.user,
|
'correcter': event.user,
|
||||||
'candidate': candidate
|
'candidate': candidate
|
||||||
};
|
};
|
||||||
output_callback(output);
|
output_callback(output);
|
||||||
@ -38,25 +38,25 @@ var spelling = function(dbot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'listener': function(data, params) {
|
'listener': function(event) {
|
||||||
if((dbot.db.ignores.hasOwnProperty(data.user) &&
|
if((dbot.db.ignores.hasOwnProperty(event.user) &&
|
||||||
dbot.db.ignores[data.user].include(name)) == false) {
|
dbot.db.ignores[event.user].include(name)) == false) {
|
||||||
var q = data.message.valMatch(/^(?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 3);
|
var q = event.message.valMatch(/^(?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 3);
|
||||||
var otherQ = data.message.valMatch(/^([\d\w\s]*): (?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 4);
|
var otherQ = event.message.valMatch(/^([\d\w\s]*): (?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 4);
|
||||||
if(q) {
|
if(q) {
|
||||||
correct(data, q[1] || q[2], data.user, function (e) {
|
correct(event, q[1] || q[2], event.user, function (e) {
|
||||||
dbot.say(data.channel, dbot.t('spelling_self', e));
|
event.reply(dbot.t('spelling_self', e));
|
||||||
});
|
});
|
||||||
} else if(otherQ) {
|
} else if(otherQ) {
|
||||||
correct(data, otherQ[2] || otherQ[3], otherQ[1], function (e) {
|
correct(event, otherQ[2] || otherQ[3], otherQ[1], function (e) {
|
||||||
dbot.say(data.channel, dbot.t('spelling_other', e));
|
event.reply(dbot.t('spelling_other', e));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if(last.hasOwnProperty(data.channel)) {
|
if(last.hasOwnProperty(event.channel)) {
|
||||||
last[data.channel][data.user] = data.message;
|
last[event.channel][event.user] = event.message;
|
||||||
} else {
|
} else {
|
||||||
last[data.channel] = { };
|
last[event.channel] = { };
|
||||||
last[data.channel][data.user] = data.message;
|
last[event.channel][event.user] = event.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ var youAre = function(dbot) {
|
|||||||
var name = 'youare';
|
var name = 'youare';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'listener': function(data) {
|
'listener': function(event) {
|
||||||
if((dbot.db.ignores.hasOwnProperty(data.user) &&
|
if((dbot.db.ignores.hasOwnProperty(event.user) &&
|
||||||
dbot.db.ignores[data.user].include(name)) == false) {
|
dbot.db.ignores[event.user].include(name)) == false) {
|
||||||
var key = data.message.valMatch(/(\bis\b|\bare\b)\s+([\w\s\d]*?)(\s+)?(,|\.|\band\b|$)/, 5);
|
var key = event.message.valMatch(/(\bis\b|\bare\b)\s+([\w\s\d]*?)(\s+)?(,|\.|\band\b|$)/, 5);
|
||||||
|
|
||||||
if(key && key[2] != "" && Number.prototype.chanceIn(1, 100) && data.user != 'aisbot') {
|
if(key && key[2] != "" && Number.prototype.chanceIn(1, 100) && event.user != 'aisbot') {
|
||||||
dbot.say(data.channel, data.user + ': You\'re ' + key[2] + '.');
|
event.reply(event.user + ': You\'re ' + key[2] + '.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user