diff --git a/client.go b/client.go index c63af16..916ab40 100644 --- a/client.go +++ b/client.go @@ -3,6 +3,7 @@ package main import ( "fmt" "log" + "strings" "maunium.net/go/mautrix" "maunium.net/go/mautrix/id" @@ -12,6 +13,8 @@ func newMatrixClient(config *botConfig) *mautrix.Client { fmt.Println("Logging into", config.Homeserver, "as", config.Username) var client *mautrix.Client var err error + //make sure username is lower case otherwise token login breaks + uname := strings.ToLower(config.Username) if config.Token == "" { client, err = mautrix.NewClient(config.Homeserver, "", "") if err != nil { @@ -19,7 +22,7 @@ func newMatrixClient(config *botConfig) *mautrix.Client { } } else { log.Println("using token login") - client, err = mautrix.NewClient(config.Homeserver, id.NewUserID(config.Username, config.Domain), config.Token) + client, err = mautrix.NewClient(config.Homeserver, id.NewUserID(uname, config.Domain), config.Token) if err != nil { panic(err) } @@ -28,7 +31,7 @@ func newMatrixClient(config *botConfig) *mautrix.Client { if config.Token == "" { loginRes, err := client.Login(&mautrix.ReqLogin{ Type: "m.login.password", - Identifier: mautrix.UserIdentifier{Type: mautrix.IdentifierTypeUser, User: config.Username}, + Identifier: mautrix.UserIdentifier{Type: mautrix.IdentifierTypeUser, User: uname}, Password: config.Password, StoreCredentials: true, })