Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Demo code does not work #17

Closed
theriseof9 opened this issue Dec 4, 2021 · 0 comments
Closed

Demo code does not work #17

theriseof9 opened this issue Dec 4, 2021 · 0 comments

Comments

@theriseof9
Copy link

theriseof9 commented Dec 4, 2021

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", "1234@c.us"])
    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

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

No branches or pull requests

1 participant