get channel symbol correct in NAMES reply

This commit is contained in:
tali 2024-01-24 12:19:50 -05:00
parent 04ad9c6ed7
commit f057eb1648
1 changed files with 12 additions and 8 deletions

View File

@ -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