genieacs: fix offset

Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
rodrigo committed 2026-04-01 08:43:54 -03:00
1 parent 6e2473719d
commit c003631efc
1 file changed
+23 -19
+23 -19
View File
@@ -6915,7 +6915,13 @@ Digite /help para ver todos os comandos disponíveis!
return; return;
} }
await this.bot.sendMessage(chatId, `🔍 Consultando dispositivo \`${termo}\` no GenieACS...`, { parse_mode: 'Markdown' }); // Escapa caracteres especiais do Markdown V1 em valores dinâmicos
const esc = (v) => {
if (v === null || v === undefined || v === '') return 'N/A';
return String(v).replace(/[_*`\[]/g, '\\$&');
};
await this.bot.sendMessage(chatId, `🔍 Consultando dispositivo \`${esc(termo)}\` no GenieACS...`, { parse_mode: 'Markdown' });
try { try {
const resultado = await this.genieacs.buscarRoteador(termo); const resultado = await this.genieacs.buscarRoteador(termo);
@@ -6923,39 +6929,37 @@ Digite /help para ver todos os comandos disponíveis!
if (!resultado.success) { if (!resultado.success) {
await this.bot.sendMessage(chatId, await this.bot.sendMessage(chatId,
`❌ *Dispositivo não encontrado*\n\n` + `❌ *Dispositivo não encontrado*\n\n` +
`🔍 Busca: \`${termo}\`\n` + `🔍 Busca: \`${esc(termo)}\`\n` +
`⚠️ ${resultado.error}`, `⚠️ ${esc(resultado.error)}`,
{ parse_mode: 'Markdown' } { parse_mode: 'Markdown' }
); );
return; return;
} }
const d = resultado.device; const d = resultado.device;
const na = (v) => (v !== null && v !== undefined && v !== '') ? String(v) : 'N/A'; const tagLabel = d.tags && d.tags.length > 0 ? d.tags.map(esc).join(', ') : 'N/A';
const tagLabel = d.tags && d.tags.length > 0 ? d.tags.join(', ') : 'N/A';
const buscadoPor = resultado.searchedBy === 'tag' ? 'TAG' : 'Serial'; const buscadoPor = resultado.searchedBy === 'tag' ? 'TAG' : 'Serial';
const msg = const msg =
`📡 *Informações do Roteador*\n` + `📡 *Informações do Roteador*\n` +
`📌 Instância: ${resultado.instance}\n` + `📌 Instância: ${esc(resultado.instance)}\n` +
`🔎 Encontrado por: ${buscadoPor}\n\n` + `🔎 Encontrado por: ${buscadoPor}\n\n` +
`🖥️ *Dispositivo*\n` + `🖥️ *Dispositivo*\n` +
`├ Nome: ${na(d.productClass)}\n` + `├ Nome: ${esc(d.productClass)}\n` +
`├ Fabricante: ${na(d.manufacturer)}\n` + `├ Fabricante: ${esc(d.manufacturer)}\n` +
`├ OUI: ${na(d.oui)}\n` + `├ OUI: ${esc(d.oui)}\n` +
`├ Serial: \`${na(d.serial)}\`\n` + `├ Serial: \`${esc(d.serial)}\`\n` +
`├ TAG (TopSapp): \`${tagLabel}\`\n` + `├ TAG (TopSapp): \`${tagLabel}\`\n` +
`├ HW: ${na(d.hardwareVersion)}\n` + `├ HW: ${esc(d.hardwareVersion)}\n` +
`└ SW: ${na(d.softwareVersion)}\n\n` + `└ SW: ${esc(d.softwareVersion)}\n\n` +
`📶 *Wi-Fi 2.4 GHz*\n` + `📶 *Wi-Fi 2.4 GHz*\n` +
`├ SSID: ${na(d.ssid24)}\n` + `├ SSID: ${esc(d.ssid24)}\n` +
`├ Canal: ${na(d.channel24)}\n` + `├ Canal: ${esc(d.channel24)}\n` +
`└ Auto-Canal: ${d.autoChannel24}\n\n` + `└ Auto-Canal: ${esc(d.autoChannel24)}\n\n` +
`📶 *Wi-Fi 5 GHz*\n` + `📶 *Wi-Fi 5 GHz*\n` +
`├ SSID: ${na(d.ssid5)}\n` + `├ SSID: ${esc(d.ssid5)}\n` +
`├ Canal: ${na(d.channel5)}\n` + `├ Canal: ${esc(d.channel5)}\n` +
`└ Auto-Canal: ${d.autoChannel5}`; `└ Auto-Canal: ${esc(d.autoChannel5)}`;
await this.bot.sendMessage(chatId, msg, { parse_mode: 'Markdown' }); await this.bot.sendMessage(chatId, msg, { parse_mode: 'Markdown' });