mirror of
https://salsa.debian.org/mdosch/feed-to-muc.git
synced 2024-11-26 07:50:59 +01:00
Added linebreaks and comments.
This commit is contained in:
parent
1eca8a84b4
commit
6f754bd8f6
1 changed files with 9 additions and 4 deletions
|
@ -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", "<ping xmlns='urn:xmpp:ping'/>")
|
||||
id, err := client.RawInformation(botJid, Muc+"/"+MucNick, sid.Id(),
|
||||
"get", "<ping xmlns='urn:xmpp:ping'/>")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -206,5 +212,4 @@ func pingServer(client *xmpp.Client, server string, botJid string) {
|
|||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue