Capture full prepay lead fields (FIO/dates/room/amount) for Telegram alerts
This commit is contained in:
@@ -100,10 +100,25 @@ function loadParadizTelegramConfig() {
|
||||
function extractLeadFields(text) {
|
||||
const out = {};
|
||||
const t = String(text || '');
|
||||
|
||||
const em = t.match(EMAIL_RE);
|
||||
if (em) out.email = em[0];
|
||||
|
||||
const ph = t.match(PHONE_RE);
|
||||
if (ph) out.phone = ph[0].replace(/\s+/g, ' ').trim();
|
||||
|
||||
const fio = t.match(/(?:фио|гость)\s*[:\-]\s*([^\n,;]+)/i);
|
||||
if (fio) out.fio = fio[1].trim();
|
||||
|
||||
const dates = t.match(/(?:даты|период)\s*[:\-]\s*([^\n;]+)/i) || t.match(/(\d{2}\.\d{2}(?:\.\d{2,4})?\s*[\-–—]\s*\d{2}\.\d{2}(?:\.\d{2,4})?)/);
|
||||
if (dates) out.dates = dates[1].trim();
|
||||
|
||||
const room = t.match(/(?:номер|размещени[ея])\s*[:\-]\s*([^\n;]+)/i);
|
||||
if (room) out.room = room[1].trim();
|
||||
|
||||
const amount = t.match(/(?:сумма|предоплат[аы])\s*[:\-]?\s*([\d\s]+(?:[\.,]\d+)?\s*(?:₽|руб|rur)?)/i);
|
||||
if (amount) out.amount = amount[1].replace(/\s+/g, ' ').trim();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user