Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.07k stars 493 forks source link

Auto update (bump) minor version #632

Open gabstv opened 2 years ago

gabstv commented 2 years ago

An attempt to avoid errors like #631 It's disabled by default to keep the original behaviour of this library:

whatsapp.AutoUpdate = true
// this will bump the minor version by 10 if the command "update" is received on login
whatsapp.AutoUpdateIncrement = 10
whatsapp.AutoUpdateMaxRetries = 100
whatsapp.AutoUpdateRetryDelay = time.Millisecond * 500

This PR also returns a proper error instead of the usual "JSON marshal failed" (check whatsapp.ErrUpdateRequired), so you can also act manually if this error is received.