Update go-whatsapp to handle unknown ping responses

This commit is contained in:
Tulir Asokan 2020-06-23 15:36:08 +03:00
parent 58de73f8b2
commit 63a1a77f26
4 changed files with 7 additions and 11 deletions

View file

@ -412,19 +412,13 @@ func (handler *CommandHandler) CommandPing(ce *CommandEvent) {
}
} else if ce.User.Conn == nil {
ce.Reply("You don't have a WhatsApp connection.")
} else if ok, err := ce.User.Conn.AdminTest(); err != nil {
} else if err := ce.User.Conn.AdminTest(); err != nil {
if ce.User.IsLoginInProgress() {
ce.Reply("Connection not OK: %v, but login in progress", err)
} else {
ce.Reply("Connection not OK: %v", err)
}
} else if !ok {
if ce.User.IsLoginInProgress() {
ce.Reply("Connection not OK, but no error received and login in progress")
} else {
ce.Reply("Connection not OK, but no error received")
}
} else {
} else {
ce.Reply("Connection to WhatsApp OK")
}
}

2
go.mod
View file

@ -19,4 +19,4 @@ require (
github.com/prometheus/client_golang v1.6.0
)
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.3.0
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.3.1

2
go.sum
View file

@ -116,6 +116,8 @@ github.com/tulir/go-whatsapp v0.2.9 h1:hagfBU+oqFzXw3Wb4U/ugR2kOZAzJDq3RVIzyz74c
github.com/tulir/go-whatsapp v0.2.9/go.mod h1:gyw9zGup1/Y3ZQUueZaqz3iR/WX9a2Lth4aqEbXjkok=
github.com/tulir/go-whatsapp v0.3.0 h1:68aLiPNaWDWMnH3WMw/z2as6KsmBnCMyn+Lkk5i1v70=
github.com/tulir/go-whatsapp v0.3.0/go.mod h1:7yGOBdWidM6gsmbAFwgkwHEIhzVrm01+6UbImpMWfTM=
github.com/tulir/go-whatsapp v0.3.1 h1:WEiRaG1zlmS0+MHwPbURqQEy3ZqofJ9UgS+UZD1KAOQ=
github.com/tulir/go-whatsapp v0.3.1/go.mod h1:7yGOBdWidM6gsmbAFwgkwHEIhzVrm01+6UbImpMWfTM=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

View file

@ -247,9 +247,9 @@ func (prov *ProvisioningAPI) Ping(w http.ResponseWriter, r *http.Request) {
"is_logged_in": user.Conn.IsLoggedIn(),
"is_login_in_progress": user.Conn.IsLoginInProgress(),
}
ok, err := user.Conn.AdminTest()
err := user.Conn.AdminTest()
wa["ping"] = map[string]interface{}{
"ok": ok,
"ok": err == nil,
"err": err,
}
}