From 6a05c1bc5990eb4b10cc2454b7f2679b0e51d4b9 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 1 May 2024 00:15:19 +0500 Subject: upd: updated the '!ping' command --- src/modules/ping.hpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/modules/ping.hpp b/src/modules/ping.hpp index 724beab..b6409ca 100644 --- a/src/modules/ping.hpp +++ b/src/modules/ping.hpp @@ -1,11 +1,17 @@ #pragma once +#include +#include +#include + +#include #include #include #include #include "../bundle.hpp" #include "../commands/command.hpp" +#include "../utils/chrono.hpp" namespace bot { namespace mod { @@ -15,7 +21,21 @@ namespace bot { std::variant, std::string> run( const InstanceBundle &bundle, const command::Request &request) const override { - return "pong"; + auto now = std::chrono::steady_clock::now(); + auto duration = now - START_TIME; + auto seconds = + std::chrono::duration_cast(duration); + std::string uptime = utils::chrono::format_timestamp(seconds.count()); + + struct rusage usage; + getrusage(RUSAGE_SELF, &usage); + + int used_memory = usage.ru_maxrss / 1024; + + return bundle.localization + .get_formatted_line(request, loc::LineId::PingResponse, + {uptime, std::to_string(used_memory)}) + .value(); } }; } -- cgit v1.2.3