From 8f1c84044787718eba2d420a57c0764d4a8a0aed Mon Sep 17 00:00:00 2001 From: benji7425 Date: Sun, 26 Nov 2017 23:37:54 +0000 Subject: [PATCH] Fix articles not posting if content too long for discord Also fix incorrect name in example commands --- README.md | 12 ++++++------ app/config.json | 3 ++- app/models/feed-data.js | 11 +++++------ package.json | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 731498a..cd6b63d 100644 --- a/README.md +++ b/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 <#channel> [@role]` +`@RSS Bot add-feed <#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 ` +`@RSS Bot remove-feed ` 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 diff --git a/app/config.json b/app/config.json index 1164d79..52d914c 100644 --- a/app/config.json +++ b/app/config.json @@ -1,4 +1,5 @@ { "maxCacheSize": 100, - "feedCheckIntervalSec": 30 + "feedCheckIntervalSec": 30, + "charLimit": 500 } \ No newline at end of file diff --git a/app/models/feed-data.js b/app/models/feed-data.js index 8c82a11..ada05d7 100644 --- a/app/models/feed-data.js +++ b/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; diff --git a/package.json b/package.json index 01ba243..b262eb6 100644 --- a/package.json +++ b/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",