mirror of
https://salsa.debian.org/mdosch/feed-to-muc.git
synced 2024-11-22 22:18:39 +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)
|
go pingMUC(client, config.BotJid, config.Muc, config.MucNick)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
// Check all configured feeds for new articles and send
|
||||||
|
// new articles to configured MUC.
|
||||||
for i := 0; i < len(config.Feeds); i++ {
|
for i := 0; i < len(config.Feeds); i++ {
|
||||||
output, err := getArticles(config.Feeds[i], config.MaxArticles)
|
output, err := getArticles(config.Feeds[i], config.MaxArticles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Exit if an error occurs checking the feeds.
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if output != "" {
|
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 {
|
if err != nil {
|
||||||
// ToDo: Save message for resend.
|
// ToDo: Save message for resend.
|
||||||
|
// Exit if message can not be sent.
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Wait 30 seconds before checking feeds again.
|
||||||
time.Sleep(30 * time.Second)
|
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)
|
time.Sleep(30 * time.Second)
|
||||||
|
|
||||||
// Send ping to own MUC participant to check we are still joined.
|
// 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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -206,5 +212,4 @@ func pingServer(client *xmpp.Client, server string, botJid string) {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue