summaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/src/commands/lua.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index 396a5a2..337551f 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -697,29 +697,32 @@ namespace bot::command::lua {
}
}
- Response parse_lua_response(const sol::table &r, sol::object &res) {
+ Response parse_lua_response(const sol::table &r, sol::object &res,
+ bool moon_prefix = true) {
+ const std::string prefix = moon_prefix ? "🌑 " : "";
+
if (res.get_type() == sol::type::function) {
sol::function f = res.as<sol::function>();
sol::object o = f(r);
return parse_lua_response(r, o);
} else if (res.get_type() == sol::type::string) {
- return {"🌑 " + res.as<std::string>()};
+ return {prefix + res.as<std::string>()};
} else if (res.get_type() == sol::type::number) {
- return {"🌑 " + std::to_string(res.as<double>())};
+ return {prefix + std::to_string(res.as<double>())};
} else if (res.get_type() == sol::type::boolean) {
- return {"🌑 " + std::to_string(res.as<bool>())};
+ return {prefix + std::to_string(res.as<bool>())};
} else if (res.get_type() == sol::type::table) {
sol::table t = res.as<sol::table>();
std::vector<std::string> o;
for (auto &kv : t) {
if (kv.second.is<std::string>()) {
- o.push_back(kv.second.as<std::string>());
+ o.push_back(prefix + kv.second.as<std::string>());
}
}
return {o};
} else {
// should it be ResponseException?
- return {"Empty or unsupported response"};
+ return {prefix + "Empty or unsupported response"};
}
}
@@ -794,6 +797,6 @@ namespace bot::command::lua {
const Request &request) const {
sol::table r = request.as_lua_table(this->luaState);
sol::object response = this->handle(r);
- return parse_lua_response(r, response);
+ return parse_lua_response(r, response, false);
}
} \ No newline at end of file