Actualizar robot.js
This commit is contained in:
23
robot.js
23
robot.js
@@ -334,6 +334,9 @@ async function runHomeserve(ownerId, user, pass, gremiosDB) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (scrapData && scrapData['Nombre Cliente']) {
|
if (scrapData && scrapData['Nombre Cliente']) {
|
||||||
|
// 🪄 Arreglamos el nombre ANTES de guardarlo (Solo en HomeServe)
|
||||||
|
scrapData['Nombre Cliente'] = arreglarNombre(scrapData['Nombre Cliente']);
|
||||||
|
|
||||||
const idGremioDetectado = clasificarGremio(scrapData['Descripción'], gremiosDB);
|
const idGremioDetectado = clasificarGremio(scrapData['Descripción'], gremiosDB);
|
||||||
if (idGremioDetectado) {
|
if (idGremioDetectado) {
|
||||||
scrapData['guild_id'] = idGremioDetectado;
|
scrapData['guild_id'] = idGremioDetectado;
|
||||||
@@ -376,6 +379,26 @@ async function syncAndArchive(ownerId, provider, currentWebRefs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizarTexto(texto) {
|
||||||
|
if (!texto) return "";
|
||||||
|
return texto.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🛠️ NUEVO: El "Gira-Nombres" EXCLUSIVO para HomeServe
|
||||||
|
function arreglarNombre(nombreRaw) {
|
||||||
|
if (!nombreRaw) return "";
|
||||||
|
let nombreLimpio = nombreRaw.trim();
|
||||||
|
// Si detectamos que tiene una coma...
|
||||||
|
if (nombreLimpio.includes(',')) {
|
||||||
|
let partes = nombreLimpio.split(',');
|
||||||
|
let apellidos = partes[0].trim();
|
||||||
|
let nombre = partes[1].trim();
|
||||||
|
// Le damos la vuelta y quitamos espacios sobrantes
|
||||||
|
nombreLimpio = `${nombre} ${apellidos}`.replace(/\s+/g, ' ');
|
||||||
|
}
|
||||||
|
return nombreLimpio;
|
||||||
|
}
|
||||||
|
|
||||||
async function saveServiceToDB(ownerId, provider, ref, data) {
|
async function saveServiceToDB(ownerId, provider, ref, data) {
|
||||||
console.log(`💾 Guardando/Actualizando ${provider.toUpperCase()} ${ref}...`);
|
console.log(`💾 Guardando/Actualizando ${provider.toUpperCase()} ${ref}...`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user