Rhymen / go-whatsapp

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

HandleRawMessage and WhatsappWeb limited to 1000 initial messages #220

Open ExecGnosis opened 4 years ago

ExecGnosis commented 4 years ago

Hello!

First of all, i would like to thank you all people who collaborate with this project, you all inspired me to learn Golang, so i could implement my own solution using this amazing API.

Well, let's talk about the problem:

I have 1281 conversations in my Whatsapp, but i only can pull 1000 of them by the method being utilized in the ChatHistory example. I tryed myself to "investigate", and when i opened Whatsapp Web, i saw this:

whatshapp number

Basically, Whatsapp still manages to show all the conversations i had, even without "message preview" after the thousand conversation (because ChatHistory and Whatsapp Web are not pulling the messages after this).

I forced a disconnection on Whatsapp Web while i'm still looking at the thousand conversation and then, after the reconnection, he pulled the "message previews" that were previously unavaible. So, i'm considering that on reconnection he uses my "scroll position" and the conversations visible to me so he can pull 1000 messages ahead.

I took a look around before creating this issue and i didn't found anything on that topic (if i missed something, please let me know), so i would like to discuss a possible implementation to overcome this.

Thanks for all, sorry for the long text 😉

hrizal commented 4 years ago

check go-whatsapp/examples/echo/main.go

if you are using sample from receiveMessages,

line 16, change with type waHandler struct { wac *whatsapp.Conn startTime uint64 }

on line 39, add like below
if message.Info.FromMe || message.Info.Timestamp < wh.startTime { return }

finally ...

on line 69, change with wac.AddHandler(&waHandler{wac, uint64(time.Now().Unix())})