From 03a5e56614c173f37ff2999a7f49b15e5411b70d Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 21 Apr 2020 16:18:09 -0400 Subject: [PATCH] specifiy state file in config --- testbot/config.yaml.sample | 1 + testbot/main.go | 7 ++++--- testbot/testbot.go | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/testbot/config.yaml.sample b/testbot/config.yaml.sample index bbc8ff7..9c7c3aa 100644 --- a/testbot/config.yaml.sample +++ b/testbot/config.yaml.sample @@ -7,3 +7,4 @@ prefix: "!tb" owm_api_key: "OpenWeatherMap API key" lat: "39.004608" long: "-76.875671" +statefile: "state" diff --git a/testbot/main.go b/testbot/main.go index 01cc78e..e0aaa7b 100644 --- a/testbot/main.go +++ b/testbot/main.go @@ -31,9 +31,10 @@ func main() { } b := botlib.NewBot(c) tb := &TestBot{ - Bot: b, - Conf: c, - Jobs: make(chan *mautrix.Event, 100), + Bot: b, + Conf: c, + Jobs: make(chan *mautrix.Event, 100), + StateFile: viper.GetString("statefile"), } tb.InitActions() tb.InitScheduler() diff --git a/testbot/testbot.go b/testbot/testbot.go index 3a09af2..12df0d2 100644 --- a/testbot/testbot.go +++ b/testbot/testbot.go @@ -19,6 +19,7 @@ type TestBot struct { Conf *botlib.Config Jobs chan *mautrix.Event Scheduler *gocron.Scheduler + StateFile string schan chan struct{} //for stoping scheduler } @@ -43,7 +44,7 @@ func (t *TestBot) DumpState() { } func (t *TestBot) LoadState() { - dat, err := ioutil.ReadFile("state") + dat, err := ioutil.ReadFile(t.StateFile) if err != nil { log.Fatal(err) }