From f057eb1648fdddcf03e20c0f76bd88e8f2442833 Mon Sep 17 00:00:00 2001 From: tali Date: Wed, 24 Jan 2024 12:19:50 -0500 Subject: [PATCH] get channel symbol correct in NAMES reply --- lib/server/connection.ml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/server/connection.ml b/lib/server/connection.ml index 38c925d..603ff92 100644 --- a/lib/server/connection.ml +++ b/lib/server/connection.ml @@ -235,14 +235,18 @@ let on_msg_privmsg t name txt = Ok () let list_names t chan = + let name = Chan.name chan in + let sym = + if Mode.Set.mem `s (Chan.mode chan) + then "@" + else "=" + in + (* TODO: dont list users who are +i if you are not a member w/ them *) + (* TODO: user membership prefix (@/+) *) + let mems = List.map User.nick (Chan.members chan) in begin - List.iter - (fun user -> - (* TODO: check if user is +i and not in channel with them *) - (* ("=", 0x3D) - Public channel. *) - (* ("@", 0x40) - Secret channel (secret channel mode "+s"). *) - reply t ("353", ["@"; Chan.name chan; User.nick user])) - (Chan.members chan); + (* TODO: concat member names until message becomes too long *) + List.iter (fun nick -> reply t ("353", [sym; name; nick])) mems; reply t ("366", [Chan.name chan; "End of NAMES list"]) end @@ -252,7 +256,7 @@ let on_msg_names t name = try match name_type name with | `chan -> Ok (Router.find_chan t.router name) - | _ -> Error (nosuchchannel name) + | `nick | `invalid -> raise Not_found with Not_found -> Error (nosuchchannel name) in