Stripping HTML .

master
Uriel Fanelli 2023-07-15 02:38:55 +02:00
parent 6978287809
commit 2ea8bf202b
3 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import (
"os" "os"
"time" "time"
strip "github.com/grokify/html-strip-tags-go"
"github.com/mmcdole/gofeed" "github.com/mmcdole/gofeed"
) )
@ -49,8 +50,8 @@ func forwardLastFeed(url string) {
if time.Since(postAge) < Zint { if time.Since(postAge) < Zint {
TheTitle := fmt.Sprintf("[ %s ]", feed.Title) TheTitle := fmt.Sprintf("[News from %s ]", strip.StripTags(feed.Title))
TheBody := fmt.Sprintf("%s \n\n%s \n\n%s", b.Author.Name, feed.Description, b.Link) TheBody := fmt.Sprintf("%s \n\n%s \n\n%s", strip.StripTags(b.Author.Name), strip.StripTags(b.Description), b.Link)
postOnMastodon(TheBody, TheTitle) postOnMastodon(TheBody, TheTitle)
log.Println("New content from: ", feed.Title, b.Title, feed.Description) log.Println("New content from: ", feed.Title, b.Title, feed.Description)

1
go.mod
View File

@ -3,6 +3,7 @@ module zorg
go 1.13 go 1.13
require ( require (
github.com/grokify/html-strip-tags-go v0.0.1
github.com/mattn/go-mastodon v0.0.4 github.com/mattn/go-mastodon v0.0.4
github.com/mmcdole/gofeed v1.0.0 github.com/mmcdole/gofeed v1.0.0
) )

2
go.sum
View File

@ -8,6 +8,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=