Matrix protocol in OCaml, Eio specialised
at main 63 lines 2.3 kB view raw
1(** Eio-idiomatic room state operations. 2 3 All functions raise [Eio.Io] exceptions on error instead of 4 returning Result types. *) 5 6(** Get a room state event. 7 8 @param room_id The room ID 9 @param event_type The state event type 10 @param state_key The state key (empty string for events without a key) 11 @return The state event content as JSON 12 @raise Eio.Io on failure *) 13let get_state_event client ~room_id ~event_type ?state_key () = 14 Error.unwrap (Matrix_client.State.get_state_event (Client.base client) 15 ~room_id ~event_type ?state_key ()) 16 17(** Set a room state event. 18 19 @param room_id The room ID 20 @param event_type The state event type 21 @param state_key The state key (empty string for events without a key) 22 @param content The event content as JSON 23 @return The event ID 24 @raise Eio.Io on failure *) 25let set_state client ~room_id ~event_type ?state_key ~content () = 26 Error.unwrap (Matrix_client.State.set_state (Client.base client) 27 ~room_id ~event_type ?state_key ~content ()) 28 29(** Get all state events for a room. 30 @return List of state events as JSON 31 @raise Eio.Io on failure *) 32let get_state client ~room_id = 33 Error.unwrap (Matrix_client.State.get_state (Client.base client) ~room_id) 34 35(** Get the room name. 36 @raise Eio.Io on failure *) 37let get_name client ~room_id = 38 Error.unwrap (Matrix_client.State.get_name (Client.base client) ~room_id) 39 40(** Set the room name. 41 @raise Eio.Io on failure *) 42let set_name client ~room_id ~name = 43 Error.unwrap (Matrix_client.State.set_name (Client.base client) ~room_id ~name) 44 45(** Get the room topic. 46 @raise Eio.Io on failure *) 47let get_topic client ~room_id = 48 Error.unwrap (Matrix_client.State.get_topic (Client.base client) ~room_id) 49 50(** Set the room topic. 51 @raise Eio.Io on failure *) 52let set_topic client ~room_id ~topic = 53 Error.unwrap (Matrix_client.State.set_topic (Client.base client) ~room_id ~topic) 54 55(** Get the room avatar URL. 56 @raise Eio.Io on failure *) 57let get_avatar client ~room_id = 58 Error.unwrap (Matrix_client.State.get_avatar (Client.base client) ~room_id) 59 60(** Set the room avatar URL. 61 @raise Eio.Io on failure *) 62let set_avatar client ~room_id ~url = 63 Error.unwrap (Matrix_client.State.set_avatar (Client.base client) ~room_id ~url)