Add rss element content into posted message

This commit is contained in:
benji7425 2017-11-11 03:21:05 +00:00
parent f6d1b5f7a6
commit 20bc117dae
2 changed files with 14 additions and 2 deletions

View File

@ -85,13 +85,24 @@ module.exports = class FeedData {
const channel = guild.channels.get(this.channelID),
role = guild.roles.get(this.roleID);
channel.send((role ? role + " " : "") + latest)
channel.send((role || "") + formatPost(articles[0]))
.catch(err => DiscordUtil.dateError(`Error posting in ${channel.id}: ${err.message || err}`));
}
});
}
};
function formatPost(article) {
let message = "";
if (article.title)
message += `\n**${article.title}**`;
if (article.content)
message += `\n${article.content}`;
if (article.link)
message += `\n\n${normaliseUrl(article.link)}`;
return message;
}
function normaliseUrl(url) {
url = url.replace("https://", "http://"); //hacky way to treat http and https the same

View File

@ -1,6 +1,7 @@
// @ts-ignore
const Discord = require("discord.js");
// @ts-ignore
const ParentPackageJSON = require("../package.json");
// @ts-ignore
const InternalConfig = require("./internal-config.json");
/**@param param*/