From 330d94cfd7c66be184e6bbd7c06a33877e518b17 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Fri, 14 Dec 2018 14:18:46 +0100 Subject: [PATCH] Special branch for the instance in kuketzblog@rooms.dismail.de which posts kuketzblogs mastodon posts. --- getarticles.go | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/getarticles.go b/getarticles.go index 5431a68..2d6b783 100644 --- a/getarticles.go +++ b/getarticles.go @@ -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, ``, "", -1) + mastodonContent = strings.Replace(mastodonContent, ``, "", -1) + mastodonContent = strings.Replace(mastodonContent, ``, "", -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" + } } }