1
0
mirror of https://git.keinpfusch.net/loweel/zorg synced 2024-12-18 11:39:31 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
df43f758e9 Custom function html2text. 2023-08-07 20:20:29 +02:00
0eb73d75a8 Added RSS item title to the APub body 2023-08-07 20:09:33 +02:00

15
feed.go
View File

@ -7,7 +7,8 @@ import (
"os"
"time"
strip "github.com/grokify/html-strip-tags-go"
"regexp"
"github.com/mmcdole/gofeed"
)
@ -50,8 +51,8 @@ func forwardLastFeed(url string) {
if time.Since(postAge) < Zint {
TheTitle := fmt.Sprintf("[News from %s ]", strip.StripTags(feed.Title))
TheBody := fmt.Sprintf("%s \n\n%s \n\n%s", strip.StripTags(b.Author.Name), strip.StripTags(b.Description), b.Link)
TheTitle := fmt.Sprintf("[News from %s ]", html2text(feed.Title))
TheBody := fmt.Sprintf("%s\n\n %s\n\n %s\n\n%s\n ", html2text(b.Author.Name), html2text(b.Title), html2text(b.Description), b.Link)
postOnMastodon(TheBody, TheTitle)
log.Println("New content from: ", feed.Title, b.Title, feed.Description)
@ -108,3 +109,11 @@ func fileByLines(filename string) (blurls []string) {
return
}
func html2text(html string) string {
re := regexp.MustCompile(`<[^>]*>`)
return re.ReplaceAllString(html, "")
}