From 2ac0ff723b0bc176ddf1a83f06004fe63ef1e48f Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Fri, 9 Aug 2024 23:09:36 -0500 Subject: [PATCH] Implement OCR --- main.cjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.cjs b/main.cjs index a845787..1b4362e 100644 --- a/main.cjs +++ b/main.cjs @@ -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")) { - const worker = await createWorker('eng'); + (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); } - })(); + })(); } /*