Implement OCR

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2024-08-09 23:09:36 -05:00
parent 1406378c9f
commit 2ac0ff723b

View File

@ -206,23 +206,24 @@ function getMatchingPhrase(inputString, targetCharacter) {
}
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
checkLoop(message, checkString);
(async () => {
// Does the message have an attachment? Check the attachment with OCR
console.log(message.attachments);
message.attachments.forEach(i => {
if (i.contentType.includes("image")) {
(async () => {
const worker = await createWorker('eng');
const ret = await worker.recognize(i.proxyURL);
console.log("OCR Results: " + ret.data.text);
checkString = ret.data.text;
await worker.terminate();
})();
if (checkLoop(message, checkString)) {
return;
}
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
checkLoop(message, checkString);
}
})();
})();
}
/*