Fixed conversion from full url to share url returning undefined
Also fixed a typo in log.js
This commit is contained in:
parent
0766a8351b
commit
33f325e134
|
@ -55,3 +55,4 @@ jspm_packages
|
|||
*.tgz
|
||||
|
||||
/botConfig.json
|
||||
/bot-config.json
|
10
feed-bot.js
10
feed-bot.js
|
@ -41,9 +41,13 @@ function checkCache(link) {
|
|||
return cachedLinks.includes(link);
|
||||
}
|
||||
|
||||
function convertToYoutubeShareUrl(fullUrl){
|
||||
function convertToYoutubeShareUrl(fullUrl) {
|
||||
var shareUrl = fullUrl.replace(youtubeFullUrl, youtubeShareUrl);
|
||||
shareUrl.splice(0, shareUrl.indexOf("&"));
|
||||
var ampersandIdx = shareUrl.indexOf("&");
|
||||
if (ampersandIdx > -1)
|
||||
return shareUrl.slice(0, ampersandIdx);
|
||||
else
|
||||
return shareUrl;
|
||||
}
|
||||
|
||||
//check if we can connect to discordapp.com to authenticate the bot
|
||||
|
@ -112,6 +116,8 @@ function checkLinkAndPost(err, articles) {
|
|||
|
||||
//check whether the latest link out the feed exists in our cache
|
||||
if (!checkCache(latestLink)) {
|
||||
if (Config.youtubeMode && latestLink.includes(youtubeFullUrl))
|
||||
latestLink = convertToYoutubeShareUrl(latestLink);
|
||||
Log.info("Attempting to post new link: " + latestLink);
|
||||
|
||||
//send a messsage containing the new feed link to our discord channel
|
||||
|
|
6
log.js
6
log.js
|
@ -9,12 +9,12 @@ function log(message) {
|
|||
module.exports = {
|
||||
info: function (message) {
|
||||
if (message)
|
||||
this.log("INFO: " + message);
|
||||
log("INFO: " + message);
|
||||
},
|
||||
event: function (message, sender) {
|
||||
//if we received a message, log it - include sender information if it was passed
|
||||
if (message) {
|
||||
log("EVENT: " + (sender ? sender + " has sent an event: " : "") + messsage);
|
||||
log("EVENT: " + (sender ? sender + " has sent an event: " : "") + message);
|
||||
}
|
||||
},
|
||||
error: function (message, innerEx) {
|
||||
|
@ -23,4 +23,4 @@ module.exports = {
|
|||
log("ERROR: " + message + (innerEx ? ". Inner exception details: " + (innerEx.message || innerEx) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue