5 Jul 2019 |
fredcy [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 [08c3...6ba3] | I want to write a simple bot using matrix-nio. | 16:47:09 |
poljar | you can check if you got an error or valid response using isinstance(response, SyncResponse) | 16:47:39 |
poljar | if you want to check the underlying issue you can the transport_response of the response which will be a aiohttp response for the async client | 16:48:24 |
poljar | i don't think there are more examples, i'm currently working on improving the documentation before a new release | 16:48:53 |
poljar | feel free to ask away here while i get the documentation in a better shape | 16:49:10 |
fredcy [08c3...6ba3] | OK, thanks. I'll give that a go. | 16:49:30 |
benpa | 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 | fredcy [08c3...6ba3]: glad you're liking the guide - what next steps/examples do you want to see? | 16:52:22 |
poljar | sure if you want, btw can i steal parts of that doc and put it into the nio documentation? | 16:52:40 |
benpa | I'm planning on writing + helping SDK devs make more guides like this, but the format can be the same between them | 16:53:11 |
benpa | 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 | thanks | 16:53:40 |
fredcy [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 [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 | event details depend on the event type | 16:58:19 |
poljar | any event in particular you're interested in? | 16:58:29 |
fredcy [08c3...6ba3] | At first, just simple user messages (the bot looks for messages for it to respond to, as usual). | 17:01:03 |
fredcy [08c3...6ba3] | Later, member-join messages may be important. | 17:01:18 |
benpa | ok - so different message event types | 17:01:49 |
poljar | so we have a class structure of Event -> RoomMessage -> RoomMessageText | 17:02:19 |
benpa | RoomMessageText 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 | RoomMessage text will have a body attribute of type string and a formatted_body attribute that can be None | 17:02:57 |
poljar | (i am in the process of committing the docs for those) | 17:03:21 |
poljar | ok, the docs did build | 17:10:35 |
poljar | https://matrix-nio.readthedocs.io/en/latest/nio.html#nio.events.RoomMessageText | 17:10:38 |
fredcy [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 | yeah, you can use it yourself without a nio Client if you want | 17:27:51 |
poljar | but using the higher level interface of a nio Client should be easier | 17:28:31 |
fredcy [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 |