fix: update settings
This commit is contained in:
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 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)
|
||||||
|
|||||||
Reference in New Issue
Block a user