From 29d196e3c14684b139197639d6d70a6a85356180 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 7 Sep 2023 03:59:19 -0600 Subject: [PATCH] Ignore old message events to prevent sending duplicate texts --- main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.js b/main.js index 8e94081..31fe61f 100644 --- a/main.js +++ b/main.js @@ -502,6 +502,11 @@ client.on("Room.timeline", function (event, room) { return; } + if (event.getTs() < (Date.now() - 1000 * 60 * 60 * 8)) { + // Ignore old events (8 hrs), they're probably duplicates or something. + return; + } + if (event.getContent().body.toLowerCase().startsWith("!sms")) { // capture command to start room for new number const matches = event.getContent().body.match(/([1-9]?[0-9]{10})/g);