Matrix protocol in OCaml, Eio specialised
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Vendor matrix-spec and fix build errors

Add matrix-spec as git submodule (v1.17) for protocol reference.

Fix type errors in client.ml by using type-safe Requests.Headers
helpers (bearer, user_agent, content_type) instead of string-based set.

Fix simple_bot.ml: ignore Event_id.t return values and use Format.eprintf
for pp_err pretty-printer compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+15 -7
+3
.gitmodules
··· 1 + [submodule "spec/matrix-spec"] 2 + path = spec/matrix-spec 3 + url = https://github.com/matrix-org/matrix-spec.git
+5
STATUS.md
··· 72 72 )) 73 73 ``` 74 74 75 + ## Specification 76 + The Matrix spec is vendored at `spec/matrix-spec` as a git submodule (currently tracking v1.17). 77 + 78 + See: https://github.com/matrix-org/matrix-spec 79 + 75 80 ## Dependencies 76 81 - `jsont` / `jsont.bytesrw` - JSON encoding/decoding 77 82 - `requests` - HTTP client (not cohttp)
+4 -4
examples/simple_bot.ml
··· 70 70 (* Echo command - repeat the message *) 71 71 let echo_text = String.sub msg 6 (String.length msg - 6) in 72 72 (try 73 - Messages.send_text client ~room_id ~body:echo_text (); 73 + let _ = Messages.send_text client ~room_id ~body:echo_text () in 74 74 Printf.printf "Echoed: %s\n%!" echo_text 75 75 with Eio.Io _ as e -> 76 76 Printf.eprintf "Failed to send echo: %s\n%!" (Printexc.to_string e)) 77 77 | Some msg when msg = "!ping" -> 78 78 (* Ping command *) 79 79 (try 80 - Messages.send_text client ~room_id ~body:"pong!" (); 80 + let _ = Messages.send_text client ~room_id ~body:"pong!" () in 81 81 Printf.printf "Responded to ping\n%!" 82 82 with Eio.Io _ as e -> 83 83 Printf.eprintf "Failed to send pong: %s\n%!" (Printexc.to_string e)) ··· 108 108 ~homeserver:(Uri.of_string homeserver) 109 109 ~user:username ~password () 110 110 with Eio.Io (Error.E err, _) -> 111 - Printf.eprintf "Login failed: %a\n%!" Error.pp_err err; 111 + Format.eprintf "Login failed: %a@." Error.pp_err err; 112 112 exit 1 113 113 in 114 114 ··· 137 137 handle_sync client my_user_id response; 138 138 Sync.Continue) 139 139 ~on_error:(fun err -> 140 - Printf.eprintf "Sync error: %a\n%!" Error.pp_err err; 140 + Format.eprintf "Sync error: %a@." Error.pp_err err; 141 141 (* Retry after 5 seconds on error *) 142 142 Sync.Retry_after 5.0) 143 143 ();
+3 -3
lib/matrix_client/client.ml
··· 44 44 let auth_headers t = 45 45 match t.session with 46 46 | Some s -> 47 - Requests.Headers.(empty |> set "Authorization" ("Bearer " ^ s.access_token)) 47 + Requests.Headers.(empty |> bearer s.access_token) 48 48 | None -> 49 49 Requests.Headers.empty 50 50 51 51 let add_user_agent t headers = 52 52 match t.config.user_agent with 53 - | Some ua -> Requests.Headers.set "User-Agent" ua headers 53 + | Some ua -> Requests.Headers.user_agent ua headers 54 54 | None -> headers 55 55 56 56 let json_content_type headers = 57 - Requests.Headers.set "Content-Type" "application/json" headers 57 + Requests.Headers.content_type Requests.Mime.json headers 58 58 59 59 let handle_response response = 60 60 let status = Requests.Response.status_code response in