(Hopefully) made help output look more nice.

This commit is contained in:
mdosch 2019-05-26 21:00:43 +02:00
parent 7fc8907608
commit 5c24584476
2 changed files with 13 additions and 3 deletions

View file

@ -251,8 +251,8 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
_, err = client.Send(xmpp.Chat{Remote: muc,
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] +
": The following commands are available:\n" +
"feeds\t" + "List feeds I'm following.\n" +
"source\t" + "Show source code URL."})
"feeds " + "List feeds I'm following.\n" +
"source " + "Show source code URL."})
if err != nil {
log.Fatal(err)
}

View file

@ -209,13 +209,23 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
return "", err
}
// To make the message look not so bloated we remove multiple newlines.
// Split the article description/content into fragments between newlines.
fragments := strings.Split(description, "\n")
// Empty article description/content
description = ""
// Fill article description/content with the fragments separated by one newline.
for _, line := range fragments {
description = description + line + "n"
}
// 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 + feed.Title + ": *" + article.Title + "*\n\n" + description + cleanURL
}
}