Closed jinfeei closed 6 years ago
This may not be exactly what you're looking for, but if you directly execute this script using the driver, it will mark the messages as read:
var originalID = Store.Chat.models[0].id;
Store.Chat.models[0].id = arguments[0];
Store.Chat.models[0].sendSeen();
Store.Chat.models[0].id = originalID;
The arguments[0] is the chatID of the Chat that you want to mark as read.
@Tschipp : I am using echo.py example and unable to understand where should i put your provided sample code.
Can you please help?
import time
from webwhatsapi import WhatsAPIDriver
from webwhatsapi.objects.message import Message
import requests
driver = WhatsAPIDriver(loadstyles=True,profile="/Users/tapankumarthapa/Library/Application Support/Firefox/Profiles/2qw4xd77.xxxxxxx")
print("Waiting for QR")
driver.wait_for_login()
print("Bot started")
wa_server_number = 'xxxxxx'
while True:
time.sleep(3)
print('Checking for more messages')
for contact in driver.get_unread():
for message in contact.messages:
if isinstance(message, Message): # Currently works for text messages only.
print("Phone:" + message.sender.id + "Message:" + message.content)
requests.post('http://xxxxxxxx/api/wa_receive', data={'wa_number': message.sender.id,
'wa_message': message.content,
'wa_type': 'text',
'wa_server_number': wa_server_number})
#contact.chat.send_message(message.safe_content)
~~~python
@Tschipp thank you...
You might also want to try
Would be great if you could post working code here after testing.
I have an update: This code seems to be working better:
var chat = Store.Chat.get(arguments[0]);
chat.sendSeen();
chat.markSeen();
You would need to call this JS code directly from the selenium webdriver. arguments[0] is the id of the chat that you want to mark as read.
Duplicate of #73
Hi, while running the echo sample, I noticed the messages are not marked as "read" (double blue ticks). How can this be done?
Also I think the async_echo.py sample is not working on Windows platform. It threw some kind of NotImplementedError exception, because I think the implementation of asyncio is different on Windows platform?
File "D:/PycharmProjects/WhatsAppWeb/sample/async_echo.py", line 48, in start loop.add_signal_handler(SIGINT, stop) File "C:\Users\XXXX\AppData\Local\Programs\Python\Python36-32\lib\asyncio\events.py", line 499, in add_signal_handler raise NotImplementedError NotImplementedError