Parse Mastodon's post body

This commit is contained in:
Christian Muehlhaeuser 2019-05-05 14:42:34 +02:00
parent fe0ac8c5eb
commit 2abf333c19
No known key found for this signature in database
GPG key ID: 3CF9FA45CA1EBB7E

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"fmt" "fmt"
"log" "log"
"time" "regexp"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/mattn/go-mastodon" "github.com/mattn/go-mastodon"
@ -147,8 +147,12 @@ func handleReplyStatus(status string) string {
return status return status
} }
func parsePost(ev *accounts.MessageEvent) { func parseBody(body string) string {
return r := regexp.MustCompile("<span class=\"invisible\">(.[^<]*)</span>")
body = r.ReplaceAllString(body, "")
r = regexp.MustCompile("<span class=\"ellipsis\">(.[^<]*)</span>")
return r.ReplaceAllString(body, "$1...")
/* /*
for _, u := range ents.Urls { for _, u := range ents.Urls {