<filename>main.py
import asyncio
import logging

import pyqrcode

import kyros

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
    teste = whatsapp.session.from_file("saveSession.dat")
    print(teste)
    await whatsapp.restore_session(teste)
    message = kyros.WebsocketMessage(None, ["query", "exist", "556185923871"])
    await whatsapp.websocket.send_message(message)
    
    # receive a websocket message
    print(await whatsapp.websocket.messages.get(message.tag))
    await whatsapp.websocket.shutdown()
if __name__ == "__main__":
   asyncio.run(main())
<filename>main.py
import asyncio
import logging

import pyqrcode

import kyros

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
    teste = whatsapp.session.from_file("saveSession.dat")
    print(teste)
    await whatsapp.restore_session(teste)
    message = kyros.WebsocketMessage(None, ["query", "exist", "556185923871"])
    await whatsapp.websocket.send_message(message)
    
    # receive a websocket message
    print(await whatsapp.websocket.messages.get(message.tag))
    await whatsapp.websocket.shutdown()
if __name__ == "__main__":
   asyncio.run(main())
# set a logging level: just to know if something (bad?) happens # create the Client instance using create class method # 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 # receive a websocket message