Browse Source

Add rss element content into posted message

master
benji7425 3 years ago
parent
commit
c1be0ff0e6
  1. 13
      app/models/feed-data.js
  2. 3
      discord-bot-core/HandleMessage.js

13
app/models/feed-data.js

@ -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

3
discord-bot-core/HandleMessage.js

@ -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*/

Loading…
Cancel
Save