| 23 Jul 2021 |
@grahamc:nixos.org | how about making every room have a unique icon by feeding its name / topic in to one of those creepy image generators | 11:24:27 |
kevincox | I would rather have a shitty unique icon than no icon. We can always get someone to make a better icon generator later. | 11:28:21 |
kevincox | I mean someone here probably knows how to use imagemagick | 11:28:38 |
@grahamc:nixos.org | yeah | 11:28:45 |
@grahamc:nixos.org | I get super lost in all the N's | 11:28:51 |
CRTified | Me too | 11:29:12 |
@grahamc:nixos.org | I have a tool to enumerate all the rooms, maybe someone could find a way to take the name and generate a random picture, github avatar style? | 11:29:32 |
kevincox | % name="example"
%wget -O "$name.img" "https://www.gravatar.com/avatar/$(md5sum <<<"$name")?d=robohash&f=y"
| 11:37:38 |
kevincox | * % name="example"
% wget -O "$name.img" "https://www.gravatar.com/avatar/$(md5sum <<<"$name")?d=robohash&f=y"
| 11:37:42 |
kevincox | You can bikeshed over the supported generators: https://en.gravatar.com/site/implement/images/#highlighter_811485 | 11:38:15 |
@grahamc:nixos.org | oh cool | 11:38:27 |
kevincox | I think there are other sites available as well but this seems good enough 🤷 | 11:39:19 |
@grahamc:nixos.org | a very nice API :) | 11:39:27 |
@grahamc:nixos.org | anyone know how to get an mxc url? mxc://nixos.org/f99b43034eae3a82706e86aca15300fda8210b79 | 11:44:44 |
CRTified | That should just be a media identifier, one second | 11:45:05 |
@grahamc:nixos.org | yeah | 11:45:13 |
CRTified | https://matrix.org/_matrix/media/r0/download/nixos.org/f99b43034eae3a82706e86aca15300fda8210b79 | 11:45:41 |
CRTified | You can just plug it in the end of that URL | 11:45:49 |
@grahamc:nixos.org | oh cool | 11:45:53 |
CRTified | In the end, its basically all HTTP | 11:46:16 |
@grahamc:nixos.org | yeah :) with some manipulation I suppose | 11:46:25 |
CRTified | You can also swap out the host and use the same URL on different homeservers, it will fetch (and cache) the download from the homeserver in the URL | 11:47:06 |
@grahamc:nixos.org | $ synadm -o json room details '!VjfUzaKsXokUdnQcvP:nixos.org' | jq .
{
"room_id": "!VjfUzaKsXokUdnQcvP:nixos.org",
"name": "Nix Python",
"canonical_alias": "#python:nixos.org",
"joined_members": 50,
"joined_local_members": 2,
"version": "6",
"creator": "@grahamc:nixos.org",
"encryption": null,
"federatable": true,
"public": true,
"join_rules": "public",
"guest_access": null,
"history_visibility": "world_readable",
"state_events": 62,
"avatar": null,
"topic": "Anything regarding using Python with Nix.",
"joined_local_devices": 12
}
so iterating over each room id, filtering out rooms with a null avatar, and then figuring out how to upload media and update the room id
| 11:47:54 |
kevincox | If you post an image Element will also let you view source and see the mxc URL. But that isn't too convenient for automation. | 11:47:54 |
@grahamc:nixos.org | yeah, I wonder what the API is like to upload the image automatically | 13:24:19 |
@grahamc:nixos.org | maybe sumner has ideas here | 13:24:25 |
kevincox | It looks like you could combine:
| 13:28:30 |
sumner | In reply to @grahamc:nixos.org yeah, I wonder what the API is like to upload the image automatically Just send it bytes I think: https://matrix.org/docs/spec/client_server/r0.4.0#post-matrix-media-r0-upload | 14:18:55 |
sumner | It gives you the MXC URI as a response. Normally clients will then turn around right away and send it in a message, but in this case you just need to add it to a m.room.avatar state event (https://matrix.org/docs/spec/client_server/r0.4.0#m-room-avatar) which can be created with this endpoint: https://matrix.org/docs/spec/client_server/r0.4.0#put-matrix-client-r0-rooms-roomid-state-eventtype | 14:22:37 |
@grahamc:nixos.org | cool | 14:59:06 |