Fix articles not posting if content too long for discord
Also fix incorrect name in example commands
This commit is contained in:
parent
d2fa55beae
commit
21c51fbc3d
12
README.md
12
README.md
|
@ -22,31 +22,31 @@ If you agree, invite to your server with [this link](https://discordapp.com/oaut
|
||||||
|
|
||||||
## Setup
|
## 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
|
### 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
|
- *url* must be an RSS feed URL
|
||||||
- *#channel* must be a channel mention
|
- *#channel* must be a channel mention
|
||||||
- *@role* must be a role mention (make sure "Anyone can mention this role" is turned on during setup)
|
- *@role* must be a role mention (make sure "Anyone can mention this role" is turned on during setup)
|
||||||
|
|
||||||
Example:
|
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
|
### 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
|
This will display a list of RSS feeds configured for this server, along with a unique ID for each
|
||||||
|
|
||||||
### Remove a configured feed
|
### 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
|
To remove a feed you will need it's unique ID, which you can find by running the above *view-feeds* command
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
`@RSS_Bot remove-feed ABc-123dEF`
|
`@RSS Bot remove-feed ABc-123dEF`
|
||||||
|
|
||||||
## Permissions
|
## Permissions
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"maxCacheSize": 100,
|
"maxCacheSize": 100,
|
||||||
"feedCheckIntervalSec": 30
|
"feedCheckIntervalSec": 30,
|
||||||
|
"charLimit": 500
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
//my imports
|
|
||||||
const DiscordUtil = require("../../discord-bot-core").util;
|
const DiscordUtil = require("../../discord-bot-core").util;
|
||||||
|
// @ts-ignore
|
||||||
//external lib imports
|
const Config = require("../config.json");
|
||||||
const Dns = require("dns"); //for host resolution checking
|
const Dns = require("dns"); //for host resolution checking
|
||||||
const Url = require("url"); //for url parsing
|
const Url = require("url"); //for url parsing
|
||||||
const FeedRead = require("feed-read"); //for extracing new links from RSS feeds
|
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) {
|
updatePastPostedLinks(guild) {
|
||||||
const channel = guild.channels.get(this.channelID);
|
const channel = guild.channels.get(this.channelID);
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ module.exports = class FeedData {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@param param */
|
/**@param guild */
|
||||||
fetchLatest(guild) {
|
fetchLatest(guild) {
|
||||||
Dns.resolve(Url.parse(this.url).host || "", err => {
|
Dns.resolve(Url.parse(this.url).host || "", err => {
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -100,7 +99,7 @@ function formatPost(article) {
|
||||||
if (article.title)
|
if (article.title)
|
||||||
message += `\n**${article.title}**`;
|
message += `\n**${article.title}**`;
|
||||||
if (article.content)
|
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)
|
if (article.link)
|
||||||
message += `\n\n${normaliseUrl(article.link)}`;
|
message += `\n\n${normaliseUrl(article.link)}`;
|
||||||
return message;
|
return message;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"main": "app/index.js",
|
"main": "app/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "cd ./discord-bot-core && npm install",
|
"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": {
|
"dependencies": {
|
||||||
"discord.js": "11.2.0",
|
"discord.js": "11.2.0",
|
||||||
|
|
Loading…
Reference in a new issue