This may be a bump, but it's useful:
package WordCorrector {
function loadWords() {
deleteVariables("$Pref::Server::Corrector::*");
%file = new FileObject();
%file.openForRead("./words.txt");
while( !%file.isEOF() ) {
%line = %file.readLine();
$Pref::Server::Corrector::BadWord[ $Pref::Server::Corrector::BadWords++ ] = firstWord(%line);
$Pref::Server::Corrector::CorrectWord[ $Pref::Server::Corrector::CorrectWords++ ] = restWords(%line);
}
}
function serverCmdMessageSent(%client, %txt) {
// Go ahead and send it regularly...
Parent::serverCmdMessageSent(%client, %txt);
// Loop through all of the words we wanna recognize:
for(%j = 1; %j <= $Pref::Server::Corrector::BadWords; %j++) {
%word = $Pref::Server::Corrector::BadWord[ %j ];
// Did they say this word? Let's see:
for(%i = 0; %i < getWordCount(%txt); %i++) {
if( getWord(%txt, %i) $= %word ) {
// They said something we recognized...
%client.hasSaid[ %word ]++;
//******************
// What to do if they've said that word more than once?
if( %client.hasSaid[ %word ] > 1 ) {
%correctWord = $Pref::Server::Corrector::CorrectWord[ %j ];
messageClient(%client, '', '\c2Do you mean, \c3%1\c2?', %correctWord);
}
//******************
}
}
}
}
};
activatePackage(WordCorrector);
For example, in words.txt you have:
plausable plausible
yuo you
loel lol
If you say 'plausable' more than once, it tells you:
Did you mean, 'plausible'?
(Nothing happens if you respond... this is just a demo to show how to check words in peoples' messages.)