@@ 31,7 31,7 @@ type theFeed struct {
func main() {
// get config parameters
- server, clientId, clientSecret, username, password, feedURL := readConfig()
+ interval, server, clientId, clientSecret, username, password, feedURL := readConfig()
// daemonize
cntxt := &daemon.Context{
@@ 69,7 69,7 @@ func main() {
// run every x times and blocks the program to keep it running
cron := gocron.NewScheduler(time.UTC)
- cron.Every(5).Minutes().Do(mastodonTask, c, feedURL)
+ cron.Every(interval).Minutes().Do(mastodonTask, c, feedURL)
cron.StartBlocking()
}
@@ 152,7 152,7 @@ func parseCredentials(command string) (string, error) {
return sec, nil
}
-func readConfig() (string, string, string, string, string, string) {
+func readConfig() (int, string, string, string, string, string, string) {
// read config.ini
// get all parameters
@@ 163,6 163,7 @@ func readConfig() (string, string, string, string, string, string) {
os.Exit(1)
}
+ interval := cfg.Section("general").Key("interval").MustInt()
server := cfg.Section("mastodon").Key("server").String()
clientId, err := parseCredentials(cfg.Section("mastodon").Key("client_id").String())
clientSecret, err := parseCredentials(cfg.Section("mastodon").Key("client_secret").String())
@@ 173,5 174,5 @@ func readConfig() (string, string, string, string, string, string) {
log.Fatal(err)
}
- return server, clientId, clientSecret, username, password, feedURL
+ return interval, server, clientId, clientSecret, username, password, feedURL
}