From 428998889e9bb60c7dc46388184b07c489ddaeb2 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 4 Dec 2025 01:26:30 +0500 Subject: feat: trusted users --- bot/src/commands/request.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bot/src/commands/request.cpp') diff --git a/bot/src/commands/request.cpp b/bot/src/commands/request.cpp index d8a91f9..28638ef 100644 --- a/bot/src/commands/request.cpp +++ b/bot/src/commands/request.cpp @@ -6,9 +6,11 @@ #include #include +#include "config.hpp" #include "constants.hpp" #include "database.hpp" #include "schemas/channel.hpp" +#include "schemas/user.hpp" #include "utils/string.hpp" namespace bot::command { @@ -38,7 +40,7 @@ namespace bot::command { std::optional get_requester( const irc::Message &irc_message, - std::unique_ptr &conn) { + std::unique_ptr &conn, const Configuration &cfg) { // fetching channel std::vector chans = conn->query_all( "SELECT * FROM channels WHERE alias_id = $1", @@ -109,7 +111,12 @@ namespace bot::command { schemas::PermissionLevel level = schemas::PermissionLevel::USER; const auto &badges = irc_message.sender.badges; - if (user.get_alias_id() == channel.get_alias_id()) { + 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; } else if (std::any_of(badges.begin(), badges.end(), [&](const auto &x) { return x.first == "moderator"; -- cgit v1.2.3