Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.06k stars 491 forks source link

info["is24h"] is nil #22

Closed jointfull closed 6 years ago

jointfull commented 6 years ago

As it seems, the session info field named 'Is24h' may be empty, so a safer conversion should be used instead of the current info["is24h"].(bool) (in session.go, line 78).

panic: interface conversion: interface {} is nil, not bool

goroutine 1 [running]:
github.com/Rhymen/go-whatsapp.newInfoFromReq(0xc0421140f0, 0xc042114180)
    C:/Workspace/GoProjects/WhatsAppWeb/src/github.com/Rhymen/go-whatsapp/session.go:78 +0xa7c
github.com/Rhymen/go-whatsapp.(*Conn).RestoreSession(0xc0420da070, 0xc042102380, 0x18, 0xc04210e2a0, 0x2c, 0xc042014240, 0x52, 0xc0421023a0, 0x20, 0x20, ...)
    C:/Workspace/GoProjects/WhatsAppWeb/src/github.com/Rhymen/go-whatsapp/session.go:319 +0x15d0
github.com/Rhymen/go-whatsapp/automation/infra.Login(0xc0420da070, 0xc04213a080, 0x40, 0x40, 0x0)
    C:/Workspace/GoProjects/WhatsAppWeb/src/github.com/Rhymen/go-whatsapp/automation/infra/login.go:16 +0x37c
main.main()
    C:/Workspace/GoProjects/WhatsAppWeb/src/github.com/rhymen/go-whatsapp/automation/automation.go:113 +0x422
Rhymen commented 6 years ago

I added a nil check so that the error should not appear anymore, thanks.

jointfull commented 6 years ago

Working now, thanks!