package main import ( "io/ioutil" "log" "os" "strings" "git.saintnet.tech/stryan/vega/botlib" "maunium.net/go/mautrix" ) type TestBot struct { Bot *botlib.Bot Conf *botlib.Config Jobs chan *mautrix.Event } func (t *TestBot) Shutdown() { log.Printf("%v is shutting down", t.Conf.Name) t.Bot.Client.StopSync() t.DumpState() os.Exit(0) } func (t *TestBot) DumpState() { id := []byte(t.Bot.ManagementRoomID) err := ioutil.WriteFile("state", id, 0644) if err != nil { log.Fatal(err) } } func (t *TestBot) LoadState() { dat, err := ioutil.ReadFile("state") if err != nil { log.Fatal(err) } t.Bot.ManagementRoomID = strings.Trim(string(dat), "") }