mirror of
https://salsa.debian.org/mdosch/feed-to-muc.git
synced 2024-11-22 22:18:39 +01:00
Special branch for the instance in kuketzblog@rooms.dismail.de which posts kuketzblogs mastodon posts.
This commit is contained in:
parent
638c24819f
commit
330d94cfd7
1 changed files with 11 additions and 19 deletions
|
@ -193,33 +193,25 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
|
||||||
|
|
||||||
// Remove redirects and tracking parameters from URL.
|
// Remove redirects and tracking parameters from URL.
|
||||||
cleanURL, _ := removeTracking(article.Link)
|
cleanURL, _ := removeTracking(article.Link)
|
||||||
|
// Don't process mastodon messages that are a reply
|
||||||
// Only send title and link if option noExcerpt is set,
|
if strings.Contains(article.Content, "http://activitystrea.ms/schema/1.0/comment") == false {
|
||||||
// otherwise add the description.
|
|
||||||
if noExcerpt == true {
|
|
||||||
output = output + feed.Title + ": *" + article.Title + "*\n" +
|
|
||||||
cleanURL
|
|
||||||
} else {
|
|
||||||
// Strip HTML as we want to get plain text.
|
// 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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only append article link if it is not yet contained in description (e.g. read more: URL).
|
output = output + "Kuketz-Blog: " + mastodonContent + "\n\n" + cleanURL
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
output = output + "\n\n---\n\n"
|
output = output + "\n\n---\n\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return output, err
|
return output, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue