import asyncio
from vzaps import AsyncVZapsClient
async def main():
async with AsyncVZapsClient(
client_token="your-client-token",
client_secret="your-client-secret",
) as client:
async with client.events.subscribe(
instance_id="VZ...",
instance_token="instance-token",
events=["Message", "Connected", "Disconnected"],
reconnect=True,
) as subscription:
@subscription.on("Message")
async def on_message(event):
print(event.id)
print(event.data)
@subscription.on_error
async def on_error(error):
print(error)
await subscription.wait_closed()
asyncio.run(main())