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 password: SimpQAhoy
dimension: dimension.saintnet.tech dimension: dimension.saintnet.tech
domain: saintnet.tech domain: saintnet.tech
statefile: statefile
vtubers: vtubers:
- name: Ina - name: Ina
channelid: UCMwGHR0BTZuLsmjY_NT5Pwg channelid: UCMwGHR0BTZuLsmjY_NT5Pwg

View File

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