jay/module/module.cpp
2025-03-28 23:12:34 +02:00

29 lines
943 B
C++

// SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "module.h"
#include <algorithm>
#include "gloox/message.h"
Module::Module::Module(const std::shared_ptr<Core>& core, const Shared::Permissions& permissions, const std::string& name):
Shared::Loggable(core->logger, {"Module", name}),
core(core),
permissions(permissions)
{}
bool Module::Module::hasPermission(const std::string& permission, const std::shared_ptr<::Actor>& actor) const {
Shared::Permissions::const_iterator itr = permissions.find(permission);
if (itr == permissions.end())
return false;
return std::find(itr->second.begin(), itr->second.end(), actor->getGroup()) != itr->second.end();
}
Module::Module::~Module() noexcept {}
std::string Module::Module::lower(const std::string& text) {
return std::ranges::to<std::string>(text | std::views::transform(::tolower));
}