Made refresh time for feed queries configurable.

This commit is contained in:
Martin Dosch 2018-09-05 20:40:41 +02:00
parent 7e2c58256d
commit e0d4613023
3 changed files with 15 additions and 2 deletions

View file

@ -45,8 +45,14 @@ If the flag `-config` is not used the configuration is expected at
"Muc": "muc-to-feed@conference.example.com",
"MucNick": "feedbot",
"MaxArticles": 5,
"RefreshTime": 30,
"NoExcerpt": false,
"Feeds": [ "https://www.debian.org/News/news",
"https://www.debian.org/security/dsa-long" ]
}
```
`MaxArticles` is the maximum number of articles that are sent per
feed and query. If `NoExcerpt` is set to *true* no excerpt will be
posted. `RefreshTime` defines the intervall for checking the feeds
in seconds.

View file

@ -5,6 +5,7 @@
"Muc": "muc-to-feed@conference.example.com",
"MucNick": "feedbot",
"MaxArticles": 5,
"RefreshTime": 30,
"NoExcerpt": false,
"Feeds": [ "https://www.debian.org/News/news",
"https://www.debian.org/security/dsa-long" ]

View file

@ -36,6 +36,7 @@ func main() {
Muc string
MucNick string
MaxArticles int
RefreshTime time.Duration
NoExcerpt bool
Feeds []string
}
@ -144,6 +145,11 @@ func main() {
// Starting goroutine to process received stanzas.
go processStanzas(client)
// Set RefreshTime to 30 seconds if not defined.
if config.RefreshTime == 0 {
config.RefreshTime = 30
}
for {
// Check all configured feeds for new articles and send
// new articles to configured MUC.
@ -165,7 +171,7 @@ func main() {
}
}
// Wait 30 seconds before checking feeds again.
time.Sleep(30 * time.Second)
time.Sleep(config.RefreshTime * time.Second)
}
}