fix: update settings #9

Merged
redrockjs merged 1 commits from dev into main 2024-05-16 08:23:21 +00:00
Showing only changes of commit dd4d14c100 - Show all commits

View File

@@ -7,7 +7,7 @@ require('dotenv').config()
const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN); 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 const MARK_STRING = process.env.MARK_STRING
@@ -36,7 +36,7 @@ const main = async () => {
source: true source: true
})) { })) {
if (message.envelope.subject === MARK_STRING) { if (message.envelope.subject.includes(MARK_STRING)) {
let email = Buffer.from(message.source).toString() let email = Buffer.from(message.source).toString()
const parsed = await simpleParser(email) const parsed = await simpleParser(email)
console.log('📌', chalk.cyan('Message:'), chalk.yellow(parsed.text)); console.log('📌', chalk.cyan('Message:'), chalk.yellow(parsed.text));
@@ -49,7 +49,7 @@ const main = async () => {
client.messageFlagsAdd(message.seq.toString(), ['\\Seen']) client.messageFlagsAdd(message.seq.toString(), ['\\Seen'])
.then((result: any) => console.log('📌', chalk.cyan(`Set seen flag for id-${message.seq}`), result)) .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 //main().then().catch(err => console.error(err)); // start once for development
setInterval(async () => { setInterval(async () => {
main().then().catch(err => console.error(err)); main().then().catch(console.error);
}, POLLING_TIMEOUT * 1000) }, Number(POLLING_TIMEOUT) * 1000)