Implement OCR
This commit is contained in:
parent
4aa533ad71
commit
65476f2bde
24
main.cjs
24
main.cjs
@ -212,19 +212,19 @@ function getMatchingPhrase(inputString, targetCharacter) {
|
|||||||
if (i.contentType.includes("image")) {
|
if (i.contentType.includes("image")) {
|
||||||
(async () => {
|
(async () => {
|
||||||
const worker = await createWorker('eng');
|
const worker = await createWorker('eng');
|
||||||
const ret = await worker.recognize(i.proxyURL);
|
const ret = await worker.recognize(i.proxyURL);
|
||||||
console.log("OCR Results: " + ret.data.text);
|
console.log("OCR Results: " + ret.data.text);
|
||||||
checkString = ret.data.text;
|
checkString = ret.data.text;
|
||||||
await worker.terminate();
|
await worker.terminate();
|
||||||
console.log("Checking OCR contents...");
|
console.log("Checking OCR contents...");
|
||||||
if (checkLoop(message, checkString)) {
|
if (checkLoop(message, checkString)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
|
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
|
||||||
checkLoop(message, checkString);
|
checkLoop(message, checkString);
|
||||||
}
|
})();
|
||||||
})();
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Main bot logic. Check for abbreviations by splitting the message at any non-word characters, then if we find a match, create a new array, replace the abbreviation with the phrase, then call replyMessage() and reply to the original message with the corrected one.
|
Main bot logic. Check for abbreviations by splitting the message at any non-word characters, then if we find a match, create a new array, replace the abbreviation with the phrase, then call replyMessage() and reply to the original message with the corrected one.
|
||||||
|
Loading…
Reference in New Issue
Block a user