!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
23 Feb 2025
@exaltia:chat.exaltia.frExaltia

if there's better way to do, feel free to tell me

sortedrooms = {}
    for each in roomslist.rooms:
        result = (await client.space_get_hierarchy(each))
        try:
            if result.rooms[0]['room_type'] == 'm.space':
                print(result.rooms[0])
                sortedrooms[result.rooms[0]['children_state'][0]['origin_server_ts']] = result.rooms[0]['name']
        except KeyError:
            pass
    print(dict(sorted(sortedrooms.items())))
14:21:30
@adam:bostoncoop.net@adam:bostoncoop.net left the room.21:03:23
24 Feb 2025
@tom:lant.uktom changed their display name from tom [back 2025-02-24] to tom.11:41:55
25 Feb 2025
@mihranofv:matrix.orgمهران صارم joined the room.02:43:04
@skskskkw:matrix.org@skskskkw:matrix.org joined the room.21:31:01
28 Feb 2025
@mariamhairy12:matrix.org@mariamhairy12:matrix.org joined the room.08:48:45
@mariamhairy12:matrix.org@mariamhairy12:matrix.org left the room.09:11:55
1 Mar 2025
@skskskkw:matrix.org@skskskkw:matrix.org left the room.00:40:24
2 Mar 2025
@asem.abadla:matrix.orgAsem Abadla joined the room.03:03:06
5 Mar 2025
@ashlees:matrix.org@ashlees:matrix.org joined the room.20:26:04
@ashlees:matrix.org@ashlees:matrix.org left the room.20:30:06
8 Mar 2025
@anton:rendezvous.anton.molyboha.meanton 00:13:13
12 Mar 2025
@aurakayra:matrix.orgaurakayra joined the room.01:06:55
13 Mar 2025
@eestiline:matrix.orgEestiline Eesti Estonia Margus Meigo DarkFi Waffa joined the room.01:23:05
@eestiline:matrix.orgEestiline Eesti Estonia Margus Meigo DarkFi Waffa changed their display name from Eestiline Eestiline to Eestiline Eesti Estonia Margus Meigo DarkFi Waffa.01:30:08
@eestiline:matrix.orgEestiline Eesti Estonia Margus Meigo DarkFi Waffa set a profile picture.01:34:50
17 Mar 2025
@rahulranjan:matrix.org@rahulranjan:matrix.org joined the room.07:20:47
@rahulranjan:matrix.org@rahulranjan:matrix.org left the room.08:00:29
18 Mar 2025
@me:shahpaarth.comPaarth Shah - Github Maintainer

Sorry, just saw this; you could achieve something similar without the try/except using structural pattern matching:

sortedrooms = {}
for room in roomslist.rooms:
    response = await client.space_get_hierarchy(room)
    match response.rooms:
        case [{"room_type": "m.space", "name": name, "children_state": [{"origin_server_ts": origin_server_ts}, *_]} as room, *_]:
            print(room)
            sortedrooms[origin_server_ts] = name
print(dict(sorted(sortedrooms.items())))
09:31:30
@me:shahpaarth.comPaarth Shah - Github Maintainer *

Sorry, just saw this; you could achieve something similar without the try/except using structural pattern matching:

sortedrooms = {}
for each in roomslist.rooms:
    response = await client.space_get_hierarchy(each)
    match response.rooms:
        case [{"room_type": "m.space", "name": name, "children_state": [{"origin_server_ts": origin_server_ts}, *_]} as room, *_]:
            print(room)
            sortedrooms[origin_server_ts] = name
print(dict(sorted(sortedrooms.items())))
09:33:03
@exaltia:chat.exaltia.frExaltiathank you, i'll note if for later use!14:10:40
@mtrnord:midnightthoughts.space@mtrnord:midnightthoughts.space changed their profile picture.20:44:27
22 Mar 2025
@mtrnord:midnightthoughts.space@mtrnord:midnightthoughts.space left the room.22:00:36
24 Mar 2025
@becht.felix:matrix.orgbecht.felix joined the room.11:37:04
28 Mar 2025
@sents:matrix.orgsents changed their display name from sents ꙮ to sents.07:34:46
31 Mar 2025
@jaycool901:matrix.org@jaycool901:matrix.org joined the room.04:06:46
@jaycool901:matrix.org@jaycool901:matrix.org left the room.04:29:07
24 Jun 2019
@poljar:matrix.orgpoljar changed the history visibility to "world_readable" from "shared".19:00:49
@travis:t2l.ioTravisR joined the room.19:04:04
@voyager:t2bot.ioMatrix Traveler (bot) joined the room.19:06:33

Show newer messages


Back to Room ListRoom Version: 4