From 5fd008c0032e8e7b16b91a845b5934f169bc903b Mon Sep 17 00:00:00 2001 From: Rodrigo Bertoldo de Sousa Martins Date: Sun, 29 Mar 2026 10:01:41 -0300 Subject: [PATCH] =?UTF-8?q?datacom:=20exibe=20service-port=20nas=20configu?= =?UTF-8?q?ra=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rodrigo Bertoldo de Sousa Martins --- src/bot/handler.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/bot/handler.js b/src/bot/handler.js index a208685..df93b5e 100644 --- a/src/bot/handler.js +++ b/src/bot/handler.js @@ -1858,18 +1858,39 @@ Digite /help para ver todos os comandos disponíveis! } const configCommand = `show running-config interface gpon ${slot} onu ${onuId}`; - const result = await this.ssh.executeCommand(connection.connectionId, configCommand); + const spCommand = `show running-config service-port | context-match "gpon ${slot} onu ${onuId}"`; + + const [configResult, spResult] = await Promise.all([ + this.ssh.executeCommand(connection.connectionId, configCommand), + this.ssh.executeCommand(connection.connectionId, spCommand) + ]); this.ssh.disconnect(connection.connectionId); - if (result.success) { + if (configResult.success) { + // Extrair service-ports + const servicePorts = spResult.success + ? this.ssh.parseServicePorts(spResult.output) + : []; + let message = `📋 *Configuração da ONU*\n`; - message += `📍 Slot: ${slot}, ONU: ${onuId}\n\n`; - message += `\`\`\`\n${result.output}\n\`\`\``; + message += `📍 Slot: ${slot}, ONU: ${onuId}\n`; + + if (servicePorts.length > 0) { + message += `🔌 *Service-port${servicePorts.length > 1 ? 's' : ''}:* ${servicePorts.join(', ')}\n`; + } else { + message += `🔌 *Service-port:* não encontrado\n`; + } + + message += `\n\`\`\`\n${configResult.output}\n\`\`\``; + + if (spResult.success && spResult.output && spResult.output.trim()) { + message += `\n\n*Service-port(s):*\n\`\`\`\n${spResult.output.trim()}\n\`\`\``; + } await this.bot.sendMessage(chatId, message, { parse_mode: 'Markdown' }); } else { - await this.bot.sendMessage(chatId, `❌ Erro ao obter configuração: ${result.error}`); + await this.bot.sendMessage(chatId, `❌ Erro ao obter configuração: ${configResult.error}`); } } catch (error) { console.error('Erro ao mostrar configuração:', error);