Implement OCR
This commit is contained in:
parent
1406378c9f
commit
2ac0ff723b
7
main.cjs
7
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);
|
||||
}
|
||||
})();
|
||||
|
||||
})();
|
||||
}
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user