My code also lives here
lc-at / kyros Goto Github PK
View Code? Open in Web Editor NEWPython wrapper for WhatsApp Web API websocket communication (based on https://github.com/sigalor/whatsapp-web-reveng)
License: MIT License
Python wrapper for WhatsApp Web API websocket communication (based on https://github.com/sigalor/whatsapp-web-reveng)
License: MIT License
My code also lives here
I am not clear on why this is not working, Let me explain what I understood.
Another issue
connection_data["phone"]
was not found.How to run this code any demo please sir.
How i can load session from file and get the data from number? like the photo and the status message.
How will we check that a number is in WhatsApp or not ???
The whatsapp can't read the qr code.
i managed to login, and save load session from file, but how can i run this forever ?
I have been quite busy and not being able to maintain this package very actively. Also, I don't think I will have that much of a time to maintain it actively in the near future.
I believe that this library could be maintained better if there is another maintainer who is willing to maintain this project on their spare time. If anyone is interested to become a maintainer of this project, please let me know, I would really appreciate that.
WhatsApp have lately been updating its WhatsApp Web platform to enable it to be accessed independently (without connecting to the phone). How would this feature be implemented in Kyros?
dear @p4kl0nc4t please help me
my code is:
` # create the Client instance using create class method
whatsapp = await kyros.Client.create()
# do a QR login
qr_data, scanned = await whatsapp.qr_login()
# generate qr code image
qr_code = pyqrcode.create(qr_data)
print(qr_code.png('code.png', scale=1, module_color=[0, 0, 0, 128], background=[0xff, 0xff, 0xff]))
# print(qr_code.terminal(quiet_zone=0))`
after scan qr code, occur this error:
Traceback (most recent call last): File "init.py", line 41, in <module> asyncio.run(main()) File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.8/asyncio/base_events.py", line 612, in run_until_complete return future.result() File "init.py", line 26, in main await scanned File "/tmp/w/lib/python3.8/site-packages/kyros/client.py", line 103, in wait_qr_scan self.phone_info = connection_data["phone"] KeyError: 'phone'
Tried running demo code
import asyncio
import logging
import pyqrcode
import kyros
logging.basicConfig()
logging.getLogger("kyros").setLevel(logging.WARNING)
async def main():
whatsapp = await kyros.Client.create()
qr_data, scanned = await whatsapp.qr_login()
qr_code = pyqrcode.create(qr_data)
print(qr_code.terminal(quiet_zone=1))
try:
await scanned
except asyncio.TimeoutError:
await whatsapp.shutdown()
return
# how to send a websocket message
message = kyros.WebsocketMessage(None, ["query", "exist", "[email protected]"])
await whatsapp.websocket.send_message(message)
# receive a websocket message
print(await whatsapp.websocket.messages.get(message.tag))
if __name__ == "__main__":
asyncio.run(main())
received error
ERROR:asyncio:Task exception was never retrieved future: <Task finished name='Task-4' coro=<WebsocketClient._start_receiver.<locals>.receiver() done, defined at C:\Users\Jerry\AppData\Local\Programs\Python\Python38\lib\site-packages\kyros\websocket.py:169> exception=AttributeError("'Queue' object has no attribute 'pop'")> Traceback (most recent call last): File "C:\Users\Jerry\AppData\Local\Programs\Python\Python38\lib\site-packages\kyros\websocket.py", line 179, in receiver raw_message = self.websocket.messages.pop() AttributeError: 'Queue' object has no attribute 'pop'
Resolved by changing websocket.py from pop() to get() and adding await
can't keep alive conection..
Hi,
Ubuntu 20.04
Python 3.8.2
Installation:
pip3 install git+https://[email protected]/p4kl0nc4t/kyros
pip3 install pyqrcode
I tried your example and I got the following error:
Traceback (most recent call last):
File "wa.py", line 40, in <module>
asyncio.run(main())
File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "wa.py", line 14, in main
whatsapp = await kyros.Client.create()
NameError: name 'kyros' is not defined
Running as:
python3 wa.py
The example code:
import asyncio
import logging
import pyqrcode
from kyros import Client, WebsocketMessage
logging.basicConfig()
# set a logging level: just to know if something (bad?) happens
logging.getLogger("kyros").setLevel(logging.WARNING)
async def main():
# create the Client instance using create class method
whatsapp = await kyros.Client.create()
# do a QR login
qr_data, scanned = await whatsapp.qr_login()
# generate qr code image
qr_code = pyqrcode.create(qr_data)
print(qr_code.terminal(quiet_zone=1))
try:
# wait for the QR code to be scanned
await scanned
except asyncio.TimeoutError:
# timed out (left unscanned), do a shutdown
await whatsapp.shutdown()
return
# how to send a websocket message
message = kyros.WebsocketMessage(None, ["query", "exist", "[email protected]"])
await whatsapp.websocket.send_message(message)
# receive a websocket message
print(await whatsapp.websocket.messages.get(message.tag))
if __name__ == "__main__":
asyncio.run(main())
When will you implement handler?
we are waiting for this
Traceback (most recent call last):
File "C:\Users\USER\Desktop\wp test.py", line 40, in <module>
asyncio.run(main())
File "C:\Program Files\Python37\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python37\lib\asyncio\base_events.py", line 587, in run_until_complete
return future.result()
File "C:\Users\USER\Desktop\wp test.py", line 14, in main
whatsapp = await kyros.Client.create()
File "C:\Users\USER\AppData\Roaming\Python\Python37\site-packages\kyros\client.py", line 32, in create
await instance.setup_ws()
File "C:\Users\USER\AppData\Roaming\Python\Python37\site-packages\kyros\client.py", line 54, in setup_ws
await self.websocket.connect()
File "C:\Users\USER\AppData\Roaming\Python\Python37\site-packages\kyros\websocket.py", line 145, in connect
constants.WEBSOCKET_URI, origin=constants.WEBSOCKET_ORIGIN)
File "C:\Users\USER\AppData\Roaming\Python\Python37\site-packages\websockets\legacy\client.py", line 650, in __await_impl_timeout__
return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
File "C:\Program Files\Python37\lib\asyncio\tasks.py", line 442, in wait_for
return fut.result()
File "C:\Users\USER\AppData\Roaming\Python\Python37\site-packages\websockets\legacy\client.py", line 664, in __await_impl__
extra_headers=protocol.extra_headers,
File "C:\Users\USER\AppData\Roaming\Python\Python37\site-packages\websockets\legacy\client.py", line 328, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 404
So i have already success implementing handle message and readbinary, but the client websockets always stop no connection
i've try adding ["admin","test"] or ?,, but still closed.
please contact me here
Hi,
I was wondering how I can save the session after login to a file and then use the restore_session method.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.