Skip to content

Commit

Permalink
fix: ocr
Browse files Browse the repository at this point in the history
  • Loading branch information
sdip15fa committed Mar 18, 2024
1 parent 4f131d4 commit f447530
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions commands/ocr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async function readImage(attachmentData: MessageMedia) {
}

const execute = async (client: Client, msg: Message) => {
const chatId = (await msg.getChat()).id._serialized;
if (msg.hasQuotedMsg) {
const quotedMsg = await msg.getQuotedMessage();
const attachmentData = await quotedMsg
Expand All @@ -29,11 +30,13 @@ const execute = async (client: Client, msg: Message) => {
if (!attachmentData) return;
const data = await readImage(attachmentData);
if (data == "error") {
quotedMsg.reply(
await client.sendMessage(
chatId,
`Error occured while reading the image. Please make sure the image is clear.`,
);
} else if (typeof data !== "string") {
quotedMsg.reply(
await client.sendMessage(
chatId,
`*Extracted Text from the Image* 👇\n\n${data.parsedText}`,
);
}
Expand Down

0 comments on commit f447530

Please sign in to comment.