!JiiOHXrIUCtcOJsZCa:matrix.org

nio

357 Members
The nio matrix python library | Latest release 0.4 https://pypi.org/project/matrix-nio/ | Documentation: https://matrix-nio.readthedocs.io/en/stable/137 Servers

Load older messages


SenderMessageTime
5 Jul 2019
@fredcy:ostez.comfredcy [08c3...6ba3]
Traceback (most recent call last):
  File "main.py", line 35, in <module>
    main()
  File "main.py", line 31, in main
    asyncio.run(main())
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "main.py", line 24, in main
    if len(sync_response.rooms.join) > 0:
AttributeError: 'SyncError' object has no attribute 'rooms'
16:45:46
@fredcy:ostez.comfredcy [08c3...6ba3]I want to write a simple bot using matrix-nio.16:47:09
@poljar:matrix.orgpoljaryou can check if you got an error or valid response using isinstance(response, SyncResponse)16:47:39
@poljar:matrix.orgpoljarif you want to check the underlying issue you can the transport_response of the response which will be a aiohttp response for the async client16:48:24
@poljar:matrix.orgpoljari don't think there are more examples, i'm currently working on improving the documentation before a new release16:48:53
@poljar:matrix.orgpoljarfeel free to ask away here while i get the documentation in a better shape16:49:10
@fredcy:ostez.comfredcy [08c3...6ba3]OK, thanks. I'll give that a go.16:49:30
@benpa:matrix.orgbenpa
In reply to @poljar:matrix.org
you can check if you got an error or valid response using isinstance(response, SyncResponse)
I can update this section to include that
16:51:48
@benpa:matrix.orgbenpa fredcy [08c3...6ba3]: glad you're liking the guide - what next steps/examples do you want to see? 16:52:22
@poljar:matrix.orgpoljarsure if you want, btw can i steal parts of that doc and put it into the nio documentation?16:52:40
@benpa:matrix.orgbenpaI'm planning on writing + helping SDK devs make more guides like this, but the format can be the same between them16:53:11
@benpa:matrix.orgbenpa
In reply to @poljar:matrix.org
sure if you want, btw can i steal parts of that doc and put it into the nio documentation?
ofc!
16:53:16
@poljar:matrix.orgpoljarthanks16:53:40
@fredcy:ostez.comfredcy [08c3...6ba3]The usage guide is quite good. The very next step is more robust handling of sync errors since I hit that with just a few minutes of testing.16:55:43
@fredcy:ostez.comfredcy [08c3...6ba3]I also need to know how to access all the relevant event details so I can have a bot respond based on message text, room, and sender.16:56:42
@poljar:matrix.orgpoljarevent details depend on the event type16:58:19
@poljar:matrix.orgpoljarany event in particular you're interested in?16:58:29
@fredcy:ostez.comfredcy [08c3...6ba3]At first, just simple user messages (the bot looks for messages for it to respond to, as usual).17:01:03
@fredcy:ostez.comfredcy [08c3...6ba3]Later, member-join messages may be important.17:01:18
@benpa:matrix.orgbenpaok - so different message event types17:01:49
@poljar:matrix.orgpoljarso we have a class structure of Event -> RoomMessage -> RoomMessageText17:02:19
@benpa:matrix.orgbenpaRoomMessageText was the most obvious place to start but yeah we could do a guide that's just "different, common event types and how to handle them"17:02:37
@poljar:matrix.orgpoljarRoomMessage text will have a body attribute of type string and a formatted_body attribute that can be None17:02:57
@poljar:matrix.orgpoljar(i am in the process of committing the docs for those)17:03:21
@poljar:matrix.orgpoljarok, the docs did build17:10:35
@poljar:matrix.orgpoljarhttps://matrix-nio.readthedocs.io/en/latest/nio.html#nio.events.RoomMessageText17:10:38
@fredcy:ostez.comfredcy [08c3...6ba3] So, nio.Api represents the matrix REST API, it seems. It's not an API to nio for use by apps such as mine, but rather what nio itself uses at a lower layer to access the matrix API? 17:27:04
@poljar:matrix.orgpoljar yeah, you can use it yourself without a nio Client if you want 17:27:51
@poljar:matrix.orgpoljarbut using the higher level interface of a nio Client should be easier17:28:31
@fredcy:ostez.comfredcy [08c3...6ba3]

When I kill my client with ^C I get some low level errors:

ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111308860>
17:51:08

Show newer messages


Back to Room ListRoom Version: 4