From 78fa61c3d3ba3888b44cf00eba935c25892c05d9 Mon Sep 17 00:00:00 2001 From: RedRock Date: Tue, 21 May 2024 21:37:47 +0300 Subject: [PATCH] fix: add estimated date and time check --- src/index.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 581c2c7..e543a97 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,24 +41,17 @@ const main = async () => { if (message.envelope.subject && 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)); let {title, groupName, subject, user, estimatedDate, estimatedTime} = parseMessage(parsed.text) - console.log( - `📌 Новое обращение: ${title}`, '\n', - `Группа: ${groupName}`, '\n', - `${user}`, '\n', - `${subject}`, '\n', - `Время выполнения: ${estimatedDate} ${estimatedTime}`, '\n' - ) - const preparedMessage = `📌 Новое обращение: ${title}\n` + `Группа: ${groupName}\n` + `${user}\n` + `${subject}\n` + - `Время выполнения: ${estimatedDate} ${estimatedTime}\n` + (estimatedDate && estimatedTime) + ? `Время выполнения: ${estimatedDate} ${estimatedTime}\n` + : 'Время выполнения: не указано' if (preparedMessage) { bot.telegram.sendMessage(process.env.TELEGRAM_GROUP_ID, preparedMessage)