diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-06 18:25:46 +0400 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-06 18:25:46 +0400 |
| commit | d1f8efef4a68f81ca104e9b8f51e04497f3bd8aa (patch) | |
| tree | ce13d90a87fdbe25c8871ff1f39322681cd520b4 /bot/src/modules | |
| parent | 2a49844a95593ac98e919c18651320e62f276fa7 (diff) | |
feat: !ping in lua + bot and time libraries
Diffstat (limited to 'bot/src/modules')
| -rw-r--r-- | bot/src/modules/ping.hpp | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/bot/src/modules/ping.hpp b/bot/src/modules/ping.hpp deleted file mode 100644 index cc982f6..0000000 --- a/bot/src/modules/ping.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include <sys/resource.h> -#include <sys/types.h> -#include <unistd.h> - -#include <chrono> -#include <string> -#include <vector> - -#include "../bundle.hpp" -#include "../commands/command.hpp" -#include "../utils/chrono.hpp" - -namespace bot { - namespace mod { - class Ping : public command::Command { - std::string get_name() const override { return "ping"; } - - command::Response run(const InstanceBundle &bundle, - const command::Request &request) const override { - 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; - - std::string cpp_info; - -#ifdef __cplusplus - cpp_info.append("C++" + std::to_string(__cplusplus).substr(2, 2)); -#endif - -#ifdef __VERSION__ - cpp_info.append(" (gcc " + - bot::utils::string::split_text(__VERSION__, ' ')[0] + - ")"); -#endif - - if (!cpp_info.empty()) { - cpp_info.append(" ยท "); - } - - return command::Response( - bundle.localization - .get_formatted_line( - request, loc::LineId::PingResponse, - {cpp_info, uptime, std::to_string(used_memory)}) - .value()); - } - }; - } -} |
