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"
|
owm_api_key: "OpenWeatherMap API key"
|
||||||
lat: "39.004608"
|
lat: "39.004608"
|
||||||
long: "-76.875671"
|
long: "-76.875671"
|
||||||
|
statefile: "state"
|
||||||
|
@ -34,6 +34,7 @@ func main() {
|
|||||||
Bot: b,
|
Bot: b,
|
||||||
Conf: c,
|
Conf: c,
|
||||||
Jobs: make(chan *mautrix.Event, 100),
|
Jobs: make(chan *mautrix.Event, 100),
|
||||||
|
StateFile: viper.GetString("statefile"),
|
||||||
}
|
}
|
||||||
tb.InitActions()
|
tb.InitActions()
|
||||||
tb.InitScheduler()
|
tb.InitScheduler()
|
||||||
|
@ -19,6 +19,7 @@ type TestBot struct {
|
|||||||
Conf *botlib.Config
|
Conf *botlib.Config
|
||||||
Jobs chan *mautrix.Event
|
Jobs chan *mautrix.Event
|
||||||
Scheduler *gocron.Scheduler
|
Scheduler *gocron.Scheduler
|
||||||
|
StateFile string
|
||||||
schan chan struct{} //for stoping scheduler
|
schan chan struct{} //for stoping scheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ func (t *TestBot) DumpState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TestBot) LoadState() {
|
func (t *TestBot) LoadState() {
|
||||||
dat, err := ioutil.ReadFile("state")
|
dat, err := ioutil.ReadFile(t.StateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user