Ports Atlas /check as /atlasdiag: Hub resolve, UI tunnel, WebSocket report for sources/zones/accessories, low source dB warnings, and auto-disable of the monitor speaker when left on after troubleshooting. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
// commands/atlasDiag.js
|
|
//
|
|
// /atlasdiag <storeOrName>
|
|
//
|
|
// 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)}`);
|
|
}
|
|
}
|