fix: restore parsing
This commit is contained in:
14
src/index.ts
14
src/index.ts
@@ -41,20 +41,24 @@ const main = async () => {
|
|||||||
if (message.envelope.subject && message.envelope.subject.includes(MARK_STRING)) {
|
if (message.envelope.subject && 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));
|
||||||
|
|
||||||
let {title, groupName, subject, user, estimatedDate, estimatedTime} = parseMessage(parsed.text)
|
let {title, groupName, subject, user, estimatedDate, estimatedTime} = parseMessage(parsed.text)
|
||||||
|
|
||||||
const estimated = (estimatedDate === undefined && estimatedTime === undefined)
|
console.log(
|
||||||
? `Время выполнения: не указано`
|
`📌 Новое обращение: ${title}`, '\n',
|
||||||
: `Время выполнения: ${estimatedDate} ${estimatedTime}`
|
`Группа: ${groupName}`, '\n',
|
||||||
|
`${user}`, '\n',
|
||||||
|
`${subject}`, '\n',
|
||||||
|
`Время выполнения: ${estimatedDate} ${estimatedTime}`, '\n'
|
||||||
|
)
|
||||||
|
|
||||||
const preparedMessage =
|
const preparedMessage =
|
||||||
`📌 Новое обращение: ${title}\n` +
|
`📌 Новое обращение: ${title}\n` +
|
||||||
`Группа: ${groupName}\n` +
|
`Группа: ${groupName}\n` +
|
||||||
`${user}\n` +
|
`${user}\n` +
|
||||||
`${subject}\n` +
|
`${subject}\n` +
|
||||||
`Время выполнения: ${estimated}\n`
|
`Время выполнения: ${estimatedDate} ${estimatedTime}\n`
|
||||||
|
|
||||||
|
|
||||||
if (preparedMessage) {
|
if (preparedMessage) {
|
||||||
bot.telegram.sendMessage(process.env.TELEGRAM_GROUP_ID, preparedMessage)
|
bot.telegram.sendMessage(process.env.TELEGRAM_GROUP_ID, preparedMessage)
|
||||||
|
|||||||
Reference in New Issue
Block a user