battery: send alerts on channel "testowy" (index 2), not the pinned send channel
CI / build + unit (pull_request) Successful in 1m0s

Owner request. BatteryAlertService reads new env BATTERY_ALERT_CHANNEL
(default 2) at construction and passes it through MeshService.sendText,
which gains an optional trailing channel argument defaulting to the
pinned MESH_SEND_CHANNEL — every other sender is untouched. Threshold,
cooldown, merged one-message-per-cycle format and @mentions unchanged.
This commit is contained in:
2026-09-25 13:02:56 +00:00
parent 6f6b704dcf
commit 1b712f7eee
5 changed files with 60 additions and 17 deletions
+12 -2
View File
@@ -33,6 +33,11 @@ export class BatteryAlertService {
process.env.BATTERY_ALERT_COOLDOWN_MS ?? '21600000', // default 6 h
10,
);
// alerts ride "testowy" (index 2), not the pinned send channel — owner decision
private readonly alertChannel = parseInt(
process.env.BATTERY_ALERT_CHANNEL ?? '2',
10,
);
// ponytail: in-memory cooldown map — resets on process restart (a node may get one duplicate alert after a deploy)
private lastAlertAt = new Map<number, number>();
@@ -62,8 +67,13 @@ export class BatteryAlertService {
}
private async alert(nodes: NodeSummary[]): Promise<void> {
// one broadcast per cycle for the whole batch — never one message per node; rides the pinned send channel like every other bot send (MeshService.sendText)
await this.mesh.sendText(BROADCAST_ADDR, formatAlert(nodes));
// one broadcast per cycle for the whole batch — never one message per node; rides BATTERY_ALERT_CHANNEL ("testowy", default index 2) via the same MeshService.sendText path as every other bot send
await this.mesh.sendText(
BROADCAST_ADDR,
formatAlert(nodes),
undefined,
this.alertChannel,
);
const now = Date.now();
for (const n of nodes) this.lastAlertAt.set(n.num, now);
}