From 63591000f0d5463c946bcd7323c4d6f2b62b8dd1 Mon Sep 17 00:00:00 2001 From: Rodrigo Bertoldo de Sousa Martins Date: Wed, 1 Apr 2026 10:08:08 -0300 Subject: [PATCH] diagnostico: adicionar ver roteador Signed-off-by: Rodrigo Bertoldo de Sousa Martins --- src/bot/handler.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/bot/handler.js b/src/bot/handler.js index d901cef..137b808 100644 --- a/src/bot/handler.js +++ b/src/bot/handler.js @@ -1055,15 +1055,18 @@ Digite /help para ver todos os comandos disponíveis! // Campo base/AP usado para rotear para a OLT correta const baseInfo = servico.base || (servico.id_ap ? `AP ${servico.id_ap}` : null); - // Executar consultas em paralelo: Juniper + ONU + // Executar consultas em paralelo: Juniper + ONU + GenieACS (por TAG/login) // No concentrador Juniper usa-se só o usuário (antes do @) const pppoeUser = pppoeLogin ? pppoeLogin.split('@')[0] : null; - const [juniperResult, onuResult] = await Promise.all([ + const [juniperResult, onuResult, genieResult] = await Promise.all([ pppoeUser ? this.ssh.getJuniperSubscriberInfo('juniper', pppoeUser).catch(e => ({ success: false, error: e.message })) : Promise.resolve({ success: false, skipped: true }), serial ? this._diagnosticarONU(serial, baseInfo).catch(e => ({ success: false, error: e.message })) + : Promise.resolve({ success: false, skipped: true }), + pppoeLogin && this.genieacs.isReady() + ? this.genieacs.buscarRoteador(pppoeLogin).catch(() => ({ success: false })) : Promise.resolve({ success: false, skipped: true }) ]); @@ -1122,6 +1125,26 @@ Digite /help para ver todos os comandos disponíveis! await this.bot.sendMessage(chatId, msg, { parse_mode: 'Markdown' }); + // Bloco 4: Roteador/CPE via GenieACS (exibido apenas se encontrado pela TAG) + if (genieResult && genieResult.success) { + const esc = (v) => { + if (v === null || v === undefined || v === '') return 'N/A'; + return String(v).replace(/[_*`\[]/g, '\\$&'); + }; + const d = genieResult.device; + const tagLabel = d.tags && d.tags.length > 0 ? d.tags.map(esc).join(', ') : null; + + let msgCPE = `📡 *Roteador / CPE (GenieACS)*\n`; + msgCPE += ` 🖥️ Nome: ${esc(d.productClass)}\n`; + msgCPE += ` 🏭 Fabricante: ${esc(d.manufacturer)}\n`; + msgCPE += ` 🔧 SW: ${esc(d.softwareVersion)}\n`; + if (tagLabel) msgCPE += ` 🏷️ TAG: \`${tagLabel}\`\n`; + if (d.ssid24) msgCPE += ` 📶 SSID 2.4GHz: ${esc(d.ssid24)} (Canal ${esc(d.channel24)}, Auto: ${esc(d.autoChannel24)})\n`; + if (d.ssid5) msgCPE += ` 📶 SSID 5GHz: ${esc(d.ssid5)} (Canal ${esc(d.channel5)}, Auto: ${esc(d.autoChannel5)})\n`; + + await this.bot.sendMessage(chatId, msgCPE, { parse_mode: 'Markdown' }); + } + } catch (error) { console.error('❌ Erro em runDiagnosticoServico:', error); await this.bot.sendMessage(chatId, `❌ Erro no diagnóstico: ${error.message}`);