From dd4d14c1000d0dfe43f97f22351e14b120c822a4 Mon Sep 17 00:00:00 2001 From: RedRock Date: Thu, 16 May 2024 11:21:15 +0300 Subject: [PATCH] fix: update settings --- src/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1828834..4908444 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ require('dotenv').config() const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN); -const POLLING_TIMEOUT = 30 +const POLLING_TIMEOUT = process.env.POLLING_TIMEOUT const MARK_STRING = process.env.MARK_STRING @@ -36,7 +36,7 @@ const main = async () => { source: true })) { - if (message.envelope.subject === MARK_STRING) { + if (message.envelope.subject.includes(MARK_STRING)) { let email = Buffer.from(message.source).toString() const parsed = await simpleParser(email) console.log('📌', chalk.cyan('Message:'), chalk.yellow(parsed.text)); @@ -49,7 +49,7 @@ const main = async () => { client.messageFlagsAdd(message.seq.toString(), ['\\Seen']) .then((result: any) => console.log('📌', chalk.cyan(`Set seen flag for id-${message.seq}`), result)) - .catch((error: any) => console.log(error)) + .catch(console.error) } } @@ -65,5 +65,5 @@ const main = async () => { //main().then().catch(err => console.error(err)); // start once for development setInterval(async () => { - main().then().catch(err => console.error(err)); -}, POLLING_TIMEOUT * 1000) + main().then().catch(console.error); +}, Number(POLLING_TIMEOUT) * 1000) -- 2.49.1