Browse Source

Fix articles not posting if content too long for discord

Also fix incorrect name in example commands
shorten
benji7425 3 years ago
parent
commit
21c51fbc3d
  1. 12
      README.md
  2. 3
      app/config.json
  3. 11
      app/models/feed-data.js
  4. 2
      package.json

12
README.md

@ -22,31 +22,31 @@ If you agree, invite to your server with [this link](https://discordapp.com/oaut
## Setup
You can ask the bot for help with commands by typing `@RSS_Bot help`
You can ask the bot for help with commands by typing `@RSS Bot help`
### Add a new feed
`@RSS_Bot add-feed <url> <#channel> [@role]`
`@RSS Bot add-feed <url> <#channel> [@role]`
- *url* must be an RSS feed URL
- *#channel* must be a channel mention
- *@role* must be a role mention (make sure "Anyone can mention this role" is turned on during setup)
Example:
`@RSS_Bot add-feed http://lorem-rss.herokuapp.com/feed?unit=second&interval=30 #rss-posts @subscribers`
`@RSS Bot add-feed http://lorem-rss.herokuapp.com/feed?unit=second&interval=30 #rss-posts @subscribers`
### View feeds configured for this server
`@RSS_Bot view-feeds`
`@RSS Bot view-feeds`
This will display a list of RSS feeds configured for this server, along with a unique ID for each
### Remove a configured feed
`@RSS_Bot remove-feed <feed-id>`
`@RSS Bot remove-feed <feed-id>`
To remove a feed you will need it's unique ID, which you can find by running the above *view-feeds* command
Example:
`@RSS_Bot remove-feed ABc-123dEF`
`@RSS Bot remove-feed ABc-123dEF`
## Permissions

3
app/config.json

@ -1,4 +1,5 @@
{
"maxCacheSize": 100,
"feedCheckIntervalSec": 30
"feedCheckIntervalSec": 30,
"charLimit": 500
}

11
app/models/feed-data.js

@ -1,7 +1,6 @@
//my imports
const DiscordUtil = require("../../discord-bot-core").util;
//external lib imports
// @ts-ignore
const Config = require("../config.json");
const Dns = require("dns"); //for host resolution checking
const Url = require("url"); //for url parsing
const FeedRead = require("feed-read"); //for extracing new links from RSS feeds
@ -34,7 +33,7 @@ module.exports = class FeedData {
};
}
/**@param param*/
/**@param guild*/
updatePastPostedLinks(guild) {
const channel = guild.channels.get(this.channelID);
@ -53,7 +52,7 @@ module.exports = class FeedData {
});
}
/**@param param */
/**@param guild */
fetchLatest(guild) {
Dns.resolve(Url.parse(this.url).host || "", err => {
if (err)
@ -100,7 +99,7 @@ function formatPost(article) {
if (article.title)
message += `\n**${article.title}**`;
if (article.content)
message += `\n${article.content}`;
message += article.content.length > Config.charLimit ? "\nArticle content too long for a single Discord message!" : `\n${article.content}`;
if (article.link)
message += `\n\n${normaliseUrl(article.link)}`;
return message;

2
package.json

@ -3,7 +3,7 @@
"main": "app/index.js",
"scripts": {
"postinstall": "cd ./discord-bot-core && npm install",
"start": "node app/index.js token.json guilds.json --max-old-space-size=64"
"start": "node app/index.js token.json guilds.json --max-old-space-size=64 --name=rss-feed"
},
"dependencies": {
"discord.js": "11.2.0",

Loading…
Cancel
Save