|
|
@@ -74,6 +74,11 @@ export default class Portal {
|
|
|
article.title = article.title.replace("Exclusivo suscriptor", "");
|
|
|
}
|
|
|
|
|
|
+ article.title = article.title.replace(/\s+/g, " ").trim();
|
|
|
+ if (article.content !== "") {
|
|
|
+ article.content = article.content.replace(/\s+/g, " ").trim();
|
|
|
+ }
|
|
|
+
|
|
|
let message = `${Emojis.NEWS} ${article.title}`;
|
|
|
if (article.content !== "") {
|
|
|
message += `\n\n${article.content}`;
|
|
|
@@ -89,20 +94,20 @@ export default class Portal {
|
|
|
? generatedTags
|
|
|
: (this._scraperArticlesOptions.hashtags ?? []);
|
|
|
|
|
|
+ message += `\n${Emojis.LINK} ${article.link}`;
|
|
|
+
|
|
|
if (tags.length > 0) {
|
|
|
- message += `\n${Emojis.TAGS} ${tags.map((hashtag) => `#${hashtag}`).join(" ")}`;
|
|
|
+ message += `\n${tags.map((hashtag) => `#${hashtag}`).join(" ")}`;
|
|
|
}
|
|
|
|
|
|
- message += `\n${Emojis.LINK} ${article.link}`;
|
|
|
-
|
|
|
// Mastodon allows a maximum of 500 characters, but historically this bot limits to 400
|
|
|
if (message.length > 400) {
|
|
|
const linkLine = `\n${Emojis.LINK} ${article.link}`;
|
|
|
const tagsLine = tags.length > 0
|
|
|
- ? `\n${Emojis.TAGS} ${tags.map((hashtag) => `#${hashtag}`).join(" ")}`
|
|
|
+ ? `\n${tags.map((hashtag) => `#${hashtag}`).join(" ")}`
|
|
|
: "";
|
|
|
const maxContentLength = 400 - linkLine.length - tagsLine.length;
|
|
|
- message = `${Emojis.NEWS} ${article.title}\n\n${article.content.substring(0, Math.max(0, maxContentLength - 10))}...${tagsLine}${linkLine}`;
|
|
|
+ message = `${Emojis.NEWS} ${article.title}\n\n${article.content.substring(0, Math.max(0, maxContentLength - 10))}...${linkLine}${tagsLine}`;
|
|
|
}
|
|
|
|
|
|
if (this._name.toUpperCase() == "Chile Cultura".toUpperCase()) {
|