diff --git a/getArticles.go b/getArticles.go index 95a48c2..4ec8eb5 100644 --- a/getArticles.go +++ b/getArticles.go @@ -19,7 +19,6 @@ import ( // Get new articles for specified feed. func getArticles(feedURL string, max int, noExcerpt bool, filter []string, filterMessage []string) (string, error) { - type feedCache struct { LastChange string } @@ -36,7 +35,7 @@ func getArticles(feedURL string, max int, noExcerpt bool, filter []string, filte // Create configPath if not yet existing. cachePath = osCacheDir + "/feed-to-muc/" if _, err := os.Stat(cachePath); os.IsNotExist(err) { - err = os.MkdirAll(cachePath, 0700) + err = os.MkdirAll(cachePath, 0o700) if err != nil { log.Fatal("Error: Can't create cache path:", err) } @@ -59,7 +58,7 @@ func getArticles(feedURL string, max int, noExcerpt bool, filter []string, filte // Create cachePath if not yet existing. cachePath = home + "/.cache/feed-to-muc/" if _, err := os.Stat(cachePath); os.IsNotExist(err) { - err = os.MkdirAll(cachePath, 0700) + err = os.MkdirAll(cachePath, 0o700) if err != nil { log.Fatal("Error: Can't create cache path:", err) } @@ -75,7 +74,7 @@ func getArticles(feedURL string, max int, noExcerpt bool, filter []string, filte log.Fatal("Error: Can't create hash for", feedURL+":", err) } if _, err := os.Stat(cachePath); os.IsNotExist(err) { - err = os.MkdirAll(cachePath, 0700) + err = os.MkdirAll(cachePath, 0o700) if err != nil { log.Fatal("Error: Can't create hash identifier for cache file:", err) } @@ -102,7 +101,7 @@ func getArticles(feedURL string, max int, noExcerpt bool, filter []string, filte } else { - file, err = os.OpenFile(cacheFile, os.O_RDWR, 0600) + file, err = os.OpenFile(cacheFile, os.O_RDWR, 0o600) if err != nil { log.Fatal("Error: Can't open cache file:", err) } diff --git a/main.go b/main.go index 027e4b2..a18008a 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,6 @@ var ( ) func main() { - // Read path to config from command line option. configFilePtr := flag.String("config", "none", "path to configuration file") flag.Parse() @@ -91,8 +90,10 @@ func main() { } if output != "" { - _, err = client.Send(xmpp.Chat{Remote: config.Muc, - Type: "groupchat", Text: output}) + _, err = client.Send(xmpp.Chat{ + Remote: config.Muc, + Type: "groupchat", Text: output, + }) if err != nil { // ToDo: Save message for resend. // Exit if message can not be sent. diff --git a/openConfig.go b/openConfig.go index 1f08864..bde01a2 100644 --- a/openConfig.go +++ b/openConfig.go @@ -21,7 +21,7 @@ func openConfig(configFilePtr *string) configuration { // Create configPath if not yet existing. configPath = osConfigDir + "/.config/feed-to-muc/" if _, err := os.Stat(configPath); os.IsNotExist(err) { - err = os.MkdirAll(configPath, 0700) + err = os.MkdirAll(configPath, 0o700) if err != nil { log.Fatal("Error: Can't create config path: ", err) } @@ -42,7 +42,7 @@ func openConfig(configFilePtr *string) configuration { // Create configPath if not yet existing. configPath = home + "/.config/feed-to-muc/" if _, err := os.Stat(configPath + "config.json"); os.IsNotExist(err) { - err = os.MkdirAll(configPath, 0700) + err = os.MkdirAll(configPath, 0o700) if err != nil { log.Fatal("Error: Can't create config path: ", err) } @@ -67,7 +67,7 @@ func openConfig(configFilePtr *string) configuration { } if _, err := os.Stat(configFile); os.IsNotExist(err) { - err = os.MkdirAll(configPath, 0700) + err = os.MkdirAll(configPath, 0o700) if err != nil { log.Fatal("Error: Can't create config path: ", err) } diff --git a/processStanzas.go b/processStanzas.go index 9c11d65..f6a691f 100644 --- a/processStanzas.go +++ b/processStanzas.go @@ -68,14 +68,18 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str "\"source\": Show source code URL." if v.Type == "groupchat" { - _, err = client.Send(xmpp.Chat{Remote: muc, - Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply}) + _, err = client.Send(xmpp.Chat{ + Remote: muc, + Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply, + }) if err != nil { log.Fatal("Error: Failed sending message to MUC:", err) } } else if v.Type == "chat" { - _, err = client.Send(xmpp.Chat{Remote: v.Remote, - Type: "chat", Text: reply}) + _, err = client.Send(xmpp.Chat{ + Remote: v.Remote, + Type: "chat", Text: reply, + }) if err != nil { log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err) } @@ -88,14 +92,18 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str "https://salsa.debian.org/mdosch/feed-to-muc" if v.Type == "groupchat" { - _, err = client.Send(xmpp.Chat{Remote: muc, - Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply}) + _, err = client.Send(xmpp.Chat{ + Remote: muc, + Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply, + }) if err != nil { log.Fatal("Error: Failed sending message to MUC:", err) } } else if v.Type == "chat" { - _, err = client.Send(xmpp.Chat{Remote: v.Remote, - Type: "chat", Text: reply}) + _, err = client.Send(xmpp.Chat{ + Remote: v.Remote, + Type: "chat", Text: reply, + }) if err != nil { log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err) } @@ -111,14 +119,18 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str reply := "Feeds I'm following:\n" + feedList if v.Type == "groupchat" { - _, err = client.Send(xmpp.Chat{Remote: muc, - Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply}) + _, err = client.Send(xmpp.Chat{ + Remote: muc, + Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply, + }) if err != nil { log.Fatal("Error: Failed sending message to MUC:", err) } } else if v.Type == "chat" { - _, err = client.Send(xmpp.Chat{Remote: v.Remote, - Type: "chat", Text: reply}) + _, err = client.Send(xmpp.Chat{ + Remote: v.Remote, + Type: "chat", Text: reply, + }) if err != nil { log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err) } @@ -133,14 +145,18 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str } if v.Type == "groupchat" { - _, err = client.Send(xmpp.Chat{Remote: muc, - Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply}) + _, err = client.Send(xmpp.Chat{ + Remote: muc, + Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply, + }) if err != nil { log.Fatal("Error: Failed sending message to MUC:", err) } } else if v.Type == "chat" { - _, err = client.Send(xmpp.Chat{Remote: v.Remote, - Type: "chat", Text: reply}) + _, err = client.Send(xmpp.Chat{ + Remote: v.Remote, + Type: "chat", Text: reply, + }) if err != nil { log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err) } @@ -154,14 +170,18 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str } if v.Type == "groupchat" { - _, err = client.Send(xmpp.Chat{Remote: muc, - Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + contact}) + _, err = client.Send(xmpp.Chat{ + Remote: muc, + Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + contact, + }) if err != nil { log.Fatal("Error: Failed sending message to MUC:", err) } } else if v.Type == "chat" { - _, err = client.Send(xmpp.Chat{Remote: v.Remote, - Type: "chat", Text: contact}) + _, err = client.Send(xmpp.Chat{ + Remote: v.Remote, + Type: "chat", Text: contact, + }) if err != nil { log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err) } diff --git a/removeTracking.go b/removeTracking.go index 220b28e..1a07cc7 100644 --- a/removeTracking.go +++ b/removeTracking.go @@ -10,7 +10,6 @@ import ( // Remove tracking parameter from URLs func removeTracking(input string) (output string, err error) { - // Perform a get request to get rid of 301 forwarding through // services like feedproxy.google.com. resp, err := http.Get(input) diff --git a/sendPings.go b/sendPings.go index 06ad4c5..d3b664c 100644 --- a/sendPings.go +++ b/sendPings.go @@ -11,7 +11,6 @@ import ( // Send a ping every 30 seconds after last successful ping to check if the MUC is still available. func pingMUC(client *xmpp.Client, botJid string, muc string, mucNick string) { - var err error for {