128 Members
The nio matrix python library | Latest release 0.10.0 https://pypi.org/project/matrix-nio/ | Documentation: https://matrix-nio.readthedocs.io/en/stable/69 Servers

Load older messages

Timestamp Message
7 Apr 2020
09:02:00@andrasdenes:matrix.organdrasdenes Hi,
I think this might be the right place to ask and I scrolled up a bunch of messages but didn't really find what I was looking for. So I have a homeserver and I want a dummy user, call it a bot, whatever, to send encrypted messages. I have googled this but couldn't find a snippet that would help me understand how to enable this feature. So when I look at the nio documentation over at matrix-nio.readthedocs.io I see that the AsyncClient has the room_send method, which should send encrypted messages if the target room is encrypted(?)
That does not really happen. I guessed there was more to this so went digging in the documentation and while I found the Encryption section, I could not really get how to implement it.
My setup would consist of a more or less basic Synapse installation and then use nio to make the dummy user do things.
First I would just manualy join a private chat with both users and send an encrypted "hello"?
Can you maybe detail this for me or provide an explanatory snippet of code?
09:02:50@andrasdenes:matrix.organdrasdenestl;dr i'm asking for your help so read only if you have a minute :D
09:07:26@poljar:matrix.orgpoljar room_send() will encrypt your messages if the room is encrypted under the condition that encryption support is installed and the state is correctly synced with the server
09:07:46@poljar:matrix.orgpoljar you'll need to use the sync_forever() method in a separate async task for the later to be true
09:10:45@andrewm:amorgan.xyzanoa poljar, huh, so storing sync tokens effectively doesn't work unless you have the e2e deps installed?
09:11:31@poljar:matrix.orgpoljarcorrect :(
09:12:22@andrewm:amorgan.xyzanoaAh, okie dokie. That is kinda sucky but thanks for letting me know :)

poljar: I tried a few different things. But I think this is the most reasonable(?):

I ran 2 different proccesses in 2 different terminals, one of them being asyncio.run(client.sync_forever(30000)) after authenticating my client

and the other ending in room_send(<room_id>, 'm.room.message', content)
where content = { "body": "this isnt encrypted for sure", "msgtype": "m.text" }

And I still had no luck.
I think that I have dependencies installed as i installed matrix-nio[e2e] and also built olm from source.

Essentially this is how I wish to send the message. Like run the sync_forever and then run this whenever I want a message sent.

    client = AsyncClient(<url>, <username>)
    await client.login(<password>)
    content = {
                "body": "this isnt encrypted for sure",
                "msgtype": "m.text"
    await client.room_send(room_id, 'm.room.message', content)


Could you point me in a direction that is going to yield the results i need? Or just tell me what I'm doing wrong?

Could you point me in a direction that is going to yield the results i need? Or just tell me what I'm doing wrong?

left that in code tags oops

12:37:40@poljar:matrix.orgpoljaryou can't run those in separate processes since they won't share memory/client state, you can create a separate task like it's described here https://docs.python.org/3/library/asyncio-task.html#creating-tasks
12:38:39@poljar:matrix.orgpoljar you run sync_forever() in a separate task and await this event in your main loop https://matrix-nio.readthedocs.io/en/latest/nio.html#nio.AsyncClient.synced
12:38:55@poljar:matrix.orgpoljarthat way you'll be sure that you don't try to send messages before a sync is done
8 Apr 2020
01:40:53@sparky:matrix.possumlodge.me@sparky:matrix.possumlodge.me left the room.
03:20:27@phil:denhoff.caPhil joined the room.
03:22:18@phil:denhoff.caPhilHi all, is there some documentation somewhere I can read to get my dev environment set up to contribute properly? Currently reading the .traivs.yml, Makefile, and guessing and I can't say I'm a big fan 🥴
06:55:38@poljar:matrix.orgpoljardepends on how you want to set it up, some distros package all the dependencies so you could go the distro package way, using a virtual environment is a possibility or just installing all the deps for your user is also possible
07:08:43@phil:denhoff.caPhilhmmm looks like our timezones don't match up great; I'm heading to bed pretty quick but I'm working on read receipt events. I think I ended up figuring out how to get it all installed in a virtualenv, except olm
07:11:09@poljar:matrix.orgpoljarolm requires the C lib, the dynamic lib as well as development headers
07:12:00@phil:denhoff.caPhilOh yeah sorry, that wasn't clear. I installed olm outside the venv
07:12:48@phil:denhoff.caPhilI'll probably have some more questions for you about testing tomorrow, gotta head to sleep pretty quick 😴
12:48:01@rda:phys.ethz.chrda joined the room.
9 Apr 2020
06:00:26@gabriel:libresolutions.networkGabriel joined the room.
14:49:29@tostiman:matrix.tostiman.comtostiman joined the room.
19:35:41@dhmf:m.dhdf.devdhmf (Old) changed their display name from dhmf to dhmf (Old).
19:36:04@dhmf:m.dhdf.devdhmf (Old) invited @dhmf:dhdf.devdhmf.
20:47:33@phil:denhoff.caPhil changed their profile picture.
20:58:23@phil:denhoff.caPhil poljar: Maybe this is better for a PR convo but I'll start here and we can always move to GitHub later; for an implementation of ReadReceiptEvents I've added a test to event_test.py that only verifies parsing the JSON from the event. I'm basing my implementation on TypingNoticeEvent, which I notice has some tests in room_test.py and client_test.py; I don't think ReadReceiptEvents will affect the room (at least, I haven't added anything into Room that tracks receipts) so should I add a test similar to client_test.test_ephemeral_cb()? Or, do you think the Room should be tracking receipts for all users, similar to how matrix-js-sdk does it?
10 Apr 2020
01:46:03@sonri:converser.euSonri joined the room.
01:46:26@sonri:converser.euSonri left the room.
06:28:04@poljar:matrix.orgpoljaronce we have a state store people will probably expect read receipts to be restored when they restore the client, so it probably makes sense to track them in the room

There are no newer messages yet.

Back to Room List