summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-12-04 17:03:45 +0500
committerilotterytea <iltsu@alright.party>2025-12-04 17:03:45 +0500
commit4dfecba2444f1457b91be46cee32169049a533c3 (patch)
tree17f2ee512b81da24d29f831bc691337eacc82ef4
parent5a1df5c2ba0c9793bc3b90b18cc37ae787e68c24 (diff)
feat: superuser role
-rw-r--r--bot/src/commands/lua.cpp2
-rw-r--r--bot/src/commands/request.cpp13
-rw-r--r--bot/src/config.cpp4
-rw-r--r--bot/src/config.hpp2
-rw-r--r--bot/src/schemas/user.hpp3
5 files changed, 18 insertions, 6 deletions
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index 9e84f8e..0033cc5 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -1007,6 +1007,8 @@ namespace bot::command::lua {
this->level = schemas::PermissionLevel::BROADCASTER;
} else if (rights_text == "trusted") {
this->level = schemas::PermissionLevel::TRUSTED;
+ } else if (rights_text == "superuser") {
+ this->level = schemas::PermissionLevel::SUPERUSER;
} else {
this->level = schemas::PermissionLevel::USER;
}
diff --git a/bot/src/commands/request.cpp b/bot/src/commands/request.cpp
index 28638ef..da5d377 100644
--- a/bot/src/commands/request.cpp
+++ b/bot/src/commands/request.cpp
@@ -111,10 +111,15 @@ namespace bot::command {
schemas::PermissionLevel level = schemas::PermissionLevel::USER;
const auto &badges = irc_message.sender.badges;
- if (std::any_of(cfg.twitch.trusted_user_ids.begin(),
- cfg.twitch.trusted_user_ids.end(), [&user](const int &x) {
- return x == user.get_alias_id();
- })) {
+ if (std::any_of(
+ cfg.twitch.superuser_ids.begin(), cfg.twitch.superuser_ids.end(),
+ [&user](const int &x) { return x == user.get_alias_id(); })) {
+ level = schemas::PermissionLevel::SUPERUSER;
+ } else if (std::any_of(cfg.twitch.trusted_user_ids.begin(),
+ cfg.twitch.trusted_user_ids.end(),
+ [&user](const int &x) {
+ return x == user.get_alias_id();
+ })) {
level = schemas::PermissionLevel::TRUSTED;
} else if (user.get_alias_id() == channel.get_alias_id()) {
level = schemas::PermissionLevel::BROADCASTER;
diff --git a/bot/src/config.cpp b/bot/src/config.cpp
index a2cd2d6..fc6a5fe 100644
--- a/bot/src/config.cpp
+++ b/bot/src/config.cpp
@@ -122,6 +122,10 @@ namespace bot {
for (const std::string &x : utils::string::split_text(value, ',')) {
ttv_cfg.trusted_user_ids.push_back(std::stoi(x));
}
+ } else if (key == "twitch.superuser_ids") {
+ for (const std::string &x : utils::string::split_text(value, ',')) {
+ ttv_cfg.superuser_ids.push_back(std::stoi(x));
+ }
}
else if (key == "db_name") {
diff --git a/bot/src/config.hpp b/bot/src/config.hpp
index 020721d..ffc835e 100644
--- a/bot/src/config.hpp
+++ b/bot/src/config.hpp
@@ -27,7 +27,7 @@ namespace bot {
struct TwitchConfiguration {
std::string client_id;
std::string token;
- std::vector<int> trusted_user_ids;
+ std::vector<int> trusted_user_ids, superuser_ids;
};
struct KickCredentialsConfiguration {
diff --git a/bot/src/schemas/user.hpp b/bot/src/schemas/user.hpp
index 2b8de81..0ce09c8 100644
--- a/bot/src/schemas/user.hpp
+++ b/bot/src/schemas/user.hpp
@@ -56,7 +56,8 @@ namespace bot::schemas {
VIP,
MODERATOR,
BROADCASTER,
- TRUSTED = 50
+ TRUSTED = 50,
+ SUPERUSER = 99
};
class UserRights {