summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-05-01 00:15:19 +0500
committerilotterytea <iltsu@alright.party>2024-05-01 00:15:19 +0500
commit6a05c1bc5990eb4b10cc2454b7f2679b0e51d4b9 (patch)
treeb4f3e16d648f939b63c37fa32f0ef7220e1dd40d /src
parentf9859164676f8fc3fa174d6c351308e6acc2b369 (diff)
upd: updated the '!ping' command
Diffstat (limited to 'src')
-rw-r--r--src/modules/ping.hpp22
1 files changed, 21 insertions, 1 deletions
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 <sys/resource.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <chrono>
#include <string>
#include <variant>
#include <vector>
#include "../bundle.hpp"
#include "../commands/command.hpp"
+#include "../utils/chrono.hpp"
namespace bot {
namespace mod {
@@ -15,7 +21,21 @@ namespace bot {
std::variant<std::vector<std::string>, 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<std::chrono::seconds>(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();
}
};
}