specifiy state file in config

This commit is contained in:
stryan 2020-04-21 16:18:09 -04:00
parent 15b839d9a7
commit 03a5e56614
3 changed files with 7 additions and 4 deletions

View File

@ -7,3 +7,4 @@ prefix: "!tb"
owm_api_key: "OpenWeatherMap API key"
lat: "39.004608"
long: "-76.875671"
statefile: "state"

View File

@ -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()

View File

@ -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)
}