From 1406378c9f57e670ddd841bbc3a55cd8ef929b7f Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Fri, 9 Aug 2024 23:08:51 -0500 Subject: [PATCH] Implement OCR --- main.cjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.cjs b/main.cjs index 703b8f9..a845787 100644 --- a/main.cjs +++ b/main.cjs @@ -198,7 +198,7 @@ function getMatchingPhrase(inputString, targetCharacter) { message.delete(); return true; } - }); + })(); return false; } if (checkLoop(message, checkString)) { @@ -209,9 +209,10 @@ function getMatchingPhrase(inputString, targetCharacter) { (async () => { // Does the message have an attachment? Check the attachment with OCR console.log(message.attachments); - if (message.attachments.contentType.includes("image")) { + message.attachments.forEach(i => { + if (i.contentType.includes("image")) { const worker = await createWorker('eng'); - const ret = await worker.recognize(message.attachments.proxyURL); + const ret = await worker.recognize(i.proxyURL); console.log("OCR Results: " + ret.data.text); checkString = ret.data.text; await worker.terminate(); @@ -221,6 +222,7 @@ function getMatchingPhrase(inputString, targetCharacter) { checkString = checkString.replace(/[^a-zA-Z0-9]/g, ''); checkLoop(message, checkString); } + })(); })(); } /*