Special branch for the instance in kuketzblog@rooms.dismail.de which posts kuketzblogs mastodon posts.

This commit is contained in:
Martin Dosch 2018-12-14 14:18:46 +01:00
parent 638c24819f
commit 330d94cfd7

View file

@ -193,31 +193,23 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
// Remove redirects and tracking parameters from URL.
cleanURL, _ := removeTracking(article.Link)
// Only send title and link if option noExcerpt is set,
// otherwise add the description.
if noExcerpt == true {
output = output + feed.Title + ": *" + article.Title + "*\n" +
cleanURL
} else {
// Don't process mastodon messages that are a reply
if strings.Contains(article.Content, "http://activitystrea.ms/schema/1.0/comment") == false {
// Strip HTML as we want to get plain text.
description, err := html2text.FromString(article.Description)
mastodonContent := strings.Replace(article.Content, `</span><span class="ellipsis">`, "", -1)
mastodonContent = strings.Replace(mastodonContent, `</span><span class="invisible">`, "", -1)
mastodonContent = strings.Replace(mastodonContent, `</span>`, "", -1)
mastodonContent = strings.Replace(mastodonContent, `<span>`, "", -1)
mastodonContent, err = html2text.FromString(mastodonContent, html2text.Options{OmitLinks: true})
if err != nil {
return "", err
}
// Only append article link if it is not yet contained in description (e.g. read more: URL).
if strings.Contains(description, article.Link) == true {
// Replace article link with URL cleaned from redirects and trackers.
description = strings.Replace(description, article.Link, cleanURL, -1)
output = output + feed.Title + ": *" + article.Title + "*\n\n" + description
} else {
output = output + feed.Title + ": *" + article.Title + "*\n\n" + description + "\n" + cleanURL
}
}
output = output + "Kuketz-Blog: " + mastodonContent + "\n\n" + cleanURL
if i > 0 {
output = output + "\n\n---\n\n"
if i > 0 {
output = output + "\n\n---\n\n"
}
}
}