summaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/src/commands/lua.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index a35e605..0c02bf5 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -8,6 +8,8 @@
#include <chrono>
#include <cmath>
#include <ctime>
+#include <filesystem>
+#include <fstream>
#include <iomanip>
#include <memory>
#include <nlohmann/json.hpp>
@@ -64,6 +66,29 @@ namespace bot::command::lua {
return usage.ru_maxrss;
});
+ state->set_function("bot_get_temperature", []() {
+ float temp = 0.0;
+
+ std::string path = "/sys/class/thermal/thermal_zone0/temp";
+
+ if (!std::filesystem::exists(path)) {
+ return temp;
+ }
+
+ std::ifstream ifs;
+ ifs.open(path);
+
+ std::stringstream buffer;
+ buffer << ifs.rdbuf();
+ ifs.close();
+
+ temp = std::stof(buffer.str());
+ temp /= 1000;
+ temp = std::roundf(temp * 100) / 100;
+
+ return temp;
+ });
+
state->set_function("bot_get_compile_time",
[]() { return BOT_COMPILED_TIMESTAMP; });