Make cleanupContent a separate function

pull/6/head
Christian Muehlhaeuser 2019-08-08 06:17:25 +02:00
rodzic d50115e2e7
commit 388aa2c5ec
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 3CF9FA45CA1EBB7E
1 zmienionych plików z 12 dodań i 6 usunięć

Wyświetl plik

@ -42,6 +42,17 @@ type stats struct {
Responses map[string]int64
}
func cleanupContent(content string) string {
// clean up toot for terminal output
content = strings.Replace(content, "<br>", "\n", -1)
content = strings.Replace(content, "<p>", "\n", -1)
content = strings.Replace(content, "</p>", "", -1)
content = html.UnescapeString(stripper.Sanitize(content))
content = strings.TrimSpace(strings.Replace(content, "\n", " ", -1))
return content
}
func parseToot(status *mastodon.Status, stats *stats) error {
// handle mentions
for _, m := range status.Mentions {
@ -92,12 +103,7 @@ func parseToot(status *mastodon.Status, stats *stats) error {
}
}
// clean up toot for terminal output
content := strings.Replace(status.Content, "<br>", "\n", -1)
content = strings.Replace(content, "<p>", "\n", -1)
content = strings.Replace(content, "</p>", "", -1)
content = html.UnescapeString(stripper.Sanitize(content))
content = strings.TrimSpace(strings.Replace(content, "\n", " ", -1))
content := cleanupContent(status.Content)
// handle replies
if status.InReplyToID != nil {