Fixed missing variable declaration
This commit is contained in:
parent
9c4a569242
commit
436d474787
14
feed-bot.js
14
feed-bot.js
|
@ -45,12 +45,12 @@ Dns.resolve("discordapp.com", function (err) {
|
||||||
bot.on("ready", function () {
|
bot.on("ready", function () {
|
||||||
log.info("Registered bot " + bot.username + " - (" + bot.id + ")");
|
log.info("Registered bot " + bot.username + " - (" + bot.id + ")");
|
||||||
|
|
||||||
//as we don't have any links cached, we need to check recent messages
|
//as we don't have any links cached, we need to check recent messages
|
||||||
checkPreviousMessagesForLinks();
|
checkPreviousMessagesForLinks();
|
||||||
|
|
||||||
log.info("Setting up timer to check feed every " + Config.pollingInterval + " milliseconds");
|
log.info("Setting up timer to check feed every " + Config.pollingInterval + " milliseconds");
|
||||||
|
|
||||||
if(!timer){
|
if (!timer) {
|
||||||
setInterval(checkFeedAndPost, Config.pollingInterval);
|
setInterval(checkFeedAndPost, Config.pollingInterval);
|
||||||
timer = true;
|
timer = true;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ Dns.resolve("discordapp.com", function (err) {
|
||||||
log.event("Bot was disconnected! " + code ? code : "No disconnect code provided", "Discord.io");
|
log.event("Bot was disconnected! " + code ? code : "No disconnect code provided", "Discord.io");
|
||||||
if (err) log.error("Bot disconnected!", err);
|
if (err) log.error("Bot disconnected!", err);
|
||||||
log.info("Trying to reconnect bot");
|
log.info("Trying to reconnect bot");
|
||||||
|
|
||||||
//then actually attempt to reconnect
|
//then actually attempt to reconnect
|
||||||
bot.connect();
|
bot.connect();
|
||||||
});
|
});
|
||||||
|
@ -98,7 +98,7 @@ function checkLinkAndPost(err, articles) {
|
||||||
//check whether the latest link out the feed exists in our cache
|
//check whether the latest link out the feed exists in our cache
|
||||||
if (!cachedLinks.includes(latestLink)) {
|
if (!cachedLinks.includes(latestLink)) {
|
||||||
log.info("Attempting to post new link: " + latestLink);
|
log.info("Attempting to post new link: " + latestLink);
|
||||||
|
|
||||||
//send a messsage containing the new feed link to our discord channel
|
//send a messsage containing the new feed link to our discord channel
|
||||||
bot.sendMessage({
|
bot.sendMessage({
|
||||||
to: Config.channelID,
|
to: Config.channelID,
|
||||||
|
@ -117,7 +117,7 @@ function checkLinkAndPost(err, articles) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//finally make sure the link is cached, so it doesn't get posted again
|
//finally make sure the link is cached, so it doesn't get posted again
|
||||||
cacheLink(latestLink);
|
cacheLink(latestLink);
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ function checkPreviousMessagesForLinks() {
|
||||||
var messageContents = messages.map((x) => { return x.content; }).reverse();
|
var messageContents = messages.map((x) => { return x.content; }).reverse();
|
||||||
|
|
||||||
for (var messageIdx in messageContents) {
|
for (var messageIdx in messageContents) {
|
||||||
message = messageContents[messageIdx];
|
var message = messageContents[messageIdx];
|
||||||
|
|
||||||
//test if the message contains a url
|
//test if the message contains a url
|
||||||
if (linkRegExp.test(message))
|
if (linkRegExp.test(message))
|
||||||
|
|
Loading…
Reference in a new issue