add TODO comments for various features missing from message handling

This commit is contained in:
tali 2024-01-10 19:43:20 -05:00
parent 15a4475d3c
commit ae8b837c56
1 changed files with 17 additions and 3 deletions

View File

@ -88,6 +88,7 @@ let on_msg_user t username modestr realname =
(* > messages and channels *)
let on_msg_privmsg t tgt txt _ =
(* TODO: comma-separated list of targets *)
let msg = Irc.Msg.make "PRIVMSG" [tgt; txt] ~always_trailing:true in
let dst =
try
@ -100,7 +101,10 @@ let on_msg_privmsg t tgt txt _ =
match dst with
| `not_found -> `nosuchnick tgt
| (`to_user _ | `to_chan _) as dst ->
(* TODO: check if allowed to send to channel *)
(* TODO: check if user is away *)
(* TODO: check if channel is +n and user is not a member *)
(* TODO: check if channel is +m and user is not priviledged *)
(* TODO: check if channel is +b <user> *)
Router.relay msg ~from:t.user dst;
`ok
@ -113,6 +117,7 @@ let list_names chan =
`names ("@", Chan.name chan, names)
let on_msg_names t name _ =
(* TODO: comma-separated list of channels *)
match Irc.name_type name with
| `nick | `invalid ->
if name = "" then `needmoreparams else `nosuchchannel name
@ -120,12 +125,15 @@ let on_msg_names t name _ =
let chan = try Some (Router.find_chan t.router name)
with Not_found -> None
in
(* TODO: check if allowed to list names *)
(* TODO: check if channel is +s and user is not a member *)
(* TODO: check if user in channel is +i and user is not a member *)
match chan with
| None -> `nosuchchannel name
| Some chan -> list_names chan
let on_msg_join t name _ =
(* TODO: comma-separated list of channels *)
(* TODO: "0" parameter means part from all channels *)
match Irc.name_type name with
| `nick | `invalid ->
if name = "" then `needmoreparams else `nosuchchannel name
@ -134,13 +142,14 @@ let on_msg_join t name _ =
with Not_found ->
Logs.debug (fun m -> m "making new channel %S" name);
let chan = Chan.make ~name in
(* TODO: op user after joining *)
(* TODO: make user +o *)
Chan.register chan ~router:t.router;
chan
in
if Chan.is_member chan t.user then
`ok
else begin
(* TODO: check if channel is +k, get associated key from parameters *)
Chan.join chan t.user;
let msg = Irc.Msg.make "JOIN" [name] in
Router.relay msg ~from:t.user `to_self;
@ -149,6 +158,8 @@ let on_msg_join t name _ =
end
let on_msg_part t name _ =
(* TODO: comma-separated list of channels *)
(* TODO: part reason *)
match Irc.name_type name with
| `nick | `invalid ->
if name = "" then `needmoreparams else `nosuchchannel name
@ -179,6 +190,9 @@ let on_msg_part t name = require_registered t (on_msg_part t name)
(* > misc *)
let on_msg_quit t reason =
(* TODO: '''When connections are terminated by a client-sent QUIT command, servers
SHOULD prepend <reason> with the ASCII string "Quit: " when sending QUIT messages to
other clients''' *)
let reason = String.concat " " reason in
shutdown t ~reason;
`ok