Added check for existing timer so we don't start a new one on reconnect
This commit is contained in:
parent
e828e6996b
commit
55ab0b58df
|
@ -14,9 +14,11 @@ var url = Url.parse(Config.feedUrl);
|
||||||
|
|
||||||
//placeholder for our bot - we need to check for connectivity before assigning this though
|
//placeholder for our bot - we need to check for connectivity before assigning this though
|
||||||
var bot;
|
var bot;
|
||||||
|
var timer = false;
|
||||||
var latestFeedLink = "";
|
var latestFeedLink = "";
|
||||||
var linkRegExp = new RegExp(["http", "https", "www"].join("|"));
|
var linkRegExp = new RegExp(["http", "https", "www"].join("|"));
|
||||||
var cachedLinks = [];
|
var cachedLinks = [];
|
||||||
|
|
||||||
//caches a link so we can check again later
|
//caches a link so we can check again later
|
||||||
function cacheLink(link) {
|
function cacheLink(link) {
|
||||||
//cheaty way to get around http and https not matching
|
//cheaty way to get around http and https not matching
|
||||||
|
@ -49,7 +51,11 @@ Dns.resolve("discordapp.com", function (err) {
|
||||||
checkPreviousMessagesForLinks();
|
checkPreviousMessagesForLinks();
|
||||||
|
|
||||||
logEvent("Setting up timer to check feed every " + Config.pollingInterval + " milliseconds");
|
logEvent("Setting up timer to check feed every " + Config.pollingInterval + " milliseconds");
|
||||||
|
|
||||||
|
if(!timer){
|
||||||
setInterval(checkFeedAndPost, Config.pollingInterval);
|
setInterval(checkFeedAndPost, Config.pollingInterval);
|
||||||
|
timer = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.on("disconnect", function (err, code) {
|
bot.on("disconnect", function (err, code) {
|
||||||
|
|
Loading…
Reference in a new issue