mirror of
https://salsa.debian.org/mdosch/feed-to-muc.git
synced 2024-11-22 14:08: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,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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue