|
@@ -4,13 +4,12 @@ const db = require("../db.js");
|
|
|
const interval = require("interval-promise");
|
|
|
const client = require("../client.js");
|
|
|
const sha1 = require("sha1");
|
|
|
-const html = require("node-html-parser");
|
|
|
-const axios = require("axios");
|
|
|
const path = require("path");
|
|
|
const fs = require("fs");
|
|
|
const Discord = require("discord.js");
|
|
|
|
|
|
const UPDATE_INTERVAL = 5;
|
|
|
+const MAX_PREVIEW_LENGTH = 300;
|
|
|
|
|
|
const aggregators = [];
|
|
|
const aggregateChannelID = db.get("aggregateChannel").value();
|
|
@@ -61,6 +60,13 @@ async function checkFeeds() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function clipText(text) {
|
|
|
+ if(text.length <= MAX_PREVIEW_LENGTH)
|
|
|
+ return text;
|
|
|
+
|
|
|
+ return `${text.substring(0, MAX_PREVIEW_LENGTH)}...`;
|
|
|
+}
|
|
|
+
|
|
|
// TODO: Replace with proper forum implementation
|
|
|
async function addNewsItem(item) {
|
|
|
let aggrItems = db.get("aggregatedItemsCache");
|
|
@@ -82,7 +88,7 @@ async function addNewsItem(item) {
|
|
|
url: item.link,
|
|
|
color: item.embedColor,
|
|
|
timestamp: new Date(),
|
|
|
- description: `${item.contents.substring(0, Math.min(item.contents.length, 300))}...`,
|
|
|
+ description: clipText(item.contents),
|
|
|
author: {
|
|
|
name: item.author
|
|
|
},
|