bogosj / tesla

Provides a wrapper around the API to easily query and command a Telsa car.
Other
22 stars 18 forks source link

Add captcha-solving callback #57

Closed andig closed 3 years ago

andig commented 3 years ago

Fix #56.

Todos:

andig commented 3 years ago

Imho the staticcheck is broken as it does not respect the replace directive. Upgrade or get rid of the check?

Should be ready for review.

bogosj commented 3 years ago

Re: staticcheck - I'd prefer to keep it around and consciously ignore errors we know aren't actually errors.

andig commented 3 years ago

Shall we include the captcha solver (legal?) or do something simple like:

tmpFile, err := ioutil.TempFile(os.TempDir(), "captcha-*.svg")
if err != nil {
    return "", fmt.Errorf("cannot create temp file: %w", err)
}

if _, err := io.Copy(tmpFile, svg); err != nil {
    return "", fmt.Errorf("cannot write temp file: %w", err)
}

_ = tmpFile.Close()

if err := open.Run(tmpFile.Name()); err != nil {
    return "", fmt.Errorf("cannot open captcha for display: %w", err)
}

fmt.Println("Captcha is now being opened in default application for svg files.")
fmt.Println()

fmt.Print("Please enter captcha: ")
reader := bufio.NewReader(os.Stdin)
captcha, err := reader.ReadString('\n')

return strings.TrimSpace(captcha), err
andig commented 3 years ago

I've changed it anyway to get rid of the forked dependency. IMHO ready to merge. And given https://github.com/bogosj/tesla/issues/58 should we also do a 1.1.0 release then?