Files
request-bot/src/lib.ts
2024-05-16 23:35:24 +03:00

42 lines
782 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export function parseMessage(message: string) {
let messageArr = message.slice().split('\n').filter((el: string) => el !== '')
const title =
messageArr[1]
.slice()
.split(' ')
.at(-1)
const groupName =
messageArr[1]
.slice()
.replace('В АС СТП на Вашу группу Адлер ', '')
.replace(' назначено обращение', '')
.split(' ')
.slice(0, -1)
.join(' ')
const user = messageArr[4]
const subject = messageArr[6]
const estimatedDate =
messageArr[7]
.slice()
.split(' ')[3]
const estimatedTime =
messageArr[7]
.slice()
.split(' ')[4]
return {
title,
groupName,
user,
subject,
estimatedDate,
estimatedTime
}
}