summaryrefslogtreecommitdiff
path: root/bot/src/config.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-12-01 16:50:39 +0500
committerilotterytea <iltsu@alright.party>2025-12-01 16:50:39 +0500
commit0d36a1ee88fb7aedf5b33af7ac95140b002c5a64 (patch)
tree7f51f629da03376e214c7683f738b05ed4be3816 /bot/src/config.cpp
parent71a4a8d6fc4a84029939003107bfbaad33b8c6ce (diff)
feat: rss timeout
Diffstat (limited to 'bot/src/config.cpp')
-rw-r--r--bot/src/config.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/bot/src/config.cpp b/bot/src/config.cpp
index 4e4b71d..6cd8cf1 100644
--- a/bot/src/config.cpp
+++ b/bot/src/config.cpp
@@ -65,18 +65,23 @@ namespace bot {
} else {
url["randompost"] = sol::lua_nil;
}
- if (this->url.rssbridge.has_value()) {
- url["rssbridge"] = this->url.rssbridge.value();
+ o["url"] = url;
+
+ sol::table rss = luaState->create_table();
+ if (this->rss.bridge.has_value()) {
+ rss["bridge"] = this->rss.bridge.value();
} else {
- url["rssbridge"] = sol::lua_nil;
+ rss["bridge"] = sol::lua_nil;
}
- o["url"] = url;
+ rss["timeout"] = this->rss.timeout;
+
+ o["rss"] = rss;
return o;
}
std::optional<Configuration> parse_configuration_from_file(
- const std::string &file_path) {
+ const std::string& file_path) {
std::ifstream ifs(file_path);
if (!ifs.is_open()) {
@@ -92,6 +97,7 @@ namespace bot {
OwnerConfiguration owner_cfg;
UrlConfiguration url_cfg;
TokenConfiguration token_cfg;
+ RssConfiguration rss_cfg;
std::string line;
while (std::getline(ifs, line, '\n')) {
@@ -102,7 +108,7 @@ namespace bot {
std::getline(iss, key, '=');
std::getline(iss, value);
- for (char &c : key) {
+ for (char& c : key) {
c = tolower(c);
}
@@ -154,8 +160,12 @@ namespace bot {
url_cfg.paste_service = value;
} else if (key == "url.randompost") {
url_cfg.randompost = value;
- } else if (key == "url.rssbridge") {
- url_cfg.rssbridge = value;
+ }
+
+ else if (key == "rss.timeout") {
+ rss_cfg.timeout = std::stoi(value);
+ } else if (key == "rss.bridge") {
+ rss_cfg.bridge = value;
}
else if (key == "token.github") {
@@ -170,6 +180,7 @@ namespace bot {
cfg.kick_credentials = kick_crd_cfg;
cfg.database = db_cfg;
cfg.tokens = token_cfg;
+ cfg.rss = rss_cfg;
log::info("Configuration",
"Successfully loaded the file from '" + file_path + "'");