From bdcede0731d375e1b14d67288e45c3e13557c913 Mon Sep 17 00:00:00 2001 From: marsalva Date: Thu, 19 Mar 2026 21:16:21 +0000 Subject: [PATCH] Actualizar robot.js --- robot.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/robot.js b/robot.js index 035c907..99b8bfb 100644 --- a/robot.js +++ b/robot.js @@ -222,6 +222,19 @@ async function runMultiasistencia(ownerId, user, pass, gremiosDB) { const cpOnly = cpMatch ? cpMatch[0] : ""; const popOnly = rawCPField.replace(cpOnly, '').replace('-', '').trim(); + // 📞 EXTRAER TELÉFONO REAL (Evita coger el de la oficina) + let telefonoReal = ""; + const titulosDiv = Array.from(document.querySelectorAll('.subtitulo')); + const divTelefono = titulosDiv.find(div => div.innerText && div.innerText.includes('Teléfono')); + if (divTelefono && divTelefono.nextElementSibling) { + const celdaNum = divTelefono.nextElementSibling.querySelector('.tdet'); + if (celdaNum) telefonoReal = celdaNum.innerText.replace(/[^0-9]/g, ''); + } + // Fallback por si acaso falla, usamos el que tenías antes + if (!telefonoReal || telefonoReal.length < 9) { + telefonoReal = (document.body.innerText.match(/[6789]\d{8}/) || [])[0] || ""; + } + return { "Expediente": findByCab("Número Reparación") || "", "Nombre Cliente": findByCab("Nombre Cliente") || "", @@ -230,7 +243,8 @@ async function runMultiasistencia(ownerId, user, pass, gremiosDB) { "Código Postal": cpOnly, "Compañía": "MULTI - " + (findByCab("Procedencia") || "MULTIASISTENCIA"), "Descripción": cleanDesc, - "Teléfono": (document.body.innerText.match(/[6789]\d{8}/) || [])[0] || "", + "Teléfono": telefonoReal, + "Estado": findByCab("Estado") || "", // 🛑 AÑADIDO EL ESTADO AQUÍ "Urgente": findByCab("Urgente") || "No" }; });