open-wa / wa-automate-python

💬 🤖 The most advanced Python whatsapp library for chatbots with advanced features. Be sure to ⭐ this repository for updates!
Other
330 stars 71 forks source link

New ack listener not working #34

Closed riquedev closed 3 years ago

riquedev commented 3 years ago

Guys, even using the subscribe method next to the observer I am not having the new visualizations report in any test. New messages works normally, what can I do to try to correct this?

Ps .: I tried to adjust according to previous versions, but without success ...

Here are the old snippets in JS that I added again:


WAPI._newAcksBuffer = (sessionStorage.getItem('saved_acks') != null) ? JSON.parse(sessionStorage.getItem('saved_acks')) : [];
WAPI._participantChangesBuffer = (sessionStorage.getItem('parti_changes') != null) ? JSON.parse(sessionStorage.getItem('parti_changes')) : [];
WAPI._liveLocUpdatesBuffer = (sessionStorage.getItem('liveloc_updates') != null) ? JSON.parse(sessionStorage.getItem('liveloc_updates')) : [];
WAPI._newAcksBuffer = (sessionStorage.getItem('saved_acks') != null) ? JSON.parse(sessionStorage.getItem('saved_acks')) : [];

window.Store.Msg.off('add');
sessionStorage.removeItem('saved_msgs');

window.WAPI._newAcksListener = Store.Msg.on("change:ack", msg => {
    let message = window.WAPI.processMessageObj(msg, true, false);
    if (message) {
        window.WAPI._newAcksBuffer.push(message)
    }
});

I also checked wapi_js_wrapper.py and everything seems to be fine, it waits for "new_acks"

new_js_acks = js_events['new_acks']

if isinstance(new_js_acks, list) and len(new_js_acks) > 0:
  new_acks = []

  for js_ack in new_js_acks:
    new_acks.append(factory_message(js_ack, self.wapi_driver))

  self._inform_new_acks(new_acks)

Environment:

riquedev commented 3 years ago

Guys, even using the subscribe method next to the observer I am not having the new visualizations report in any test. New messages works normally, what can I do to try to correct this?

Ps .: I tried to adjust according to previous versions, but without success ...

Here are the old snippets in JS that I added again:

WAPI._newAcksBuffer = (sessionStorage.getItem('saved_acks') != null) ? JSON.parse(sessionStorage.getItem('saved_acks')) : [];
WAPI._participantChangesBuffer = (sessionStorage.getItem('parti_changes') != null) ? JSON.parse(sessionStorage.getItem('parti_changes')) : [];
WAPI._liveLocUpdatesBuffer = (sessionStorage.getItem('liveloc_updates') != null) ? JSON.parse(sessionStorage.getItem('liveloc_updates')) : [];
WAPI._newAcksBuffer = (sessionStorage.getItem('saved_acks') != null) ? JSON.parse(sessionStorage.getItem('saved_acks')) : [];

window.Store.Msg.off('add');
sessionStorage.removeItem('saved_msgs');

window.WAPI._newAcksListener = Store.Msg.on("change:ack", msg => {
    let message = window.WAPI.processMessageObj(msg, true, false);
    if (message) {
        window.WAPI._newAcksBuffer.push(message)
    }
});

I also checked wapi_js_wrapper.py and everything seems to be fine, it waits for "new_acks"

new_js_acks = js_events['new_acks']

if isinstance(new_js_acks, list) and len(new_js_acks) > 0:
  new_acks = []

  for js_ack in new_js_acks:
    new_acks.append(factory_message(js_ack, self.wapi_driver))

  self._inform_new_acks(new_acks)

Environment:

  • Centos 7
  • geckodriver v0.26.0
  • Firefox nightly (latest)
  • Python 3

I managed to solve it! The event has changed, now it's change:msg:ack and not change:ack