Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Reading Unread Messages & Marking them as Read #98

Open
KarthikAbiram opened this issue Jan 22, 2022 · 0 comments
Open

Issue with Reading Unread Messages & Marking them as Read #98

KarthikAbiram opened this issue Jan 22, 2022 · 0 comments

Comments

@KarthikAbiram
Copy link

I am trying to read unread messages using the below code. I did not get any messages with the default arguments for the 'get_unread' method. But by passing 'use_unread_count', I am able to get the list of unread messages. But one issue is, it doesn't mark these chat messages as 'read' in mobile (it does get marked as read in browser view). So, when I rerun below code, it again returns the older messages.

from openwa import WhatsAPIDriver, MessageGroup
import time

driver = WhatsAPIDriver()

print("Waiting for QR")
while not driver.wait_for_login():
    time.sleep(3)

print("Bot started")

print("Getting Existing Unread Messages..")

# # Get Unread Messages
message_groups = driver.get_unread(use_unread_count=True)
print(message_groups)
for i,message_group in enumerate(message_groups):
    for j,msg in enumerate(message_group.messages):
        print(f'Message {j}: {msg}')
        # Mark Chat as Read
        driver.chat_send_seen(msg.chat_id)
        try:
            print(f'Message Content is: {msg.content}')
        except:
            pass

print('Bot stopped')

Instead of using the code, if I manually click a chat in the launched browser window, it does get marked as read in both browser and mobile. Is there anyway I can mark the chat as read in mobile as well, so that the messages don't get returned during the next run.

OS: Windows 10
Python: 3.7.9 64-bit
openwa: 1.3.16 (installed using pipenv)
Browser: Firefox using gecko driver

PS: I also tried "driver.chat_send_seen(msg.chat_id)", but that didn't help in marking the chat as read in mobile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant