add TIME command
This commit is contained in:
parent
34bc83e12b
commit
051f1659a3
|
@ -712,6 +712,14 @@ let on_msg_help t topic =
|
||||||
let topic = Option.value topic ~default:"*" in
|
let topic = Option.value topic ~default:"*" in
|
||||||
Error ("524", [topic; "No help available on this topic"])
|
Error ("524", [topic; "No help available on this topic"])
|
||||||
|
|
||||||
|
let on_msg_time t =
|
||||||
|
let* _me = require_registered t in
|
||||||
|
let time = Ptime_clock.now () in
|
||||||
|
let time_unix = Fmt.str "%a" pp_unixtime time in
|
||||||
|
let time_human = Fmt.str "%a" Server_info.pp_time time in
|
||||||
|
reply t ("391", [t.server_info.hostname; time_unix; time_human]);
|
||||||
|
Ok ()
|
||||||
|
|
||||||
let quit t me ~reason =
|
let quit t me ~reason =
|
||||||
begin
|
begin
|
||||||
let msg = Msg.make "QUIT" [User.nick me; reason] ~always_trailing:true in
|
let msg = Msg.make "QUIT" [User.nick me; reason] ~always_trailing:true in
|
||||||
|
@ -863,6 +871,7 @@ let dispatch t = function
|
||||||
| "MOTD", _ -> on_msg_motd t
|
| "MOTD", _ -> on_msg_motd t
|
||||||
| "ADMIN", _ -> on_msg_admin t
|
| "ADMIN", _ -> on_msg_admin t
|
||||||
| "INFO", _ -> on_msg_info t
|
| "INFO", _ -> on_msg_info t
|
||||||
|
| "TIME", _ -> on_msg_time t
|
||||||
| "HELP", args -> on_msg_help t (concat_args args)
|
| "HELP", args -> on_msg_help t (concat_args args)
|
||||||
| "PING", args -> on_msg_ping t (concat_args args)
|
| "PING", args -> on_msg_ping t (concat_args args)
|
||||||
| "PONG", args -> on_msg_pong t (concat_args args)
|
| "PONG", args -> on_msg_pong t (concat_args args)
|
||||||
|
@ -891,7 +900,6 @@ let dispatch t = function
|
||||||
Error noprivileges
|
Error noprivileges
|
||||||
(* TODO: "LIST" *)
|
(* TODO: "LIST" *)
|
||||||
(* TODO: "LUSERS" *)
|
(* TODO: "LUSERS" *)
|
||||||
(* TODO: "TIME" *)
|
|
||||||
(* TODO: "LINKS" *)
|
(* TODO: "LINKS" *)
|
||||||
(* TODO: "USERHOST" *)
|
(* TODO: "USERHOST" *)
|
||||||
| cmd, _ ->
|
| cmd, _ ->
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
open! Import
|
open! Import
|
||||||
|
|
||||||
|
let tz_offset_s = Ptime_clock.current_tz_offset_s ()
|
||||||
|
let pp_time = Ptime.pp_human () ?tz_offset_s
|
||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
version : string;
|
version : string;
|
||||||
created : string;
|
created : string;
|
||||||
|
@ -38,13 +41,7 @@ let make ~hostname = {
|
||||||
version =
|
version =
|
||||||
(* TODO: generate version string at build time? *)
|
(* TODO: generate version string at build time? *)
|
||||||
"0.0.0";
|
"0.0.0";
|
||||||
created =
|
created = Fmt.str "%a" pp_time (Ptime_clock.now ());
|
||||||
begin
|
|
||||||
let ts = Ptime_clock.now () in
|
|
||||||
let tz_offset_s = Ptime_clock.current_tz_offset_s () in
|
|
||||||
let pp = Ptime.pp_human () ?tz_offset_s in
|
|
||||||
Fmt.str "%a" pp ts
|
|
||||||
end;
|
|
||||||
hostname;
|
hostname;
|
||||||
admin_info =
|
admin_info =
|
||||||
(* TODO: make configurable *)
|
(* TODO: make configurable *)
|
||||||
|
|
Loading…
Reference in New Issue