switch human alert to button

This commit is contained in:
legop3
2026-04-09 14:02:54 -04:00
parent 5e428b278a
commit 8ed617305d
14 changed files with 382 additions and 1125 deletions
+9 -14
View File
@@ -1460,37 +1460,32 @@ function handleBusEvent(event) {
logger.warn('Replay send failed', err.message);
});
break;
case 'vision.humanDetected': {
case 'humanAlert.buttonPressed': {
const imageBase64 = payload?.imageBase64 ? String(payload.imageBase64) : '';
let attachment = null;
if (imageBase64) {
try {
const imageBuffer = Buffer.from(imageBase64, 'base64');
if (imageBuffer.length > 0) {
attachment = new AttachmentBuilder(imageBuffer, { name: 'human-detected.jpg' });
attachment = new AttachmentBuilder(imageBuffer, { name: 'human-alert-mosaic.jpg' });
}
} catch (err) {
logger.warn('Failed to decode human detection image for Discord', err.message);
logger.warn('Failed to decode human alert image for Discord', err.message);
}
}
const cameraLabel = payload?.cameraId ? `Camera: \`${payload.cameraId}\`` : 'Camera: unknown';
const confidenceLabel =
Number.isFinite(Number(payload?.confidence))
? `Confidence: \`${Number(payload.confidence).toFixed(2)}\``
: 'Confidence: n/a';
const detectedAt = Number(payload?.detectedAt);
const detectedLabel = Number.isFinite(detectedAt)
? `Detected: <t:${Math.floor(detectedAt / 1000)}:F>`
const triggeredAt = Number(payload?.triggeredAt);
const triggeredLabel = Number.isFinite(triggeredAt)
? `Triggered: <t:${Math.floor(triggeredAt / 1000)}:F>`
: null;
const embed = buildEmbed({
title: 'Human Detected',
description: [cameraLabel, confidenceLabel, detectedLabel].filter(Boolean).join('\n'),
title: 'Human Alert Button Pressed',
description: [triggeredLabel].filter(Boolean).join('\n'),
color: 0xe53935,
});
announce({
channelId: channels.humanAlerts,
pingRoleId: roles.humanAlertPing || null,
content: payload?.message || 'Human detected in room.',
content: payload?.message || 'Human alert button pressed.',
embeds: [embed],
files: attachment ? [attachment] : [],
includeSiteUrl: false,