fix: update settings #9
10
src/index.ts
10
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)
|
||||
|
||||
Reference in New Issue
Block a user