Support html-to-text for cleaning up html
This commit is contained in:
parent
f764ad3dc7
commit
ae44a77148
|
@ -6,6 +6,7 @@ const Core = require("../../core");
|
||||||
const DiscordUtil = require("../../core").util;
|
const DiscordUtil = require("../../core").util;
|
||||||
const GetUrls = require("get-urls");
|
const GetUrls = require("get-urls");
|
||||||
const Url = require("url");
|
const Url = require("url");
|
||||||
|
const HtmlToText = require("html-to-text");
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const readFeed = url => promisify(require("rss-parser").parseURL)(url);
|
const readFeed = url => promisify(require("rss-parser").parseURL)(url);
|
||||||
|
@ -119,7 +120,8 @@ function formatPost(article) {
|
||||||
|
|
||||||
if (article.content) {
|
if (article.content) {
|
||||||
let maxLen = Config.charLimit - title.length - link.length - 4;
|
let maxLen = Config.charLimit - title.length - link.length - 4;
|
||||||
message += article.content.length > maxLen ? `\n${article.content.substr(0, maxLen)}...` : `\n${article.content}`;
|
let sanitized = HtmlToText.fromString(article.content);
|
||||||
|
message += sanitized.length > maxLen ? `\n${sanitized.substr(0, maxLen)}...` : `\n${sanitized}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
message += link;
|
message += link;
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "9.3.0",
|
"@types/node": "9.3.0",
|
||||||
"discord.js": "11.2.0",
|
"discord.js": "11.2.0",
|
||||||
"eslint": "4.16.0",
|
"eslint": "4.19.1",
|
||||||
"get-urls": "7.0.0",
|
"get-urls": "7.0.0",
|
||||||
"jsonfile": "3.0.1",
|
"jsonfile": "3.0.1",
|
||||||
"rss-parser": "2.12.0",
|
"rss-parser": "2.12.0",
|
||||||
"shortid": "2.2.8"
|
"shortid": "2.2.8",
|
||||||
|
"html-to-text": "3.3.0"
|
||||||
},
|
},
|
||||||
"name": "discord-bot-rss-feed",
|
"name": "discord-bot-rss-feed",
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
|
|
Loading…
Reference in New Issue