make statefile configurable

This commit is contained in:
stryan 2021-06-25 14:05:57 -04:00
parent 734896fe93
commit a4c2fc4b37
2 changed files with 5 additions and 1 deletions

View File

@ -3,6 +3,7 @@ username: SimpBot
password: SimpQAhoy
dimension: dimension.saintnet.tech
domain: saintnet.tech
statefile: statefile
vtubers:
- name: Ina
channelid: UCMwGHR0BTZuLsmjY_NT5Pwg

View File

@ -17,6 +17,7 @@ var Password string
var DimensionServer string
var HomeserverDomain string
var GitCommit string
var Statefile string
func main() {
viper.SetConfigName("config")
@ -28,17 +29,19 @@ func main() {
viper.SetConfigType("yaml")
Homeserver = viper.GetString("homeserver")
viper.SetDefault("domain", Homeserver)
viper.SetDefault("statefile", "simpstate")
Username = viper.GetString("username")
Password = viper.GetString("password")
DimensionServer = viper.GetString("dimension")
HomeserverDomain = viper.GetString("domain")
Statefile = viper.GetString("statefile")
var vtubers []*Vtuber
log.Println("Logging into", Homeserver, "as", Username)
client, err := mautrix.NewClient(Homeserver, "", "")
if err != nil {
panic(err)
}
client.Store = NewLazyMemStore("statedata")
client.Store = NewLazyMemStore(Statefile)
_, err = client.Login(&mautrix.ReqLogin{
Type: "m.login.password",
Identifier: mautrix.UserIdentifier{Type: mautrix.IdentifierTypeUser, User: Username},