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

get_unread_messages_in_chat is broken #84

Closed darkash closed 2 years ago

darkash commented 2 years ago

I was trying to give an alternative to #76 by using this function to load the messages by chat room, but the function will raise an exception when there is/are unread message(s). Upon inspecting it further, the function getUnreadMessagesInChat in wapi.js is returning an array of promises and hence when pyFunc try resolve the promise, it does not resolve all the promise members (at least from my understanding) and selenium read it as an array empty objects causing factory_message to fail mapping it to python objects.

The concept script in question

chats = driver.wapi_functions.getAllChatsWithNewMsg()
if chats and len(chats) > 0:
    for chat in chats:
        chat_id = chat['id']
        messages = driver.get_unread_messages_in_chat(chat_id) # this will error on factory_message
        for msg in messages:
            print(message.content)

tagging @mrodal

mrodal commented 2 years ago

Indeed, now its returning an array of promises, it didnt happen before.. I talked with the owner of the project and asked me to open an issue, please follow https://github.com/open-wa/wa-automate-nodejs/issues/2021

fire17 commented 2 years ago

You guys are awesome... My workaround stop for working for a while yesterday and now it's working again :) any chance this fixes #76 ???

darkash commented 2 years ago

You guys are awesome... My workaround stop for working for a while yesterday and now it's working again :) any chance this fixes #76 ???

you can try, but let's just keep that discussion on that issue

Indeed, now its returning an array of promises, it didnt happen before.. I talked with the owner of the project and asked me to open an issue, please follow open-wa/wa-automate-nodejs#2021

I see, the issue got fixed over there, I will check once I had access to my laptop I will reopen when the issue still persists


Edit: it's confirmed to be fixed