diff --git a/README.md b/README.md index c705194..4bdcde9 100644 --- a/README.md +++ b/README.md @@ -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, -"NoExcerpt": false, +"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. \ No newline at end of file diff --git a/config.json.example b/config.json.example index 2bd6364..af954b9 100644 --- a/config.json.example +++ b/config.json.example @@ -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" ] diff --git a/feed-to-muc.go b/feed-to-muc.go index 6603262..18e8e77 100644 --- a/feed-to-muc.go +++ b/feed-to-muc.go @@ -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) } }