[golangci-lint] Changed formatting.

This commit is contained in:
Martin Dosch 2019-08-30 12:30:30 +02:00
parent 975404f2e6
commit 69a5eeb7b6
2 changed files with 12 additions and 9 deletions

View file

@ -189,15 +189,15 @@ func pingMUC(client *xmpp.Client, botJid string, muc string, mucNick string) {
pingReceived = false pingReceived = false
// Check for result IQ as long as there was no reply yet. // Check for result IQ as long as there was no reply yet.
for (time.Since(pingSent).Seconds() < 10.0) && (pingReceived == false) { for (time.Since(pingSent).Seconds() < 10.0) && (!pingReceived) {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
if pingReceived == true { if pingReceived {
break break
} }
} }
// Quit if no ping reply was received. // Quit if no ping reply was received.
if pingReceived == false { if !pingReceived {
log.Fatal("MUC not available.") log.Fatal("MUC not available.")
} }
} }
@ -232,7 +232,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
// Check for room mention of the bots nick if the the message type is groupchat. // Check for room mention of the bots nick if the the message type is groupchat.
if v.Type == "groupchat" { if v.Type == "groupchat" {
// Leave if option quiet is set. // Leave if option quiet is set.
if quiet == true { if quiet {
break break
} }
// Get first word of the message and transform it to lower case. // Get first word of the message and transform it to lower case.
@ -384,7 +384,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
if v.Type == "get" { if v.Type == "get" {
// Reply to disco#info requests according to https://xmpp.org/extensions/xep-0030.html. // Reply to disco#info requests according to https://xmpp.org/extensions/xep-0030.html.
if strings.Contains(string(v.Query), if strings.Contains(string(v.Query),
"<query xmlns='http://jabber.org/protocol/disco#info'/>") == true { "<query xmlns='http://jabber.org/protocol/disco#info'/>") {
_, err := client.RawInformation(client.JID(), v.From, v.ID, _, err := client.RawInformation(client.JID(), v.From, v.ID,
"result", "<query xmlns='http://jabber.org/protocol/disco#info'>"+ "result", "<query xmlns='http://jabber.org/protocol/disco#info'>"+
"<identity category='client' type='bot' name='feedbot'/>"+ "<identity category='client' type='bot' name='feedbot'/>"+
@ -392,7 +392,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
if err != nil { if err != nil {
log.Fatal("Error: Failed to reply to disco#info:", err) log.Fatal("Error: Failed to reply to disco#info:", err)
} }
} else if strings.Contains(string(v.Query), "<ping xmlns='urn:xmpp:ping'/>") == true { } else if strings.Contains(string(v.Query), "<ping xmlns='urn:xmpp:ping'/>") {
// Reply to pings. // Reply to pings.
_, err := client.RawInformation(client.JID(), v.From, v.ID, "result", "") _, err := client.RawInformation(client.JID(), v.From, v.ID, "result", "")
if err != nil { if err != nil {

View file

@ -13,8 +13,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/mmcdole/gofeed"
"github.com/jaytaylor/html2text" "github.com/jaytaylor/html2text"
"github.com/mmcdole/gofeed"
) )
// Get new articles for specified feed. // Get new articles for specified feed.
@ -70,7 +70,10 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
// Create a hash as identifier for the feed. // Create a hash as identifier for the feed.
// The identifier will be used as filename for caching the update time. // The identifier will be used as filename for caching the update time.
h := fnv.New32a() h := fnv.New32a()
h.Write([]byte(feedURL)) _, err := h.Write([]byte(feedURL))
if err != nil {
log.Fatal("Error: Can't create hash for", feedURL+":", err)
}
if _, err := os.Stat(cachePath); os.IsNotExist(err) { if _, err := os.Stat(cachePath); os.IsNotExist(err) {
err = os.MkdirAll(cachePath, 0700) err = os.MkdirAll(cachePath, 0700)
if err != nil { if err != nil {
@ -167,7 +170,7 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
// Note: Checking for cached timestamp being newer, instead of not older // Note: Checking for cached timestamp being newer, instead of not older
// lead to duplicate messages for the same article. Probably a corner // lead to duplicate messages for the same article. Probably a corner
// case when the time is identical. // case when the time is identical.
if last.Before(updateTime) == false { if !last.Before(updateTime) {
continue continue
} }