diff --git a/scripts/telegram-watcher.js b/scripts/telegram-watcher.js index b018d0c..d02dc83 100644 --- a/scripts/telegram-watcher.js +++ b/scripts/telegram-watcher.js @@ -25,6 +25,7 @@ if (!DRY_RUN && (!BOT_TOKEN || !CHAT_ID)) { let prevSide = null; let lastSentAt = 0; +let lastSentTs = null; async function send(text) { if (DRY_RUN) { @@ -115,12 +116,17 @@ function watch() { return; } const [, , phase, strength] = data.rec.split(":"); + const ts = data.row[data.hdr.indexOf("timestamp")]; const flipped = side !== prevSide; const cooled = Date.now() - lastSentAt > COOLDOWN_MS; - if (flipped && cooled) { - const msg = buildMessage(data.hdr, data.row, side, phase, strength, getCurrentSlug()); + const newRow = ts !== lastSentTs; + if (flipped && cooled && newRow) { + const slug = getCurrentSlug(); + console.log("[watcher] slug for push:", slug); + const msg = buildMessage(data.hdr, data.row, side, phase, strength, slug); await send(msg); lastSentAt = Date.now(); + lastSentTs = ts; } prevSide = side; } catch (e) {