// SPDX-FileCopyrightText: 2024 Yury Gubich // SPDX-License-Identifier: GPL-3.0-or-later #include "actor.h" Module::Actor::Actor(const std::shared_ptr& core, const std::shared_ptr& connection, const Permissions& permissions): Module(core, connection, permissions) {} Module::Actor::~Actor() noexcept {} void Module::Actor::message(const std::shared_ptr<::Actor>& actor, const Module::Module::Tokens& args) { std::string result; if (args.front() == "list") result = hasPermission("read", actor) ? list() : "Can not tell you that"; if (!result.empty()) connection->send(actor->jid, result); } std::string Module::Actor::list() { std::string result; for (const std::pair& pair : core->router.getActors()) { if (!result.empty()) result.append(1, '\n'); result += pair.first + ": " + pair.second; } if (result.empty()) result += "There are no actors currently"; return result; }