add ADMIN command
This commit is contained in:
parent
b0e1b10868
commit
7534b2c4e7
|
@ -61,7 +61,7 @@ let reply t (num, params) =
|
|||
| None -> "*"
|
||||
in
|
||||
let always_trailing = match num with
|
||||
| "301" | "311" | "312" | "314" | "319" | "332" | "353" -> true
|
||||
| "256" | "301" | "311" | "312" | "314" | "319" | "332" | "353" -> true
|
||||
| _ -> false
|
||||
in
|
||||
Outbox.send t.outbox
|
||||
|
@ -690,6 +690,11 @@ let welcome t me =
|
|||
motd t;
|
||||
end
|
||||
|
||||
let on_msg_admin t =
|
||||
let* _me = require_registered t in
|
||||
reply t ("256", [t.server_info.hostname; t.server_info.admin_info]);
|
||||
Ok ()
|
||||
|
||||
let quit t me ~reason =
|
||||
begin
|
||||
let msg = Msg.make "QUIT" [User.nick me; reason] ~always_trailing:true in
|
||||
|
@ -839,11 +844,13 @@ let dispatch t = function
|
|||
| "USER", unm :: _ :: _ :: rnm :: _ -> on_msg_user t unm rnm
|
||||
| "QUIT", reason -> on_msg_quit t (concat_args reason)
|
||||
| "MOTD", _ -> on_msg_motd t
|
||||
| "ADMIN", _ -> on_msg_admin t
|
||||
| "PING", args -> on_msg_ping t (concat_args args)
|
||||
| "PONG", args -> on_msg_pong t (concat_args args)
|
||||
| "PRIVMSG", ([] | "" :: _) -> Error norecipient
|
||||
| "PRIVMSG", ([_] | _ :: "" :: _) -> Error notexttosend
|
||||
| "PRIVMSG", tgt :: msg :: _ -> on_msg_privmsg t tgt msg
|
||||
(* TODO: "NOTICE" *)
|
||||
| "JOIN", tgt :: _ when tgt <> "" -> on_msg_join t tgt
|
||||
| "JOIN 0", _ -> (* hack; see split_command_params *) on_msg_join_0 t
|
||||
| "NAMES", tgt :: _ when tgt <> "" -> on_msg_names t tgt
|
||||
|
@ -869,7 +876,6 @@ let dispatch t = function
|
|||
(* TODO: "STATS" *)
|
||||
(* TODO: "HELP" *)
|
||||
(* TODO: "INFO" *)
|
||||
(* TODO: "NOTICE" *)
|
||||
(* TODO: "KILL" *)
|
||||
(* TODO: "REHASH" *)
|
||||
(* TODO: "RESTART" *)
|
||||
|
|
|
@ -4,6 +4,7 @@ type t = {
|
|||
version : string;
|
||||
created : string;
|
||||
hostname : string;
|
||||
admin_info : string;
|
||||
motd : string list;
|
||||
conf : conf;
|
||||
}
|
||||
|
@ -41,6 +42,9 @@ let make ~hostname = {
|
|||
(* TODO: stringify timestamp *)
|
||||
"Sun Jan 7 09:58:24 PM EST 2024";
|
||||
hostname;
|
||||
admin_info =
|
||||
(* TODO: make configurable *)
|
||||
"the admin of this server is @iitalics@octodon.social";
|
||||
motd = [
|
||||
(* TODO: load from file *)
|
||||
"MEOW MEOW MEOW MEOW MEOW";
|
||||
|
|
Loading…
Reference in New Issue