specifiy state file in config
This commit is contained in:
parent
15b839d9a7
commit
03a5e56614
@ -7,3 +7,4 @@ prefix: "!tb"
|
||||
owm_api_key: "OpenWeatherMap API key"
|
||||
lat: "39.004608"
|
||||
long: "-76.875671"
|
||||
statefile: "state"
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user