diff --git a/commands.go b/commands.go index adf1f2c..824d985 100644 --- a/commands.go +++ b/commands.go @@ -27,10 +27,12 @@ func reset(m chat1.MsgSummary) { func authenticate(m chat1.MsgSummary) { defer log.PanicSafe() + log.LogDebug("Called authenticate()") if isAuthenticated(m) { k.SendMessageByConvID(m.ConvID, "You have already authenticated (please use !reset to reset.") return } + log.LogDebug("User was not already authenticated") if !m.IsEphemeral { k.SendMessageByConvID(m.ConvID, "Please remember to delete your message after we have authenticated!") } @@ -39,6 +41,7 @@ func authenticate(m chat1.MsgSummary) { k.SendMessageByConvID(m.ConvID, "Invalid input for command authenticate. Requires username and password. This information is not stored in keybase, or logged.") return } + log.LogDebug("Proper amount of parameters has been received, calling login()") username := parts[1] password := parts[2] t, err := login(context.Background(), username, password) @@ -46,6 +49,7 @@ func authenticate(m chat1.MsgSummary) { handleError(err, m, "There was an error logging in. Contact @rudi9719 for more information with code %+v") return } + log.LogDebug("Returned from login()") log.LogDebug("Token created for %+v", m.Sender.Username) _, err = k.KVPut(&m.Channel.Name, "teslabot", "authtok", t) if err != nil { diff --git a/helabot b/helabot index b930291..b827cad 100755 Binary files a/helabot and b/helabot differ diff --git a/login.go b/login.go index 76dfadb..83018b3 100644 --- a/login.go +++ b/login.go @@ -7,24 +7,26 @@ import ( "github.com/bogosj/tesla" ) -func noDevice(ctx context.Context, devices []tesla.Device) (d tesla.Device, passcode string, err error) { - return tesla.Device{}, "", nil -} func login(ctx context.Context, username string, password string) (string, error) { + defer log.PanicSafe() + + log.LogDebug("Creating client for %+v", username) client, err := tesla.NewClient( ctx, tesla.WithCredentials(username, password), ) + log.LogDebug("Created client for %+v", username) if err != nil { log.LogErrorType(err) return "", err } - + log.LogDebug("Creating token for %+v", username) t, err := client.Token() if err != nil { log.LogErrorType(err) return "", err } + log.LogDebug("Created token for %+v", username) ret, err := json.Marshal(t) if err != nil { log.LogErrorType(err)