field accessors are ok, dont use methods in Server_info

This commit is contained in:
tali 2024-01-23 14:31:31 -05:00
parent 7dbd997b92
commit 67024c572e
2 changed files with 18 additions and 24 deletions

View File

@ -273,8 +273,7 @@ let join t user chan =
begin
(* TODO: make founder +o / +q etc. *)
Chan.register chan ~router:t.router;
set_chan_mode chan ~from:user
~add:(Server_info.conf t.server_info).init_cmode;
set_chan_mode chan ~from:user ~add:t.server_info.conf.init_cmode;
end
end
@ -344,8 +343,8 @@ let on_msg_part t name reason =
(* welcome and quit *)
let motd t =
let s_hostname = Server_info.hostname t.server_info in
let s_motd = Server_info.motd t.server_info in
let s_hostname = t.server_info.hostname in
let s_motd = t.server_info.motd in
begin
reply t ("375", [Fmt.str "- %s Message of the day - " s_hostname]);
List.iter (fun ln -> reply t ("372", ["- " ^ ln])) s_motd;
@ -359,20 +358,20 @@ let on_msg_motd t =
let welcome t me =
let whoami = Msg.prefix_string (User.prefix me) in
let s_hostname = Server_info.hostname t.server_info in
let s_version = Server_info.version t.server_info in
let s_created = Server_info.created t.server_info in
let conf = Server_info.conf t.server_info in
let s_hostname = t.server_info.hostname in
let s_version = t.server_info.version in
let s_created = t.server_info.created in
let s_conf = t.server_info.conf in
let modes l = String.of_seq (List.to_seq l |> Seq.map Mode.to_char) in
let umodes = modes conf.all_umodes in
let cmodes = modes conf.all_cmodes in
let pmodes = modes conf.all_pmodes in
let umodes = modes s_conf.all_umodes in
let cmodes = modes s_conf.all_cmodes in
let pmodes = modes s_conf.all_pmodes in
begin
reply t ("001", [Fmt.str "Welcome to the tali IRC network %s" whoami]);
reply t ("002", [Fmt.str "Your host is %s, running version %s" s_hostname s_version]);
reply t ("003", [Fmt.str "This server was created %s" s_created]);
reply t ("004", [s_hostname; s_version; umodes; cmodes; pmodes]);
reply t ("005", conf.isupport @ ["are supported by this server"]);
reply t ("005", s_conf.isupport @ ["are supported by this server"]);
motd t;
end
@ -415,8 +414,7 @@ let attempt_to_register t =
User.register me ~router:t.router;
t.user <- Some me;
welcome t me;
set_user_mode me
~add:(Server_info.conf t.server_info).init_umode;
set_user_mode me ~add:t.server_info.conf.init_umode;
Ok ()
| _, _ ->
Ok ()

View File

@ -1,8 +1,9 @@
open! Import
type t = {
hostname : string;
version : string;
created : string;
hostname : string;
motd : string list;
conf : conf;
}
@ -33,10 +34,13 @@ let default_conf = {
}
let make ~hostname = {
hostname;
version =
(* TODO: generate version string at build time? *)
"0.0.0";
created =
(* TODO: stringify timestamp *)
"Sun Jan 7 09:58:24 PM EST 2024";
hostname;
motd = [
(* TODO: load from file *)
"MEOW MEOW MEOW MEOW MEOW";
@ -46,12 +50,4 @@ let make ~hostname = {
conf = default_conf;
}
let version (_ : t) =
(* TODO: generate version string at build time? *)
"0.0.0"
let hostname t = t.hostname
let prefix t = Msg.Server_prefix t.hostname
let created t = t.created
let motd t = t.motd
let conf t = t.conf