You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
646B

  1. from importlib import util
  2. import asyncio
  3. from nio import (AsyncClient, SyncResponse, RoomMessageText, LoginResponse)
  4. homeserver_url = "https://matrix.org"
  5. user_id = "@ethrfhre6hgfdgrtgsedgser5g:matrix.org"
  6. device_id = "TEQUUBMWDR"
  7. access_token = ""
  8. async_client = AsyncClient(homeserver_url)
  9. async def on_message(room, event):
  10. print(room)
  11. print(event)
  12. async def main():
  13. async_client.add_event_callback(on_message, RoomMessageText)
  14. login_response = LoginResponse(user_id, device_id, access_token)
  15. await async_client.receive_response(login_response)
  16. await async_client.sync_forever(timeout=30000)
  17. asyncio.run(main())