// commands/atlasDiag.js // // /atlasdiag // // Live AZM report via Atlas UI tunnel + WebSocket: sources, zones, // accessories, uptime. Sources in the -80 to -70 dB band are flagged. import { checkStore } from '../integrations/atlas/checkStore.js'; import { logger } from '../utils/logger.js'; export async function handleAtlasDiag(bot, trigger) { const query = trigger.query || {}; const args = trigger.args || []; const storeOrName = ( args[0]?.trim() || query.storeNum || query.store || query.s || '' ).trim(); if (!storeOrName) { await bot.say( 'markdown', 'Please provide a store number or AZM device name.\n' + 'Examples:\n' + '- `/atlasdiag 2547`\n' + '- `/atlasdiag US002547AMP`\n' + 'HTTP: `?storeNum=2547`', ); return; } logger('atlas:diag', `Starting live AZM check for ${storeOrName}`); await bot.say('markdown', `⏳ Checking store **${storeOrName}** (live AZM tunnel, may take up to 90s)…`); try { const result = await checkStore(storeOrName); await bot.say('markdown', result.markdown); } catch (err) { logger('atlas:diag', `Check failed for ${storeOrName}: ${err.message}`, 'warn'); await bot.say('markdown', `❌ Atlas diag failed: ${err.message || String(err)}`); } }