My agentic slop goes here. Not intended for anyone else!
1(* Simple Bot Example using core Zulip library *)
2
3let () = Eio_main.run @@ fun env ->
4 Eio.Switch.run @@ fun sw ->
5
6 Printf.printf "OCaml Zulip Bot Example\n";
7 Printf.printf "=======================\n\n";
8
9 (* Create test authentication *)
10 let auth = Zulip.Auth.create
11 ~server_url:"https://example.zulipchat.com"
12 ~email:"bot@example.com"
13 ~api_key:"example-api-key" in
14
15 Printf.printf "✅ Created authentication for: %s\n" (Zulip.Auth.email auth);
16 Printf.printf "✅ Server URL: %s\n" (Zulip.Auth.server_url auth);
17
18 (* Create client *)
19 let client = Zulip.Client.create ~sw env auth in
20 let client_str = Format.asprintf "%a" Zulip.Client.pp client in
21 Printf.printf "✅ Created client: %s\n" client_str;
22
23 (* Test message creation *)
24 let message = Zulip.Message.create
25 ~type_:`Channel
26 ~to_:["general"]
27 ~content:"Hello from OCaml bot!"
28 ~topic:"Bot Testing"
29 () in
30
31 Printf.printf "✅ Created message to: %s\n" (String.concat ", " (Zulip.Message.to_ message));
32 Printf.printf "✅ Message content: %s\n" (Zulip.Message.content message);
33 Printf.printf "✅ Message topic: %s\n" (match Zulip.Message.topic message with Some t -> t | None -> "none");
34
35 (* Test API call (mock) *)
36 (match Zulip.Client.request client ~method_:`GET ~path:"/users/me" () with
37 | Ok response ->
38 Printf.printf "✅ API request successful: %s\n"
39 (match response with
40 | `O fields -> String.concat ", " (List.map fst fields)
41 | _ -> "unknown format")
42 | Error err ->
43 Printf.printf "❌ API request failed: %s\n" (Zulip.error_message err));
44
45 Printf.printf "\n🎉 Bot example completed successfully!\n";
46 Printf.printf "Note: This uses mock responses since we're not connected to a real Zulip server.\n"