diff --git a/feed-to-muc.go b/feed-to-muc.go
index f220013..f2795b0 100644
--- a/feed-to-muc.go
+++ b/feed-to-muc.go
@@ -133,21 +133,26 @@ func main() {
go pingMUC(client, config.BotJid, config.Muc, config.MucNick)
for {
-
+ // Check all configured feeds for new articles and send
+ // new articles to configured MUC.
for i := 0; i < len(config.Feeds); i++ {
output, err := getArticles(config.Feeds[i], config.MaxArticles)
if err != nil {
+ // Exit if an error occurs checking the feeds.
log.Fatal(err)
}
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.
log.Fatal(err)
}
}
}
+ // Wait 30 seconds before checking feeds again.
time.Sleep(30 * time.Second)
}
}
@@ -158,7 +163,8 @@ func pingMUC(client *xmpp.Client, botJid string, Muc string, MucNick string) {
time.Sleep(30 * time.Second)
// Send ping to own MUC participant to check we are still joined.
- id, err := client.RawInformation(botJid, Muc+"/"+MucNick, sid.Id(), "get", "")
+ id, err := client.RawInformation(botJid, Muc+"/"+MucNick, sid.Id(),
+ "get", "")
if err != nil {
log.Fatal(err)
}
@@ -206,5 +212,4 @@ func pingServer(client *xmpp.Client, server string, botJid string) {
log.Fatal(err)
}
}
-
}