From 662e0e775c2767fa80b46d793aba3e11536aee71 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 15 Aug 2024 22:35:44 -0600 Subject: [PATCH] Fix - Restart after 10 minutes of inactivity from weather.im --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 707b06d..7d207a6 100644 --- a/index.js +++ b/index.js @@ -290,6 +290,8 @@ xmpp.on("offline", () => { }) }); +var restartTimer = null; + xmpp.on("stanza", (stanza) => { // Debug stuff if (config.debug >= 2) console.log(`${colors.magenta("[DEBUG]")} Stanza: ${stanza.toString()}`); @@ -315,6 +317,11 @@ xmpp.on("stanza", (stanza) => { } // Get new messages and log them, ignore old messages if (stanza.is("message") && stanza.attrs.type === "groupchat") { + clearTimeout(restartTimer) + restartTimer = setTimeout(() => { + console.log(`${colors.red("[FATAL]")} No messages from weather.im in 10 minutes, restarting!!!!!!!!!!!`) + process.exit(1) + }, 600000) // Stops spam from getting old messages if (startup) return; // Get channel name