From 55ab0b58df4f8a70440c589350810be0f326fb0c Mon Sep 17 00:00:00 2001 From: benji7425 Date: Fri, 2 Dec 2016 00:40:33 +0000 Subject: [PATCH] Added check for existing timer so we don't start a new one on reconnect --- feed-bot.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/feed-bot.js b/feed-bot.js index 2cfe5b0..194c2de 100644 --- a/feed-bot.js +++ b/feed-bot.js @@ -14,9 +14,11 @@ var url = Url.parse(Config.feedUrl); //placeholder for our bot - we need to check for connectivity before assigning this though var bot; +var timer = false; var latestFeedLink = ""; var linkRegExp = new RegExp(["http", "https", "www"].join("|")); var cachedLinks = []; + //caches a link so we can check again later function cacheLink(link) { //cheaty way to get around http and https not matching @@ -49,7 +51,11 @@ Dns.resolve("discordapp.com", function (err) { checkPreviousMessagesForLinks(); logEvent("Setting up timer to check feed every " + Config.pollingInterval + " milliseconds"); - setInterval(checkFeedAndPost, Config.pollingInterval); + + if(!timer){ + setInterval(checkFeedAndPost, Config.pollingInterval); + timer = true; + } }); bot.on("disconnect", function (err, code) {