~rek2/goTootRamdonVideo

bb4c5c4333b8f80fb4abaa25437f23e91e0d61ad — rek2 3 years ago 8e34443
added interval int to config and main
2 files changed, 8 insertions(+), 4 deletions(-)

M config.ini
M main.go
M config.ini => config.ini +3 -0
@@ 1,3 1,6 @@
[general]
interval = 60

[mastodon]
server = https://hispagatos.space
client_id = `gopass show -o -f gotootramdonvideo/clientid`

M main.go => main.go +5 -4
@@ 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
}