Refactored in a way modules have access to bot infrastructure

This commit is contained in:
Blue 2025-03-09 21:01:41 +02:00
parent c605b3ba93
commit 89c04254b8
Signed by: blue
GPG key ID: 9B203B252A63EE38
25 changed files with 245 additions and 216 deletions

View file

@ -3,13 +3,33 @@
#include "actor.h"
Module::Actor::Actor(const std::shared_ptr<gloox::Client>& client):
Module(client)
Module::Actor::Actor(const std::shared_ptr<Core>& core, const std::shared_ptr<Connection>& connection):
Module(core, connection)
{}
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")
sendMessage(actor, "Me\nMyself\nI");
result = list();
if (!result.empty())
connection->send(actor->jid, result);
}
std::string Module::Actor::list() {
std::string result;
for (const std::pair<const std::string, std::string>& 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;
}